#include <rx28.h>
Public Types | |
typedef std::list< unsigned char > | DeviceList |
List of servo IDs. | |
Public Member Functions | |
RobotisRX28 (const char *device_file, unsigned int default_timeout_ms=30) | |
Constructor. | |
~RobotisRX28 () | |
Destructor. | |
void | open () |
Open serial port. | |
void | close () |
Close port. | |
bool | ping (unsigned char id, unsigned int timeout_ms=100) |
Ping servo. | |
DeviceList | discover (unsigned int total_timeout_ms=50) |
Discover devices on the bus. | |
void | write_table_value (unsigned char id, unsigned char addr, unsigned int value, bool double_byte=false) |
Write a table value. | |
void | write_table_values (unsigned char id, unsigned char start_addr, unsigned char *values, unsigned int num_values) |
Write multiple table values. | |
void | read_table_values (unsigned char id) |
Read all table values for given servo. | |
void | read_table_value (unsigned char id, unsigned char addr, unsigned char read_length) |
Read a table value. | |
void | start_read_table_values (unsigned char id) |
Start to receive table values. | |
void | finish_read_table_values () |
Finish control table receive operations. | |
void | goto_position (unsigned char id, unsigned int value) |
Move servo to specified position. | |
void | goto_positions (unsigned int num_positions,...) |
Move several servos to specified positions. | |
unsigned int | get_model (unsigned char id, bool refresh=false) |
Get model. | |
unsigned int | get_position (unsigned char id, bool refresh=false) |
Get current position. | |
unsigned char | get_firmware_version (unsigned char id, bool refresh=false) |
Get firmware version. | |
unsigned char | get_baudrate (unsigned char id, bool refresh=false) |
Get baud rate. | |
unsigned char | get_delay_time (unsigned char id, bool refresh=false) |
Get time of the delay before replies are sent. | |
void | get_angle_limits (unsigned char id, unsigned int &cw_limit, unsigned int &ccw_limit, bool refresh=false) |
Get angle limits. | |
unsigned char | get_temperature_limit (unsigned char id, bool refresh=false) |
Get temperature limit. | |
void | get_voltage_limits (unsigned char id, unsigned char &low, unsigned char &high, bool refresh=false) |
Get voltage limits. | |
unsigned int | get_max_torque (unsigned char id, bool refresh=false) |
Get maximum torque. | |
unsigned char | get_status_return_level (unsigned char id, bool refresh=false) |
Get status return level. | |
unsigned char | get_alarm_led (unsigned char id, bool refresh=false) |
Get alarm LED status. | |
unsigned char | get_alarm_shutdown (unsigned char id, bool refresh=false) |
Get shutdown on alarm state. | |
void | get_calibration (unsigned char id, unsigned int &down_calib, unsigned int &up_calib, bool refresh=false) |
Get calibration data. | |
bool | is_torque_enabled (unsigned char id, bool refresh=false) |
Check if torque is enabled. | |
bool | is_led_enabled (unsigned char id, bool refresh=false) |
Check if LED is enabled. | |
void | get_compliance_values (unsigned char id, unsigned char &cw_margin, unsigned char &cw_slope, unsigned char &ccw_margin, unsigned char &ccw_slope, bool refresh=false) |
Get compliance values. | |
unsigned int | get_goal_position (unsigned char id, bool refresh=false) |
Get goal position. | |
unsigned int | get_goal_speed (unsigned char id, bool refresh=false) |
Get goal speed. | |
float | get_max_supported_speed (unsigned char id, bool refresh=false) |
Get maximum supported speed. | |
unsigned int | get_torque_limit (unsigned char id, bool refresh=false) |
Get torque limit. | |
unsigned int | get_speed (unsigned char id, bool refresh=false) |
Get current speed. | |
unsigned int | get_load (unsigned char id, bool refresh=false) |
Get current load. | |
unsigned char | get_voltage (unsigned char id, bool refresh=false) |
Get current voltage. | |
unsigned char | get_temperature (unsigned char id, bool refresh=false) |
Get temperature. | |
bool | is_moving (unsigned char id, bool refresh=false) |
Check if servo is moving. | |
bool | is_locked (unsigned char id, bool refresh=false) |
Check is servo is locked. | |
unsigned int | get_punch (unsigned char id, bool refresh=false) |
Get punch. | |
void | set_id (unsigned char id, unsigned char new_id) |
Set ID. | |
void | set_baudrate (unsigned char id, unsigned char baudrate) |
Set baud rate. | |
void | set_return_delay_time (unsigned char id, unsigned char return_delay_time) |
Set return delay time. | |
void | set_angle_limits (unsigned char id, unsigned int cw_limit, unsigned int ccw_limit) |
Set angle limits. | |
void | set_temperature_limit (unsigned char id, unsigned char temp_limit) |
Set temperature limit. | |
void | set_voltage_limits (unsigned char id, unsigned char low, unsigned char high) |
Set voltage limits. | |
void | set_max_torque (unsigned char id, unsigned int max_torque) |
Set maximum torque. | |
void | set_status_return_level (unsigned char id, unsigned char status_return_level) |
Set status return level. | |
void | set_alarm_led (unsigned char id, unsigned char alarm_led) |
Set alarm LED settings. | |
void | set_alarm_shutdown (unsigned char id, unsigned char alarm_shutdown) |
Set shutdown on alarm. | |
void | set_torque_enabled (unsigned char id, bool enabled) |
Enable or disable torque. | |
void | set_torques_enabled (bool enabled, unsigned char num_servos,...) |
Enable or disable torque for multiple (selected) servos at once. | |
void | set_led_enabled (unsigned char id, bool enabled) |
Turn LED on or off. | |
void | set_compliance_values (unsigned char id, unsigned char cw_margin, unsigned char cw_slope, unsigned char ccw_margin, unsigned char ccw_slope) |
Set compliance values. | |
void | set_goal_speed (unsigned char id, unsigned int goal_speed) |
Set goal speed. | |
void | set_goal_speeds (unsigned int num_servos,...) |
Set goal speeds for multiple servos. | |
void | set_torque_limit (unsigned char id, unsigned int torque_limit) |
Set torque limit. | |
void | lock_config (unsigned char id) |
Lock config. | |
void | set_punch (unsigned char id, unsigned int punch) |
Set punch. | |
bool | data_available () |
Check data availability. | |
Static Public Attributes | |
static const unsigned char | SRL_RESPOND_NONE = 0 |
SRL_RESPOND_NONE. | |
static const unsigned char | SRL_RESPOND_READ = 1 |
SRL_RESPOND_READ. | |
static const unsigned char | SRL_RESPOND_ALL = 2 |
SRL_RESPOND_ALL. | |
static const unsigned char | BROADCAST_ID = 0xfe |
BROADCAST_ID. | |
static const unsigned int | MAX_POSITION = 0x3ff |
MAX_POSITION. | |
static const unsigned int | CENTER_POSITION = 0x1ff |
CENTER_POSITION. | |
static const float | MAX_ANGLE_DEG = 300 |
MAX_ANGLE_DEG. | |
static const float | MAX_ANGLE_RAD = fawkes::deg2rad(RobotisRX28::MAX_ANGLE_DEG) |
MAX_ANGLE_RAD. | |
static const float | RAD_PER_POS_TICK = RobotisRX28::MAX_ANGLE_RAD / (float)(RobotisRX28::MAX_POSITION) |
RAD_PER_POS_TICK. | |
static const float | POS_TICKS_PER_RAD = (float)(RobotisRX28::MAX_POSITION) / RobotisRX28::MAX_ANGLE_RAD |
POS_TICKS_PER_RAD. | |
static const float | SEC_PER_60DEG_12V = 0.167 |
SEC_PER_60DEG_12V. | |
static const float | SEC_PER_60DEG_16V = 0.126 |
SEC_PER_60DEG_16V. | |
static const unsigned int | MAX_SPEED = 0x3ff |
MAX_SPEED. | |
static const unsigned char | P_MODEL_NUMBER_L = 0 |
P_MODEL_NUMBER_L. | |
static const unsigned char | P_MODEL_NUMBER_H = 1 |
P_MODEL_NUMBER_H. | |
static const unsigned char | P_VERSION = 2 |
P_VERSION. | |
static const unsigned char | P_ID = 3 |
P_ID. | |
static const unsigned char | P_BAUD_RATE = 4 |
P_BAUD_RATE. | |
static const unsigned char | P_RETURN_DELAY_TIME = 5 |
P_RETURN_DELAY_TIME. | |
static const unsigned char | P_CW_ANGLE_LIMIT_L = 6 |
P_CW_ANGLE_LIMIT_L. | |
static const unsigned char | P_CW_ANGLE_LIMIT_H = 7 |
P_CW_ANGLE_LIMIT_H. | |
static const unsigned char | P_CCW_ANGLE_LIMIT_L = 8 |
P_CCW_ANGLE_LIMIT_L. | |
static const unsigned char | P_CCW_ANGLE_LIMIT_H = 9 |
P_CCW_ANGLE_LIMIT_H. | |
static const unsigned char | P_SYSTEM_DATA2 = 10 |
P_SYSTEM_DATA2. | |
static const unsigned char | P_LIMIT_TEMPERATURE = 11 |
P_LIMIT_TEMPERATURE. | |
static const unsigned char | P_DOWN_LIMIT_VOLTAGE = 12 |
P_DOWN_LIMIT_VOLTAGE. | |
static const unsigned char | P_UP_LIMIT_VOLTAGE = 13 |
P_UP_LIMIT_VOLTAGE. | |
static const unsigned char | P_MAX_TORQUE_L = 14 |
P_MAX_TORQUE_L. | |
static const unsigned char | P_MAX_TORQUE_H = 15 |
P_MAX_TORQUE_H. | |
static const unsigned char | P_RETURN_LEVEL = 16 |
P_RETURN_LEVEL. | |
static const unsigned char | P_ALARM_LED = 17 |
P_ALARM_LED. | |
static const unsigned char | P_ALARM_SHUTDOWN = 18 |
P_ALARM_SHUTDOWN. | |
static const unsigned char | P_OPERATING_MODE = 19 |
P_OPERATING_MODE. | |
static const unsigned char | P_DOWN_CALIBRATION_L = 20 |
P_DOWN_CALIBRATION_L. | |
static const unsigned char | P_DOWN_CALIBRATION_H = 21 |
P_DOWN_CALIBRATION_H. | |
static const unsigned char | P_UP_CALIBRATION_L = 22 |
P_UP_CALIBRATION_L. | |
static const unsigned char | P_UP_CALIBRATION_H = 23 |
P_UP_CALIBRATION_H. | |
static const unsigned char | P_TORQUE_ENABLE = 24 |
P_TORQUE_ENABLE. | |
static const unsigned char | P_LED = 25 |
P_LED. | |
static const unsigned char | P_CW_COMPLIANCE_MARGIN = 26 |
P_CW_COMPLIANCE_MARGIN. | |
static const unsigned char | P_CCW_COMPLIANCE_MARGIN = 27 |
P_CCW_COMPLIANCE_MARGIN. | |
static const unsigned char | P_CW_COMPLIANCE_SLOPE = 28 |
P_CW_COMPLIANCE_SLOPE. | |
static const unsigned char | P_CCW_COMPLIANCE_SLOPE = 29 |
P_CCW_COMPLIANCE_SLOPE. | |
static const unsigned char | P_GOAL_POSITION_L = 30 |
P_GOAL_POSITION_L. | |
static const unsigned char | P_GOAL_POSITION_H = 31 |
P_GOAL_POSITION_H. | |
static const unsigned char | P_GOAL_SPEED_L = 32 |
P_GOAL_SPEED_L. | |
static const unsigned char | P_GOAL_SPEED_H = 33 |
P_GOAL_SPEED_H. | |
static const unsigned char | P_TORQUE_LIMIT_L = 34 |
P_TORQUE_LIMIT_L. | |
static const unsigned char | P_TORQUE_LIMIT_H = 35 |
P_TORQUE_LIMIT_H. | |
static const unsigned char | P_PRESENT_POSITION_L = 36 |
P_PRESENT_POSITION_L. | |
static const unsigned char | P_PRESENT_POSITION_H = 37 |
P_PRESENT_POSITION_H. | |
static const unsigned char | P_PRESENT_SPEED_L = 38 |
P_PRESENT_SPEED_L. | |
static const unsigned char | P_PRESENT_SPEED_H = 39 |
P_PRESENT_SPEED_H. | |
static const unsigned char | P_PRESENT_LOAD_L = 40 |
P_PRESENT_LOAD_L. | |
static const unsigned char | P_PRESENT_LOAD_H = 41 |
P_PRESENT_LOAD_H. | |
static const unsigned char | P_PRESENT_VOLTAGE = 42 |
P_PRESENT_VOLTAGE. | |
static const unsigned char | P_PRESENT_TEMPERATURE = 43 |
P_PRESENT_TEMPERATURE. | |
static const unsigned char | P_REGISTERED_INSTRUCTION = 44 |
P_REGISTERED_INSTRUCTION. | |
static const unsigned char | P_PAUSE_TIME = 45 |
P_PAUSE_TIME. | |
static const unsigned char | P_MOVING = 46 |
P_MOVING. | |
static const unsigned char | P_LOCK = 47 |
P_LOCK. | |
static const unsigned char | P_PUNCH_L = 48 |
P_PUNCH_L. | |
static const unsigned char | P_PUNCH_H = 49 |
P_PUNCH_H. |
One instance of this class communicates with a chain of up to 254 Robotis RX28 servos, which are uniquely identified with an ID. Before making use of the chain, connect each servo individually and set its ID. See the discover() method for more information about numbering of the servos. To achieve a higher speed, it is recommended to set the status return level to reply only on READ instructions. You can do this for the whole chain with
rx28->set_status_return_level(RobotisRX28::BROADCAST_ID, RobotisRX28::SRL_RESPOND_READ);
Definition at line 42 of file rx28.h.
typedef std::list<unsigned char> RobotisRX28::DeviceList |
RobotisRX28::RobotisRX28 | ( | const char * | device_file, | |
unsigned int | default_timeout_ms = 30 | |||
) |
void RobotisRX28::close | ( | ) |
bool RobotisRX28::data_available | ( | ) |
RobotisRX28::DeviceList RobotisRX28::discover | ( | unsigned int | timeout_ms = 50 |
) |
Discover devices on the bus.
This method will send a PING instruction to the broadcast ID and collect responses. This assumes that the return delay time is set appropriately that all responses can be received without collisions, and that the difference between the time of two consecutive servos is smaller than the given timeout (note that this might be void if you have one servo with ID 1 and one with ID 253). After sending the packet this method will do up to RX28_MAX_NUM_SERVOS receive operations, each with the given timeout. After the first timeout the discovery is aborted assuming that all replies have been received. You can set the timeout really high (several seconds) to be sure that all connected servos are recognized. For this to work best it is recommended to set consecutive servo IDs starting from 1 on the servos. After the servos are found, the control tables of all recognized servos are received to ensure that all other methods return valid data.
timeout_ms | maximum timeout to wait for replies. |
Definition at line 435 of file rx28.cpp.
References fawkes::Exception::append(), BROADCAST_ID, and read_table_values().
void RobotisRX28::finish_read_table_values | ( | ) |
Finish control table receive operations.
This executes the receive operation initiated by start_read_table_values(). This will read the values and write the output to the control table (in memory, not in the servo), such that the appropriate get methods will return the new data.
Definition at line 526 of file rx28.cpp.
Referenced by read_table_values().
unsigned char RobotisRX28::get_alarm_led | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get alarm LED status.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 834 of file rx28.cpp.
References P_ALARM_LED.
unsigned char RobotisRX28::get_alarm_shutdown | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get shutdown on alarm state.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 846 of file rx28.cpp.
References P_ALARM_SHUTDOWN.
void RobotisRX28::get_angle_limits | ( | unsigned char | id, | |
unsigned int & | cw_limit, | |||
unsigned int & | ccw_limit, | |||
bool | refresh = false | |||
) |
Get angle limits.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value | |
cw_limit | upon return contains the clockwise angle limit | |
ccw_limit | upon return contains the counter-clockwise angle limit |
Definition at line 767 of file rx28.cpp.
References P_CCW_ANGLE_LIMIT_H, P_CCW_ANGLE_LIMIT_L, P_CW_ANGLE_LIMIT_H, and P_CW_ANGLE_LIMIT_L.
unsigned char RobotisRX28::get_baudrate | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get baud rate.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 742 of file rx28.cpp.
References P_BAUD_RATE.
void RobotisRX28::get_calibration | ( | unsigned char | id, | |
unsigned int & | down_calib, | |||
unsigned int & | up_calib, | |||
bool | refresh = false | |||
) |
Get calibration data.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value | |
down_calib | downward calibration | |
up_calib | upward calibration |
Definition at line 859 of file rx28.cpp.
References P_DOWN_CALIBRATION_H, P_DOWN_CALIBRATION_L, P_UP_CALIBRATION_H, and P_UP_CALIBRATION_L.
void RobotisRX28::get_compliance_values | ( | unsigned char | id, | |
unsigned char & | cw_margin, | |||
unsigned char & | cw_slope, | |||
unsigned char & | ccw_margin, | |||
unsigned char & | ccw_slope, | |||
bool | refresh = false | |||
) |
Get compliance values.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value | |
cw_margin | upon return contains clockwise margin | |
cw_slope | upon return contains clockwise slope | |
ccw_margin | upon return contains counter-clockwise margin | |
ccw_slope | upon return contains counter-clockwise slope |
Definition at line 901 of file rx28.cpp.
References P_CCW_COMPLIANCE_MARGIN, P_CCW_COMPLIANCE_SLOPE, P_CW_COMPLIANCE_MARGIN, and P_CW_COMPLIANCE_SLOPE.
unsigned char RobotisRX28::get_delay_time | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get time of the delay before replies are sent.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 754 of file rx28.cpp.
References P_RETURN_DELAY_TIME.
unsigned char RobotisRX28::get_firmware_version | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
unsigned int RobotisRX28::get_goal_position | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get goal position.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 919 of file rx28.cpp.
References P_GOAL_POSITION_H, and P_GOAL_POSITION_L.
unsigned int RobotisRX28::get_goal_speed | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get goal speed.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 931 of file rx28.cpp.
References P_GOAL_SPEED_H, and P_GOAL_SPEED_L.
unsigned int RobotisRX28::get_load | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get current load.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 994 of file rx28.cpp.
References P_PRESENT_LOAD_H, and P_PRESENT_LOAD_L.
float RobotisRX28::get_max_supported_speed | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get maximum supported speed.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 943 of file rx28.cpp.
References fawkes::deg2rad(), get_voltage(), SEC_PER_60DEG_12V, and SEC_PER_60DEG_16V.
unsigned int RobotisRX28::get_max_torque | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get maximum torque.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 810 of file rx28.cpp.
References P_MAX_TORQUE_H, and P_MAX_TORQUE_L.
unsigned int RobotisRX28::get_model | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get model.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 706 of file rx28.cpp.
References P_MODEL_NUMBER_H, and P_MODEL_NUMBER_L.
unsigned int RobotisRX28::get_position | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get current position.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 718 of file rx28.cpp.
References P_PRESENT_POSITION_H, and P_PRESENT_POSITION_L.
unsigned int RobotisRX28::get_punch | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
unsigned int RobotisRX28::get_speed | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get current speed.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 982 of file rx28.cpp.
References P_PRESENT_SPEED_H, and P_PRESENT_SPEED_L.
unsigned char RobotisRX28::get_status_return_level | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get status return level.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 822 of file rx28.cpp.
References P_RETURN_LEVEL.
unsigned char RobotisRX28::get_temperature | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get temperature.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 1018 of file rx28.cpp.
References P_PRESENT_TEMPERATURE.
unsigned char RobotisRX28::get_temperature_limit | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get temperature limit.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 782 of file rx28.cpp.
References P_LIMIT_TEMPERATURE.
unsigned int RobotisRX28::get_torque_limit | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get torque limit.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 970 of file rx28.cpp.
References P_TORQUE_LIMIT_H, and P_TORQUE_LIMIT_L.
unsigned char RobotisRX28::get_voltage | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Get current voltage.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 1006 of file rx28.cpp.
References P_PRESENT_VOLTAGE.
Referenced by get_max_supported_speed().
void RobotisRX28::get_voltage_limits | ( | unsigned char | id, | |
unsigned char & | low, | |||
unsigned char & | high, | |||
bool | refresh = false | |||
) |
Get voltage limits.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value | |
low | upon return contains low voltage limit | |
high | upon return contans high voltage limit |
Definition at line 795 of file rx28.cpp.
References P_DOWN_LIMIT_VOLTAGE, and P_UP_LIMIT_VOLTAGE.
void RobotisRX28::goto_position | ( | unsigned char | id, | |
unsigned int | value | |||
) |
Move servo to specified position.
id | servo ID | |
value | position, value between 0 and 1023 (inclusive), covering an angle range from 0 to 300 degrees. |
Definition at line 1341 of file rx28.cpp.
References P_GOAL_POSITION_L, and write_table_value().
void RobotisRX28::goto_positions | ( | unsigned int | num_servos, | |
... | ||||
) |
Move several servos to specified positions.
Given the number of servos the variadic arguments must contain two values for each servo, first is the ID, second the position (see goto_position() for information on the valid values).
num_servos | number of servos, maximum is 83 |
Definition at line 1354 of file rx28.cpp.
References BROADCAST_ID, and P_GOAL_POSITION_L.
bool RobotisRX28::is_led_enabled | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
bool RobotisRX28::is_locked | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
bool RobotisRX28::is_moving | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
bool RobotisRX28::is_torque_enabled | ( | unsigned char | id, | |
bool | refresh = false | |||
) |
Check if torque is enabled.
id | servo ID, not the broadcast ID | |
refresh | if true, will issue a read command for the value |
Definition at line 874 of file rx28.cpp.
References P_TORQUE_ENABLE.
void RobotisRX28::lock_config | ( | unsigned char | id | ) |
Lock config.
Locks the config, configuration values can no longer be modified until the next power cycle.
id | servo ID |
Definition at line 1329 of file rx28.cpp.
References P_LOCK, and write_table_value().
void RobotisRX28::open | ( | ) |
Open serial port.
Definition at line 177 of file rx28.cpp.
References close().
Referenced by RobotisRX28().
bool RobotisRX28::ping | ( | unsigned char | id, | |
unsigned int | timeout_ms = 100 | |||
) |
Ping servo.
This pings the given servo by sending a PING instruction and reading the reply.
id | servo ID, not the broadcast ID | |
timeout_ms | maximum wait time in miliseconds |
Definition at line 474 of file rx28.cpp.
References fawkes::Exception::print_trace().
void RobotisRX28::read_table_value | ( | unsigned char | id, | |
unsigned char | addr, | |||
unsigned char | read_length | |||
) |
Read a table value.
This will read the given value(s) and write the output to the control table (in memory, not in the servo), such that the appropriate get method will return the new value.
id | servo ID, not the broadcast ID | |
addr | start addr, one of the P_* constants. | |
read_length | number of bytes to read |
void RobotisRX28::read_table_values | ( | unsigned char | id | ) |
Read all table values for given servo.
This issues a READ comment for the whole control table and waits for the response.
id | servo ID |
Definition at line 494 of file rx28.cpp.
References finish_read_table_values(), and start_read_table_values().
Referenced by discover().
void RobotisRX28::set_alarm_led | ( | unsigned char | id, | |
unsigned char | alarm_led | |||
) |
Set alarm LED settings.
id | servo ID | |
alarm_led | new LED alarm value. |
Definition at line 1161 of file rx28.cpp.
References P_ALARM_LED, and write_table_value().
void RobotisRX28::set_alarm_shutdown | ( | unsigned char | id, | |
unsigned char | alarm_shutdown | |||
) |
Set shutdown on alarm.
id | servo ID | |
alarm_shutdown | alarm shutdown settings |
Definition at line 1172 of file rx28.cpp.
References P_ALARM_SHUTDOWN, and write_table_value().
void RobotisRX28::set_angle_limits | ( | unsigned char | id, | |
unsigned int | cw_limit, | |||
unsigned int | ccw_limit | |||
) |
Set angle limits.
id | servo ID | |
cw_limit | new clockwise limit | |
ccw_limit | new counter-clockwise limit |
Definition at line 1099 of file rx28.cpp.
References P_CCW_ANGLE_LIMIT_L, P_CW_ANGLE_LIMIT_L, and write_table_value().
void RobotisRX28::set_baudrate | ( | unsigned char | id, | |
unsigned char | baudrate | |||
) |
Set baud rate.
id | servo ID | |
baudrate | new baudrate |
Definition at line 1076 of file rx28.cpp.
References P_BAUD_RATE, and write_table_value().
void RobotisRX28::set_compliance_values | ( | unsigned char | id, | |
unsigned char | cw_margin, | |||
unsigned char | cw_slope, | |||
unsigned char | ccw_margin, | |||
unsigned char | ccw_slope | |||
) |
Set compliance values.
id | servo ID | |
cw_margin | clockwise margin | |
cw_slope | clockwise slope | |
ccw_margin | counter-clockwise margin | |
ccw_slope | counter-clockwise slope |
Definition at line 1242 of file rx28.cpp.
References P_CW_COMPLIANCE_MARGIN, and write_table_values().
void RobotisRX28::set_goal_speed | ( | unsigned char | id, | |
unsigned int | goal_speed | |||
) |
Set goal speed.
id | servo ID | |
goal_speed | desired goal speed, 1024 is maximum, 0 means "no velicity control", i.e. move as fast as possible depending on the voltage |
Definition at line 1261 of file rx28.cpp.
References P_GOAL_SPEED_L, and write_table_value().
void RobotisRX28::set_goal_speeds | ( | unsigned int | num_servos, | |
... | ||||
) |
Set goal speeds for multiple servos.
Given the number of servos the variadic arguments must contain two values for each servo, first is the ID, second the value.
num_servos | number of servos, maximum is 83 |
Definition at line 1273 of file rx28.cpp.
References BROADCAST_ID, and P_GOAL_SPEED_L.
void RobotisRX28::set_id | ( | unsigned char | id, | |
unsigned char | new_id | |||
) |
Set ID.
id | servo ID | |
new_id | new ID to set |
Definition at line 1065 of file rx28.cpp.
References P_ID, and write_table_value().
void RobotisRX28::set_led_enabled | ( | unsigned char | id, | |
bool | led_enabled | |||
) |
Turn LED on or off.
id | servo ID | |
led_enabled | true to turn LED on, false to turn off |
Definition at line 1228 of file rx28.cpp.
References P_LED, and write_table_value().
void RobotisRX28::set_max_torque | ( | unsigned char | id, | |
unsigned int | max_torque | |||
) |
Set maximum torque.
id | servo ID | |
max_torque | new maximum torque |
Definition at line 1138 of file rx28.cpp.
References P_MAX_TORQUE_L, and write_table_value().
void RobotisRX28::set_punch | ( | unsigned char | id, | |
unsigned int | punch | |||
) |
Set punch.
id | servo ID | |
punch | new punch value |
Definition at line 1317 of file rx28.cpp.
References P_PUNCH_L, and write_table_value().
void RobotisRX28::set_return_delay_time | ( | unsigned char | id, | |
unsigned char | return_delay_time | |||
) |
Set return delay time.
id | servo ID | |
return_delay_time | new return delay time |
Definition at line 1087 of file rx28.cpp.
References P_RETURN_DELAY_TIME, and write_table_value().
void RobotisRX28::set_status_return_level | ( | unsigned char | id, | |
unsigned char | status_return_level | |||
) |
Set status return level.
id | servo ID | |
status_return_level | status return level, one of SRL_RESPOND_NONE, SRL_RESPOND_READ or SRL_RESPOND_ALL. |
Definition at line 1150 of file rx28.cpp.
References P_RETURN_LEVEL, and write_table_value().
void RobotisRX28::set_temperature_limit | ( | unsigned char | id, | |
unsigned char | temp_limit | |||
) |
Set temperature limit.
id | servo ID | |
temp_limit | new temperature limit (in degrees Celsius) |
Definition at line 1112 of file rx28.cpp.
References P_LIMIT_TEMPERATURE, and write_table_value().
void RobotisRX28::set_torque_enabled | ( | unsigned char | id, | |
bool | enabled | |||
) |
Enable or disable torque.
id | servo ID | |
enabled | true to enable (servo is powered) false to disable (servo power disabled, servo can be freely moved manually) |
Definition at line 1184 of file rx28.cpp.
References P_TORQUE_ENABLE, and write_table_value().
void RobotisRX28::set_torque_limit | ( | unsigned char | id, | |
unsigned int | torque_limit | |||
) |
Set torque limit.
id | servo ID | |
torque_limit | new torque limit |
Definition at line 1306 of file rx28.cpp.
References P_TORQUE_LIMIT_L, and write_table_value().
void RobotisRX28::set_torques_enabled | ( | bool | enabled, | |
unsigned char | num_servos, | |||
... | ||||
) |
Enable or disable torque for multiple (selected) servos at once.
Given the number of servos the same number of variadic arguments must be passed, one for each servo ID that should be enabled/disabled.
enabled | true to enable (servo is powered) false to disable (servo power disabled, servo can be freely moved manually) | |
num_servos | number of servos to set, maximum is 120 |
Definition at line 1198 of file rx28.cpp.
References BROADCAST_ID, and P_TORQUE_ENABLE.
void RobotisRX28::set_voltage_limits | ( | unsigned char | id, | |
unsigned char | low, | |||
unsigned char | high | |||
) |
Set voltage limits.
id | servo ID | |
low | lower bound (give Volts * 10) | |
high | higher bound (give Volts * 10) |
Definition at line 1124 of file rx28.cpp.
References P_DOWN_LIMIT_VOLTAGE, and write_table_values().
void RobotisRX28::start_read_table_values | ( | unsigned char | id | ) |
Start to receive table values.
This method sends a READ instruction packet for the whole table, but it does not wait for the reply. This can be used to overlap the receiving with other operations. You have to ensure to call finish_read_table_values() before sending any other data.
id | servo ID, not the broadcast ID |
Definition at line 509 of file rx28.cpp.
Referenced by read_table_values().
void RobotisRX28::write_table_value | ( | unsigned char | id, | |
unsigned char | addr, | |||
unsigned int | value, | |||
bool | double_byte = false | |||
) |
Write a table value.
id | servo ID, may be the broadcast ID | |
addr | start addr, one of the P_* constants. | |
value | value to write | |
double_byte | if true, will assume value to be a two-byte value, otherwise it is considered as a one-byte value. |
Definition at line 578 of file rx28.cpp.
References BROADCAST_ID.
Referenced by goto_position(), lock_config(), set_alarm_led(), set_alarm_shutdown(), set_angle_limits(), set_baudrate(), set_goal_speed(), set_id(), set_led_enabled(), set_max_torque(), set_punch(), set_return_delay_time(), set_status_return_level(), set_temperature_limit(), set_torque_enabled(), and set_torque_limit().
void RobotisRX28::write_table_values | ( | unsigned char | id, | |
unsigned char | start_addr, | |||
unsigned char * | values, | |||
unsigned int | num_values | |||
) |
Write multiple table values.
id | servo ID, may be the broadcast ID | |
start_addr | start addr, one of the P_* constants. | |
values | values to write | |
num_values | length in bytes of the values array |
Definition at line 614 of file rx28.cpp.
References BROADCAST_ID.
Referenced by set_compliance_values(), and set_voltage_limits().
const unsigned char RobotisRX28::BROADCAST_ID = 0xfe [static] |
BROADCAST_ID.
Definition at line 138 of file rx28.h.
Referenced by discover(), goto_positions(), PanTiltRX28Thread::init(), set_goal_speeds(), set_torques_enabled(), write_table_value(), and write_table_values().
const unsigned int RobotisRX28::CENTER_POSITION = 0x1ff [static] |
const float RobotisRX28::MAX_ANGLE_DEG = 300 [static] |
const float RobotisRX28::MAX_ANGLE_RAD = fawkes::deg2rad(RobotisRX28::MAX_ANGLE_DEG) [static] |
const unsigned int RobotisRX28::MAX_POSITION = 0x3ff [static] |
const unsigned int RobotisRX28::MAX_SPEED = 0x3ff [static] |
const unsigned char RobotisRX28::P_ALARM_LED = 17 [static] |
P_ALARM_LED.
Definition at line 167 of file rx28.h.
Referenced by get_alarm_led(), and set_alarm_led().
const unsigned char RobotisRX28::P_ALARM_SHUTDOWN = 18 [static] |
P_ALARM_SHUTDOWN.
Definition at line 168 of file rx28.h.
Referenced by get_alarm_shutdown(), and set_alarm_shutdown().
const unsigned char RobotisRX28::P_BAUD_RATE = 4 [static] |
P_BAUD_RATE.
Definition at line 154 of file rx28.h.
Referenced by get_baudrate(), and set_baudrate().
const unsigned char RobotisRX28::P_CCW_ANGLE_LIMIT_H = 9 [static] |
const unsigned char RobotisRX28::P_CCW_ANGLE_LIMIT_L = 8 [static] |
P_CCW_ANGLE_LIMIT_L.
Definition at line 158 of file rx28.h.
Referenced by get_angle_limits(), and set_angle_limits().
const unsigned char RobotisRX28::P_CCW_COMPLIANCE_MARGIN = 27 [static] |
P_CCW_COMPLIANCE_MARGIN.
Definition at line 178 of file rx28.h.
Referenced by get_compliance_values().
const unsigned char RobotisRX28::P_CCW_COMPLIANCE_SLOPE = 29 [static] |
P_CCW_COMPLIANCE_SLOPE.
Definition at line 180 of file rx28.h.
Referenced by get_compliance_values().
const unsigned char RobotisRX28::P_CW_ANGLE_LIMIT_H = 7 [static] |
const unsigned char RobotisRX28::P_CW_ANGLE_LIMIT_L = 6 [static] |
P_CW_ANGLE_LIMIT_L.
Definition at line 156 of file rx28.h.
Referenced by get_angle_limits(), and set_angle_limits().
const unsigned char RobotisRX28::P_CW_COMPLIANCE_MARGIN = 26 [static] |
P_CW_COMPLIANCE_MARGIN.
Definition at line 177 of file rx28.h.
Referenced by get_compliance_values(), and set_compliance_values().
const unsigned char RobotisRX28::P_CW_COMPLIANCE_SLOPE = 28 [static] |
P_CW_COMPLIANCE_SLOPE.
Definition at line 179 of file rx28.h.
Referenced by get_compliance_values().
const unsigned char RobotisRX28::P_DOWN_CALIBRATION_H = 21 [static] |
const unsigned char RobotisRX28::P_DOWN_CALIBRATION_L = 20 [static] |
const unsigned char RobotisRX28::P_DOWN_LIMIT_VOLTAGE = 12 [static] |
P_DOWN_LIMIT_VOLTAGE.
Definition at line 162 of file rx28.h.
Referenced by get_voltage_limits(), and set_voltage_limits().
const unsigned char RobotisRX28::P_GOAL_POSITION_H = 31 [static] |
const unsigned char RobotisRX28::P_GOAL_POSITION_L = 30 [static] |
P_GOAL_POSITION_L.
Definition at line 181 of file rx28.h.
Referenced by get_goal_position(), goto_position(), and goto_positions().
const unsigned char RobotisRX28::P_GOAL_SPEED_H = 33 [static] |
const unsigned char RobotisRX28::P_GOAL_SPEED_L = 32 [static] |
P_GOAL_SPEED_L.
Definition at line 183 of file rx28.h.
Referenced by get_goal_speed(), set_goal_speed(), and set_goal_speeds().
const unsigned char RobotisRX28::P_ID = 3 [static] |
const unsigned char RobotisRX28::P_LED = 25 [static] |
P_LED.
Definition at line 176 of file rx28.h.
Referenced by is_led_enabled(), and set_led_enabled().
const unsigned char RobotisRX28::P_LIMIT_TEMPERATURE = 11 [static] |
P_LIMIT_TEMPERATURE.
Definition at line 161 of file rx28.h.
Referenced by get_temperature_limit(), and set_temperature_limit().
const unsigned char RobotisRX28::P_LOCK = 47 [static] |
const unsigned char RobotisRX28::P_MAX_TORQUE_H = 15 [static] |
const unsigned char RobotisRX28::P_MAX_TORQUE_L = 14 [static] |
P_MAX_TORQUE_L.
Definition at line 164 of file rx28.h.
Referenced by get_max_torque(), and set_max_torque().
const unsigned char RobotisRX28::P_MODEL_NUMBER_H = 1 [static] |
const unsigned char RobotisRX28::P_MODEL_NUMBER_L = 0 [static] |
const unsigned char RobotisRX28::P_MOVING = 46 [static] |
const unsigned char RobotisRX28::P_OPERATING_MODE = 19 [static] |
const unsigned char RobotisRX28::P_PAUSE_TIME = 45 [static] |
const unsigned char RobotisRX28::P_PRESENT_LOAD_H = 41 [static] |
const unsigned char RobotisRX28::P_PRESENT_LOAD_L = 40 [static] |
const unsigned char RobotisRX28::P_PRESENT_POSITION_H = 37 [static] |
const unsigned char RobotisRX28::P_PRESENT_POSITION_L = 36 [static] |
const unsigned char RobotisRX28::P_PRESENT_SPEED_H = 39 [static] |
const unsigned char RobotisRX28::P_PRESENT_SPEED_L = 38 [static] |
const unsigned char RobotisRX28::P_PRESENT_TEMPERATURE = 43 [static] |
const unsigned char RobotisRX28::P_PRESENT_VOLTAGE = 42 [static] |
const unsigned char RobotisRX28::P_PUNCH_H = 49 [static] |
const unsigned char RobotisRX28::P_PUNCH_L = 48 [static] |
const unsigned char RobotisRX28::P_REGISTERED_INSTRUCTION = 44 [static] |
const unsigned char RobotisRX28::P_RETURN_DELAY_TIME = 5 [static] |
P_RETURN_DELAY_TIME.
Definition at line 155 of file rx28.h.
Referenced by get_delay_time(), and set_return_delay_time().
const unsigned char RobotisRX28::P_RETURN_LEVEL = 16 [static] |
P_RETURN_LEVEL.
Definition at line 166 of file rx28.h.
Referenced by get_status_return_level(), and set_status_return_level().
const unsigned char RobotisRX28::P_SYSTEM_DATA2 = 10 [static] |
const unsigned char RobotisRX28::P_TORQUE_ENABLE = 24 [static] |
P_TORQUE_ENABLE.
Definition at line 175 of file rx28.h.
Referenced by is_torque_enabled(), set_torque_enabled(), and set_torques_enabled().
const unsigned char RobotisRX28::P_TORQUE_LIMIT_H = 35 [static] |
const unsigned char RobotisRX28::P_TORQUE_LIMIT_L = 34 [static] |
P_TORQUE_LIMIT_L.
Definition at line 185 of file rx28.h.
Referenced by get_torque_limit(), and set_torque_limit().
const unsigned char RobotisRX28::P_UP_CALIBRATION_H = 23 [static] |
const unsigned char RobotisRX28::P_UP_CALIBRATION_L = 22 [static] |
const unsigned char RobotisRX28::P_UP_LIMIT_VOLTAGE = 13 [static] |
const unsigned char RobotisRX28::P_VERSION = 2 [static] |
const float RobotisRX28::POS_TICKS_PER_RAD = (float)(RobotisRX28::MAX_POSITION) / RobotisRX28::MAX_ANGLE_RAD [static] |
const float RobotisRX28::RAD_PER_POS_TICK = RobotisRX28::MAX_ANGLE_RAD / (float)(RobotisRX28::MAX_POSITION) [static] |
const float RobotisRX28::SEC_PER_60DEG_12V = 0.167 [static] |
const float RobotisRX28::SEC_PER_60DEG_16V = 0.126 [static] |
const unsigned char RobotisRX28::SRL_RESPOND_ALL = 2 [static] |
const unsigned char RobotisRX28::SRL_RESPOND_NONE = 0 [static] |
const unsigned char RobotisRX28::SRL_RESPOND_READ = 1 [static] |