Khangai Robot Play - Naive  01
THe naive play of the Khangai Robot
robo_states.h
Go to the documentation of this file.
1 /*
2  * robo_states.h
3  *
4  * Created : 1/9/2019
5  * Author : n-is
6  * email : 073bex422.nischal@pcampus.edu.np
7  */
8 
9 #ifndef _ROBO_STATES_H_
10 #define _ROBO_STATES_H_
11 
12 #include "state_sensor.h"
13 #include "vec2.h"
14 #include "vec4.h"
15 
16 enum class Field
17 {
18  FIELD_A,
19  FIELD_B,
20  FIELD_C,
21  FIELD_D,
22  FIELD_E,
23  FIELD_F,
24  FIELD_G,
25  FIELD_H,
26  FIELD_I,
27  FIELD_J,
28  FIELD_K,
29  FIELD_L,
30 
31  FIELD_O,
32  FIELD_P,
33  FIELD_Q,
34  FIELD_Q1,
35  FIELD_Q2,
36  FIELD_R1,
37  FIELD_R2,
38  FIELD_R,
39  FIELD_S,
40  FIELD_T
41 };
42 
43 struct State_Vars
44 {
46 
50 
51  float last_limit;
53  float first_limit;
54 
55  float max_vel;
56  float rated_vel;
57 
58  float ang_offset;
59 };
60 
62 {
63 public:
65  Robo_States(Robo_States &&) = default;
66 
67  Robo_States(const Robo_States &) = default;
68  Robo_States &operator=(Robo_States &&) = default;
69  Robo_States &operator=(const Robo_States &) = default;
71 
72  float calc_RoboVelocity(Vec3<float> state, uint32_t dt_millis);
73  float calc_AngleOfAttack(Vec3<float> state, float v, uint32_t dt_millis);
74  Vec2<float> calc_Velocity(Vec3<float> state, Vec3<float> vel_from_base, uint32_t dt_millis);
75  bool nextStateReached(Vec3<float> state, uint8_t bounds);
76 
79  Field get_ID() { return sv_->id; }
80  State_Vars* get_State() { return sv_; }
81  void set_State(Robo_States *robo) {
82  sv_ = robo->get_State();
83  next_state_ = robo->get_NextState();
84  }
85 
86  float get_AngOffset() { return sv_->ang_offset; }
87 
88 private:
91 
92  float ramped_;
93 
95  float quadTheta(Vec3<float> state, float v, uint32_t dt_millis);
96  float linearTheta(Vec3<float> state, float v, uint32_t dt_millis);
97 };
98 
99 #endif // !_ROBO_STATES_H_
Robo_States(State_Vars *sv, Robo_States *next)
Definition: robo_states.cpp:25
float quadTheta(Vec3< float > state, float v, uint32_t dt_millis)
Definition: robo_states.cpp:59
Field get_ID()
Definition: robo_states.h:79
Robo_States * get_NextState()
Definition: robo_states.h:77
Vec2< float > lower_bounds
Definition: robo_states.h:49
void set_State(Robo_States *robo)
Definition: robo_states.h:81
bool nextStateReached(Vec3< float > state, uint8_t bounds)
Definition: robo_states.cpp:219
float calc_RoboVelocity(Vec3< float > state, uint32_t dt_millis)
Definition: robo_states.cpp:38
Definition: robo_states.h:61
Vec2< float > upper_bounds
Definition: robo_states.h:48
Vec2< float > calc_Velocity(Vec3< float > state, Vec3< float > vel_from_base, uint32_t dt_millis)
Definition: robo_states.cpp:130
float ang_offset
Definition: robo_states.h:58
State_Vars * get_State()
Definition: robo_states.h:80
float calc_AngleOfAttack(Vec3< float > state, float v, uint32_t dt_millis)
Definition: robo_states.cpp:118
float linearTheta(Vec3< float > state, float v, uint32_t dt_millis)
Definition: robo_states.cpp:104
float rated_vel
Definition: robo_states.h:56
~Robo_States()
Definition: robo_states.h:70
Field
Definition: robo_states.h:16
Vec2< float > get_Centre()
Definition: robo_states.h:78
State_Vars * sv_
Definition: robo_states.h:89
float max_vel
Definition: robo_states.h:55
Vec4< float > cubicSpline(Vec2< float > curr, Vec2< float > nex, Vec2< float > nexnex)
Definition: robo_states.h:43
float ramped_
Definition: robo_states.h:92
Field id
Definition: robo_states.h:45
Robo_States * next_state_
Definition: robo_states.h:90
float get_AngOffset()
Definition: robo_states.h:86
Vec2< float > centre
Definition: robo_states.h:47
float last_limit
Definition: robo_states.h:51
float first_limit
Definition: robo_states.h:53
Robo_States & operator=(Robo_States &&)=default
Definition: vec4.h:15
float ramping_factor
Definition: robo_states.h:52