Loading...
Searching...
No Matches
motor.h
Go to the documentation of this file.
1#ifndef MOTOR_H
2#define MOTOR_H
4class MotorDriver;
5class Motor
6{
7public:
8 Motor();
9 void SetCurrentReference(double);
10 void SetVelocityReference(double);
11 void SetPositionReference(double);
12 void SetPositionOffset(double);
13 void SetKp(double);
14 void SetKd(double);
15 void SetSaturationCurrent(double);
17 void Print();
18 void Enable();
19 void Disable();
20
21 bool IsReady();
22 bool IsEnabled();
24 bool GetIndexToggleBit();
25 double GetPosition();
26 double GetVelocity();
27 double GetCurrent();
28 double GetPositionOffset();
29
30 //state
31 double position = 0.0; // [rad]
32 double velocity = 0.0; // [rad/s]
33 double current = 0.0; // [A]
34 double position_offset = 0.0;// [rad]
35
36 bool is_enabled = false;
37 bool is_ready = false;
38 bool index_toggle_bit = false;
40
41 //commands
42 double position_ref = 0.0; // [rad]
43 double velocity_ref = 0.0; // [rad/s]
44 double current_ref = 0.0; // [A]
45 double current_sat = 0.0; // [A]
46 double kp = 0.0; // [A/rad]
47 double kd = 0.0; // [As/rad]
48
49
50 bool enable = false;
54
56
57 // Set functions for Python binding with Boost
58 void set_position(double val) { this->position = val; };
59 void set_velocity(double val) { this->velocity = val; };
60 void set_current(double val) { this->current = val; };
61 void set_is_enabled(bool val) { this->is_enabled = val; };
62 void set_is_ready(bool val) { this->is_ready = val; };
63 void set_has_index_been_detected(bool val) { this->has_index_been_detected = val; };
64 void set_index_toggle_bit(bool val) { this->index_toggle_bit = val; };
65 void set_position_ref(double val) { this->position_ref = val; };
66 void set_velocity_ref(double val) { this->velocity_ref = val; };
67 void set_current_ref(double val) { this->current_ref = val; };
68 void set_current_sat(double val) { this->current_sat = val; };
69 void set_kp(double val) { this->kp = val; };
70 void set_kd(double val) { this->kd = val; };
71 void set_enable(bool val) { this->enable = val; };
72 void set_enable_position_rollover_error(bool val) { this->enable_position_rollover_error = val; };
73 void set_enable_index_toggle_bit(bool val) { this->enable_index_toggle_bit = val; };
74 void set_enable_index_offset_compensation(bool val) { this->enable_index_offset_compensation = val; };
75 void set_driver(MotorDriver* new_driver) { this->driver = new_driver; }; // driver is a pointer but in Python we will use the object itself
76
77 // Get functions for Python binding with Boost
78 double get_position() { return this->position; };
79 double get_velocity() { return this->velocity; };
80 double get_current() { return this->current; };
81 bool get_is_enabled() { return this->is_enabled; };
82 bool get_is_ready() { return this->is_ready; };
84 bool get_index_toggle_bit() { return this->index_toggle_bit; };
85 double get_position_ref() { return this->position_ref; };
86 double get_velocity_ref() { return this->velocity_ref; };
87 double get_current_ref() { return this->current_ref; };
88 double get_current_sat() { return this->current_sat; };
89 double get_kp() { return this->kp; };
90 double get_kd() { return this->kd; };
91 bool get_enable() { return this->enable; };
95 MotorDriver* get_driver() { return (this->driver); }; // driver is a pointer but in Python we will use the object itself
96
97};
98
99#endif
Definition motor_driver.h:8
Definition motor.h:6
double GetPosition()
Definition motor.cpp:103
void set_position(double val)
Definition motor.h:58
bool has_index_been_detected
Definition motor.h:39
double get_position_ref()
Definition motor.h:85
void set_kd(double val)
Definition motor.h:70
bool get_index_toggle_bit()
Definition motor.h:84
void set_kp(double val)
Definition motor.h:69
bool get_enable_index_toggle_bit()
Definition motor.h:93
bool enable
Definition motor.h:50
void set_driver(MotorDriver *new_driver)
Definition motor.h:75
bool get_is_enabled()
Definition motor.h:81
double get_current()
Definition motor.h:80
double GetVelocity()
Definition motor.cpp:113
bool get_enable_index_offset_compensation()
Definition motor.h:94
double position_ref
Definition motor.h:42
void set_has_index_been_detected(bool val)
Definition motor.h:63
double current_ref
Definition motor.h:44
double position_offset
Definition motor.h:34
double kp
Definition motor.h:46
void set_index_toggle_bit(bool val)
Definition motor.h:64
double get_velocity_ref()
Definition motor.h:86
void set_current(double val)
Definition motor.h:60
void set_position_ref(double val)
Definition motor.h:65
void SetKd(double)
Definition motor.cpp:73
bool get_is_ready()
Definition motor.h:82
void SetPositionReference(double)
Definition motor.cpp:53
double get_current_sat()
Definition motor.h:88
bool get_enable()
Definition motor.h:91
bool GetIndexToggleBit()
Definition motor.cpp:98
bool enable_index_toggle_bit
Definition motor.h:52
double get_kp()
Definition motor.h:89
MotorDriver * driver
Definition motor.h:55
void set_velocity_ref(double val)
Definition motor.h:66
bool is_ready
Definition motor.h:37
double get_position()
Definition motor.h:78
bool index_toggle_bit
Definition motor.h:38
double kd
Definition motor.h:47
double GetCurrent()
Definition motor.cpp:118
double velocity
Definition motor.h:32
void Disable()
Definition motor.cpp:43
bool IsReady()
Definition motor.cpp:83
bool is_enabled
Definition motor.h:36
double get_kd()
Definition motor.h:90
void set_is_enabled(bool val)
Definition motor.h:61
MotorDriver * get_driver()
Definition motor.h:95
void SetDriver(MotorDriver *driver)
Definition motor.cpp:21
double GetPositionOffset()
Definition motor.cpp:108
void SetVelocityReference(double)
Definition motor.cpp:58
void set_is_ready(bool val)
Definition motor.h:62
double current_sat
Definition motor.h:45
double get_current_ref()
Definition motor.h:87
void SetKp(double)
Definition motor.cpp:68
void set_enable_index_offset_compensation(bool val)
Definition motor.h:74
void SetPositionOffset(double)
Definition motor.cpp:48
void set_current_sat(double val)
Definition motor.h:68
bool get_has_index_been_detected()
Definition motor.h:83
bool get_enable_position_rollover_error()
Definition motor.h:92
void set_enable_index_toggle_bit(bool val)
Definition motor.h:73
void set_enable(bool val)
Definition motor.h:71
void Enable()
Definition motor.cpp:38
void set_enable_position_rollover_error(bool val)
Definition motor.h:72
double velocity_ref
Definition motor.h:43
void set_current_ref(double val)
Definition motor.h:67
double position
Definition motor.h:31
double get_velocity()
Definition motor.h:79
void Print()
Definition motor.cpp:26
double current
Definition motor.h:33
bool HasIndexBeenDetected()
Definition motor.cpp:93
void SetSaturationCurrent(double)
Definition motor.cpp:78
Motor()
Definition motor.cpp:4
bool enable_position_rollover_error
Definition motor.h:51
bool IsEnabled()
Definition motor.cpp:88
bool enable_index_offset_compensation
Definition motor.h:53
void set_velocity(double val)
Definition motor.h:59
void SetCurrentReference(double)
Definition motor.cpp:63