Motion Master
|
#include <cia402_drive.h>
Public Member Functions | |
Cia402Drive (VirtualDevice *virtual_device) | |
int32_t | get_id () const |
Get the device ID. More... | |
uint16_t | get_hardware_id () const |
Get the hardware ID. More... | |
MotionMasterError | init_position_controller () |
Initialize the position controller. More... | |
MotionMasterError | init_velocity_controller () |
Initialize the velocity controller. More... | |
MotionMasterError | init_torque_controller () |
Initialize the torque controller. More... | |
MotionMasterError | init_slave_profile_position () |
Initialize the position profile on the slave. More... | |
MotionMasterError | init_slave_profile_velocity () |
Initialize the velocity profile on the slave. More... | |
MotionMasterError | init_slave_profile_torque () |
Initialize the torque profile on the slave. More... | |
MotionMasterError | deinit_current_controller () |
Deinitialize a controller. More... | |
bool | execute_profile_position_ramp () |
Execute a position profile ramp on the slave. More... | |
void | set_halt_bit (bool value) |
Set the halt bit (up or down) in the controlword. More... | |
void | set_target_position (int32_t position) |
Set the target position. More... | |
void | set_target_velocity (int32_t velocity) |
Set the target velocity. More... | |
void | set_target_torque (int32_t torque) |
Set the target torque. More... | |
uint16_t | get_statusword () |
Get the raw statusword. More... | |
int32_t | get_target_position () |
Get the current target position. More... | |
int32_t | get_target_velocity () |
Get the current target velocity. More... | |
int32_t | get_target_torque () |
Get the current target torque. More... | |
Cia402State | get_cia402_state () |
Get the current CiA402 state. More... | |
OpMode | get_op_mode () |
Get the current OP mode. More... | |
int32_t | get_current_position () |
Get the current position. More... | |
int32_t | get_current_velocity () |
Get the current velocity. More... | |
int32_t | get_current_torque () |
Get the current torque. More... | |
uint32_t | get_current_timestamp () |
Get the current timestamp. More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, int32_t value) |
Set parameter value (and reload the device if requested) More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, int32_t value, bool reload_configuration) |
Set parameter value (and reload the device if requested) More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, float value) |
Set parameter value (and reload the device if requested) More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, float value, bool reload_configuration) |
Set parameter value (and reload the device if requested) More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, double value) |
Set parameter value (and reload the device if requested) More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, double value, bool reload_configuration) |
Set parameter value (and reload the device if requested) More... | |
MotionMasterError | set_parameter (uint16_t index, uint8_t subindex, const std::string &value) |
Set parameter value. More... | |
VirtualParameter * | get_parameter (uint16_t index, uint8_t subindex) |
Get a parameter by index/subindex. More... | |
MotionMasterError | reload_drive (bool ignore_fault_reset_timeout=false) |
Make the CiA402 drive reload (soft restart) More... | |
std::variant< MotionMasterError, std::list< std::string > > | get_file_list () const |
Get the list of available files on the flash memory. More... | |
std::variant< MotionMasterError, std::string > | read_file (const std::string &file_name) const |
Get the file content from a file from the flash memory. More... | |
MotionMasterError | write_file (const std::string &name, const std::string &content) |
Write the file to the flash memory. More... | |
MotionMasterError | remove_file (const std::string &file_name) |
Remove a file from the flash memory. More... | |
std::string | get_log () |
Get the slave log from the flash memory. More... | |
std::map< uint16_t, EncoderFunction > | get_all_encoder_functions () |
Get all encoder functions. More... | |
bool | set_encoder_function (uint16_t index, EncoderFunction encoder_function) |
(Re)set an encoder function based on the get_all_encoder_functions output More... | |
EncoderType | get_commutation_encoder_type () |
Get the type of the encoder set as the commutation encoder. More... | |
uint32_t | get_commutation_encoder_resolution () |
Find the resolution of the encoder used for commutation feedback. More... | |
uint32_t | get_position_control_encoder_resolution () |
Find the resolution of the encoder used for motion feedback (function 1 or 3) More... | |
bool | is_gearbox_potentially_present () |
Determine if a gearbox is potentially present depending on the encoder configuration. More... | |
double | get_gear_ratio () |
Get the configured gear ratio. More... | |
double | get_feed_constant () |
Get and calculate the feed constant if set. More... | |
bool | is_brake_engaged () |
Check if the brake is currently engaged. More... | |
MotionMasterError | engage_brake (bool value) |
Apply or release the brake. More... | |
void | reset_torque_target_and_offset () |
void | quick_stop () |
Request a quick stop on a device. More... | |
MotionMasterError | quick_stop_blocking () |
Request an asynchronous quick stop on a device. More... | |
int32_t | save_current_configuration_to_flash () |
Save the current device configuration to the flash memory. More... | |
int32_t | load_configuration_from_flash () |
Load the configuration from the flash memory. More... | |
bool | is_running () |
Check if the device is currently running. More... | |
bool | get_fault_state () |
Get the current fault state. More... | |
MotionMasterError | reset_fault (bool ignore_timeout_error=false) |
Reset the current fault. More... | |
bool | get_warning_status () |
Get the current warning status. More... | |
bool | get_internal_limit_reached () |
Check if the internal limit reached statusword bit is active. More... | |
bool | is_operational () |
Check if the device is operational. More... | |
MotionMasterError | state_machine_control (OpMode target_op_mode, Cia402State target_state) |
Change the device OP mode and CiA402 state. More... | |
MotionMasterError | state_machine_control (Cia402State target_state) |
Change the device CiA402 state. More... | |
std::vector< int16_t > | get_cogging_torque_compensation_data () |
Get the cogging torque compensation values. More... | |
MotionMasterError | read_encoder_register (uint8_t encoder_ordinal, uint8_t address, uint8_t &value) |
Read a value from an encoder register. More... | |
MotionMasterError | write_encoder_register (uint8_t encoder_ordinal, uint8_t address, uint8_t value) |
Write a value into an encoder register. More... | |
std::tuple< uint8_t, uint8_t, uint8_t > | get_controller_encoder_sources () |
Get the encoder used for each of the controllers. More... | |
Static Public Attributes | |
static std::map< uint8_t, uint16_t > | fw_v5_encoder_configuration_map_ |
static std::map< uint8_t, uint16_t > | fw_v5_encoder_feedback_map_ |
static std::map< std::tuple< bool, bool, bool >, EncoderFunction > | controller_to_encoder_function_map_ |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
explicit |
MotionMasterError Cia402Drive::deinit_current_controller | ( | ) |
Deinitialize a controller.
MotionMasterError Cia402Drive::engage_brake | ( | bool | value | ) |
Apply or release the brake.
value | true to apply, false to release |
bool Cia402Drive::execute_profile_position_ramp | ( | ) |
Execute a position profile ramp on the slave.
std::map< uint16_t, Cia402Drive::EncoderFunction > Cia402Drive::get_all_encoder_functions | ( | ) |
Get all encoder functions.
IMPORTANT NOTE: For firmwares < v5, the map contains the parameter indexes of the encoder configurations in the object dictionary, but for firmwares >= v5 (including the calibration firmwares > v0.3.7), the map contains the indexes of the encoders (1 or 2)
Cia402Drive::Cia402State Cia402Drive::get_cia402_state | ( | ) |
Get the current CiA402 state.
std::vector< int16_t > Cia402Drive::get_cogging_torque_compensation_data | ( | ) |
Get the cogging torque compensation values.
Get the contents of the cogging_torque.bin file from the flash memory as a vector of signed 16-bit integers
MotionMasterError |
uint32_t Cia402Drive::get_commutation_encoder_resolution | ( | ) |
Find the resolution of the encoder used for commutation feedback.
Cia402Drive::EncoderType Cia402Drive::get_commutation_encoder_type | ( | ) |
Get the type of the encoder set as the commutation encoder.
std::tuple< uint8_t, uint8_t, uint8_t > Cia402Drive::get_controller_encoder_sources | ( | ) |
Get the encoder used for each of the controllers.
Controllers: position, velocity, torque (in that order)
int32_t Cia402Drive::get_current_position | ( | ) |
Get the current position.
uint32_t Cia402Drive::get_current_timestamp | ( | ) |
Get the current timestamp.
int32_t Cia402Drive::get_current_torque | ( | ) |
Get the current torque.
int32_t Cia402Drive::get_current_velocity | ( | ) |
Get the current velocity.
bool Cia402Drive::get_fault_state | ( | ) |
Get the current fault state.
double Cia402Drive::get_feed_constant | ( | ) |
Get and calculate the feed constant if set.
std::variant< MotionMasterError, std::list< std::string > > Cia402Drive::get_file_list | ( | ) | const |
Get the list of available files on the flash memory.
double Cia402Drive::get_gear_ratio | ( | ) |
Get the configured gear ratio.
IMPORTANT: Only gets the configured gear ratio, but doesn't guarantee its correctness.
uint16_t Cia402Drive::get_hardware_id | ( | ) | const |
Get the hardware ID.
int32_t Cia402Drive::get_id | ( | ) | const |
Get the device ID.
bool Cia402Drive::get_internal_limit_reached | ( | ) |
Check if the internal limit reached statusword bit is active.
std::string Cia402Drive::get_log | ( | ) |
Get the slave log from the flash memory.
Cia402Drive::OpMode Cia402Drive::get_op_mode | ( | ) |
Get the current OP mode.
VirtualParameter * Cia402Drive::get_parameter | ( | uint16_t | index, |
uint8_t | subindex | ||
) |
Get a parameter by index/subindex.
index | |
subindex |
uint32_t Cia402Drive::get_position_control_encoder_resolution | ( | ) |
Find the resolution of the encoder used for motion feedback (function 1 or 3)
uint16_t Cia402Drive::get_statusword | ( | ) |
Get the raw statusword.
int32_t Cia402Drive::get_target_position | ( | ) |
Get the current target position.
int32_t Cia402Drive::get_target_torque | ( | ) |
Get the current target torque.
int32_t Cia402Drive::get_target_velocity | ( | ) |
Get the current target velocity.
bool Cia402Drive::get_warning_status | ( | ) |
Get the current warning status.
MotionMasterError Cia402Drive::init_position_controller | ( | ) |
Initialize the position controller.
MotionMasterError Cia402Drive::init_slave_profile_position | ( | ) |
Initialize the position profile on the slave.
MotionMasterError Cia402Drive::init_slave_profile_torque | ( | ) |
Initialize the torque profile on the slave.
MotionMasterError Cia402Drive::init_slave_profile_velocity | ( | ) |
Initialize the velocity profile on the slave.
MotionMasterError Cia402Drive::init_torque_controller | ( | ) |
Initialize the torque controller.
MotionMasterError Cia402Drive::init_velocity_controller | ( | ) |
Initialize the velocity controller.
bool Cia402Drive::is_brake_engaged | ( | ) |
Check if the brake is currently engaged.
MotionMasterError(Error::kBrakeGetFailed) |
bool Cia402Drive::is_gearbox_potentially_present | ( | ) |
Determine if a gearbox is potentially present depending on the encoder configuration.
IMPORTANT: If the encoder configuration is not correct, this function will not produce the correct result. Get gear ratio to get more precise information about the presence of a gearbox.
bool Cia402Drive::is_operational | ( | ) |
Check if the device is operational.
Checks if the device is in CiA402 operation enabled state
bool Cia402Drive::is_running | ( | ) |
Check if the device is currently running.
int32_t Cia402Drive::load_configuration_from_flash | ( | ) |
Load the configuration from the flash memory.
void Cia402Drive::quick_stop | ( | ) |
Request a quick stop on a device.
MotionMasterError Cia402Drive::quick_stop_blocking | ( | ) |
Request an asynchronous quick stop on a device.
MotionMasterError Cia402Drive::read_encoder_register | ( | uint8_t | encoder_ordinal, |
uint8_t | address, | ||
uint8_t & | value | ||
) |
Read a value from an encoder register.
encoder_ordinal | ordinal of the used encoder |
address | register address |
value | output value |
std::variant< MotionMasterError, std::string > Cia402Drive::read_file | ( | const std::string & | file_name | ) | const |
Get the file content from a file from the flash memory.
file_name | name of the file in the flash memory |
MotionMasterError Cia402Drive::reload_drive | ( | bool | ignore_fault_reset_timeout = false | ) |
Make the CiA402 drive reload (soft restart)
This function transitions the drive into the "switch on disabled" and then to the "ready to switch on" state, in order to do a (soft) reset of the drive. This function can be used in order to make the drive to actually use the set configuration. It can also be used to reset a fault straight away.
ignore_fault_reset_timeout |
MotionMasterError Cia402Drive::remove_file | ( | const std::string & | file_name | ) |
Remove a file from the flash memory.
file_name | name of the file in the flash memory |
MotionMasterError Cia402Drive::reset_fault | ( | bool | ignore_timeout_error = false | ) |
void Cia402Drive::reset_torque_target_and_offset | ( | ) |
int32_t Cia402Drive::save_current_configuration_to_flash | ( | ) |
Save the current device configuration to the flash memory.
bool Cia402Drive::set_encoder_function | ( | uint16_t | index, |
EncoderFunction | encoder_function | ||
) |
(Re)set an encoder function based on the get_all_encoder_functions output
index | index of the encoder |
encoder_function | encoder function to set |
void Cia402Drive::set_halt_bit | ( | bool | value | ) |
Set the halt bit (up or down) in the controlword.
value | true for up, false for down |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
const std::string & | value | ||
) |
Set parameter value.
index | |
subindex | |
value |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
double | value | ||
) |
Set parameter value (and reload the device if requested)
index | |
subindex | |
value |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
double | value, | ||
bool | reload_configuration | ||
) |
Set parameter value (and reload the device if requested)
index | |
subindex | |
value | |
reload_configuration |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
float | value | ||
) |
Set parameter value (and reload the device if requested)
index | |
subindex | |
value |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
float | value, | ||
bool | reload_configuration | ||
) |
Set parameter value (and reload the device if requested)
index | |
subindex | |
value | |
reload_configuration |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
int32_t | value | ||
) |
Set parameter value (and reload the device if requested)
index | |
subindex | |
value |
MotionMasterError Cia402Drive::set_parameter | ( | uint16_t | index, |
uint8_t | subindex, | ||
int32_t | value, | ||
bool | reload_configuration | ||
) |
Set parameter value (and reload the device if requested)
index | |
subindex | |
value | |
reload_configuration |
void Cia402Drive::set_target_position | ( | int32_t | position | ) |
Set the target position.
position | target position to set |
void Cia402Drive::set_target_torque | ( | int32_t | torque | ) |
Set the target torque.
torque | target torque to set |
void Cia402Drive::set_target_velocity | ( | int32_t | velocity | ) |
Set the target velocity.
velocity | target velocity to set |
MotionMasterError Cia402Drive::state_machine_control | ( | Cia402State | target_state | ) |
Change the device CiA402 state.
target_state |
This is a safeguard so when we switch to OP enable the motor does not move before the user sets the real target. This should only happen if the quick stop procedure is not currently active, since a user can alter the target during the quick stop active and expect that target to be applied as soon as the drive goes back to OP enabled.
MotionMasterError Cia402Drive::state_machine_control | ( | OpMode | target_op_mode, |
Cia402State | target_state | ||
) |
Change the device OP mode and CiA402 state.
target_op_mode | |
target_state |
Both the drive and Motion Master initially start with "OP mode display" and "OP mode" PDOs set to 0. But if Motion Master was restarted at any point and the drive wasn't, these two values can fall out of sync. In order to prevent Motion Master from sending out of sync "OP mode" values (with 0 value being the most important one, since it triggers the "invalid OP mode" warning on the drive), even if the target and current OP modes are the same, make sure to reapply the same value to the Motion Master internal OP mode RxPDO.
This is a safeguard so when we switch to OP enable the motor does not move before the user sets the real target. This should only happen if the quick stop procedure is not currently active, since a user can alter the target during the quick stop active and expect that target to be applied as soon as the drive goes back to OP enabled.
MotionMasterError Cia402Drive::write_encoder_register | ( | uint8_t | encoder_ordinal, |
uint8_t | address, | ||
uint8_t | value | ||
) |
Write a value into an encoder register.
encoder_ordinal | ordinal of the used encoder |
address | register address |
value | output value |
MotionMasterError Cia402Drive::write_file | ( | const std::string & | name, |
const std::string & | content | ||
) |
Write the file to the flash memory.
name | the name of the file to be written |
content | the content of the file to be written |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |