This class CanBusMotorBoard implements a MotorBoardInterface specific to CAN networks.
More...
#include <motor_board.hpp>
|
enum | CanframeIDs {
COMMAND_ID = 0x00,
IqRef = 0x05,
STATUSMSG = 0x10,
Iq = 0x20,
POS = 0x30,
SPEED = 0x40,
ADC6 = 0x50,
ENC_INDEX = 0x60
} |
| These are the frame IDs that define the kind of data we acquiere from the CAN bus.
|
|
|
static THREAD_FUNCTION_RETURN_TYPE | loop (void *instance_pointer) |
| This is the helper function used for spawning the real time thread. More...
|
|
|
enum | MeasurementIndex {
current_0,
current_1,
position_0,
position_1,
velocity_0,
velocity_1,
analog_0,
analog_1,
encoder_index_0,
encoder_index_1,
measurement_count
} |
| This is the list of the measurement we can access.
|
|
enum | ControlIndex { current_target_0,
current_target_1,
control_count
} |
| This is the list of the controls we can send.
|
|
typedef real_time_tools::ThreadsafeTimeseries< double > | ScalarTimeseries |
| A useful shortcut.
|
|
typedef ScalarTimeseries::Index | Index |
| A useful shortcut.
|
|
typedef real_time_tools::ThreadsafeTimeseries< Index > | IndexTimeseries |
| A useful shortcut.
|
|
typedef real_time_tools::ThreadsafeTimeseries< MotorBoardStatus > | StatusTimeseries |
| A useful shortcut.
|
|
typedef real_time_tools::ThreadsafeTimeseries< MotorBoardCommand > | CommandTimeseries |
| A useful shortcut.
|
|
template<typename Type > |
using | Ptr = std::shared_ptr< Type > |
| A useful shortcut.
|
|
template<typename Type > |
using | Vector = std::vector< Type > |
| A useful shortcut.
|
|
This class CanBusMotorBoard implements a MotorBoardInterface specific to CAN networks.
◆ CanBusMotorBoard()
blmc_drivers::CanBusMotorBoard::CanBusMotorBoard |
( |
std::shared_ptr< CanBusInterface > |
can_bus, |
|
|
const size_t & |
history_length = 1000 , |
|
|
const int & |
control_timeout_ms = 100 |
|
) |
| |
◆ bytes_to_int32()
template<typename T >
int32_t blmc_drivers::CanBusMotorBoard::bytes_to_int32 |
( |
T |
bytes | ) |
|
|
inlineprivate |
private methods ========================================================
Useful converters Converts from bytes to int32.
- Template Parameters
-
T | this is the type of the bytes convert. |
- Parameters
-
- Returns
- int32_t the output integer in int32.
◆ float_to_q24()
int32_t blmc_drivers::CanBusMotorBoard::float_to_q24 |
( |
float |
fval | ) |
|
|
inlineprivate |
Converts from float to 24-bit normalized fixed-point.
- Parameters
-
- Returns
- int32_t
◆ get_command()
◆ get_control()
virtual Ptr<const ScalarTimeseries> blmc_drivers::CanBusMotorBoard::get_control |
( |
const int & |
index | ) |
const |
|
inlinevirtual |
Get the controls to be sent.
- Parameters
-
index | the kind of control we are interested in. |
- Returns
- Ptr<const ScalarTimeseries> is the list of the control to be sent.
Implements blmc_drivers::MotorBoardInterface.
◆ get_measurement()
virtual Ptr<const ScalarTimeseries> blmc_drivers::CanBusMotorBoard::get_measurement |
( |
const int & |
index | ) |
const |
|
inlinevirtual |
Getters.
Get the measurement data.
- Parameters
-
index | is the kind of measurement we are insterested in. |
- Returns
- Ptr<const ScalarTimeseries> is the list of the last measurements acquiered from the CAN card.
Implements blmc_drivers::MotorBoardInterface.
◆ get_sent_command()
◆ get_sent_control()
virtual Ptr<const ScalarTimeseries> blmc_drivers::CanBusMotorBoard::get_sent_control |
( |
const int & |
index | ) |
const |
|
inlinevirtual |
Get the already sent controls.
- Parameters
-
index | the kind of control we are interested in. |
- Returns
- Ptr<const ScalarTimeseries> is the list of the sent cotnrols.
Implements blmc_drivers::MotorBoardInterface.
◆ get_status()
◆ loop()
static THREAD_FUNCTION_RETURN_TYPE blmc_drivers::CanBusMotorBoard::loop |
( |
void * |
instance_pointer | ) |
|
|
inlinestaticprivate |
This is the helper function used for spawning the real time thread.
- Parameters
-
instance_pointer | is the current object in this case. |
- Returns
- THREAD_FUNCTION_RETURN_TYPE depends on the current OS.
◆ pause_motors()
void blmc_drivers::CanBusMotorBoard::pause_motors |
( |
| ) |
|
- Todo:
- : this function should go away, and we should add somewhere a warning in case there is a timeout
◆ q24_to_float()
float blmc_drivers::CanBusMotorBoard::q24_to_float |
( |
int32_t |
qval | ) |
|
|
inlineprivate |
Convert from 24-bit normalized fixed-point to float.
- Parameters
-
qval | is the floating base point. |
- Returns
- float is the converted value
◆ qbytes_to_float()
template<typename T >
float blmc_drivers::CanBusMotorBoard::qbytes_to_float |
( |
T |
qbytes | ) |
|
|
inlineprivate |
Converts from qbytes to float.
- Template Parameters
-
T | the type of byte to manage |
- Parameters
-
qbytes | the input value in bytes |
- Returns
- float the output value.
◆ send_newest_controls()
void blmc_drivers::CanBusMotorBoard::send_newest_controls |
( |
| ) |
|
|
private |
send the controls to the cards.
- Parameters
-
controls | are the controls to be sent. |
◆ set_command()
virtual void blmc_drivers::CanBusMotorBoard::set_command |
( |
const MotorBoardCommand & |
command | ) |
|
|
inlinevirtual |
◆ set_control()
virtual void blmc_drivers::CanBusMotorBoard::set_control |
( |
const double & |
control, |
|
|
const int & |
index |
|
) |
| |
|
inlinevirtual |
◆ control_
Inputs.
This is the buffer of the controls to be sent to card.
◆ is_loop_active_
bool blmc_drivers::CanBusMotorBoard::is_loop_active_ |
|
private |
Loop management.
This boolean makes sure that the loop is stopped upon destruction of this object.
◆ measurement_
Outputs.
measurement_ contains all the measurements acquiered from the CAN board.
◆ sent_control_
Log.
This is the history of the already sent controls.
The documentation for this class was generated from the following files: