26 #include <core/exceptions/system.h> 27 #include <core/exceptions/software.h> 29 #include <utils/math/angle.h> 31 #include <sys/ioctl.h> 110 const unsigned char RobotisRX28::INST_PING = 0x01;
111 const unsigned char RobotisRX28::INST_READ = 0x02;
112 const unsigned char RobotisRX28::INST_WRITE = 0x03;
113 const unsigned char RobotisRX28::INST_REG_WRITE = 0x04;
114 const unsigned char RobotisRX28::INST_ACTION = 0x05;
115 const unsigned char RobotisRX28::INST_RESET = 0x06;
116 const unsigned char RobotisRX28::INST_DIGITAL_RESET = 0x07;
117 const unsigned char RobotisRX28::INST_SYSTEM_READ = 0x0C;
118 const unsigned char RobotisRX28::INST_SYSTEM_WRITE = 0x0D;
119 const unsigned char RobotisRX28::INST_SYNC_WRITE = 0x83;
120 const unsigned char RobotisRX28::INST_SYNC_REG_WRITE = 0x84;
122 const unsigned char RobotisRX28::PACKET_OFFSET_ID = 2;
123 const unsigned char RobotisRX28::PACKET_OFFSET_LENGTH = 3;
124 const unsigned char RobotisRX28::PACKET_OFFSET_INST = 4;
125 const unsigned char RobotisRX28::PACKET_OFFSET_PARAM = 5;
126 const unsigned char RobotisRX28::PACKET_OFFSET_ERROR = 4;
154 __default_timeout_ms = default_timeout_ms;
155 __device_file = strdup(device_file);
157 __obuffer_length = 0;
158 __ibuffer_length = 0;
159 memset(__control_table, 0, RX28_MAX_NUM_SERVOS * RX28_CONTROL_TABLE_LENGTH);
179 struct termios param;
181 __fd = ::open(__device_file, O_NOCTTY | O_RDWR);
185 tcflush(__fd, TCIOFLUSH);
187 if (tcgetattr(__fd, ¶m) == -1) {
188 Exception e(errno,
"Getting the port parameters failed");
194 cfsetospeed(¶m, B57600);
195 cfsetispeed(¶m, B57600);
197 param.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN);
198 param.c_iflag &= ~(INLCR | IGNCR | ICRNL | IGNBRK | PARMRK);
201 param.c_iflag &= ~(IXON | IXOFF | IXANY);
202 param.c_cflag &= ~CRTSCTS;
204 param.c_cflag |= (CREAD | CLOCAL);
207 param.c_cflag &= ~CS5 & ~CS6 & ~CS7 & ~CS8;
208 param.c_cflag |= CS8;
211 param.c_cflag &= ~(PARENB | PARODD);
212 param.c_iflag &= ~(INPCK | ISTRIP);
215 param.c_cflag &= ~CSTOPB;
218 param.c_oflag &= ~OPOST;
220 param.c_cc[VMIN] = 1;
221 param.c_cc[VTIME] = 0;
223 tcflush(__fd, TCIOFLUSH);
225 if (tcsetattr(__fd, TCSANOW, ¶m) != 0) {
226 Exception e(errno,
"Setting the port parameters failed");
235 #ifdef TIMETRACKER_VISCA 237 track_file.open(
"tracker_visca.txt");
238 ttcls_pantilt_get_send = tracker->addClass(
"getPanTilt: send");
239 ttcls_pantilt_get_read = tracker->addClass(
"getPanTilt: read");
240 ttcls_pantilt_get_handle = tracker->addClass(
"getPanTilt: handling responses");
241 ttcls_pantilt_get_interpret = tracker->addClass(
"getPanTilt: interpreting");
267 RobotisRX28::calc_checksum(
const unsigned char id,
const unsigned char instruction,
268 const unsigned char *params,
const unsigned char plength)
270 unsigned int checksum =
id + instruction + plength+2;
271 for (
unsigned char i = 0; i < plength; ++i) {
272 checksum += params[i];
275 return ~(checksum & 0xFF);
286 RobotisRX28::send(
const unsigned char id,
const unsigned char instruction,
287 const unsigned char *params,
const unsigned char plength)
292 __obuffer[PACKET_OFFSET_ID] = id;
293 __obuffer[PACKET_OFFSET_LENGTH] = plength+2;
294 __obuffer[PACKET_OFFSET_INST] = instruction;
296 unsigned int checksum =
id + plength+2;
298 for (
unsigned char i = 0; i < plength; ++i) {
299 __obuffer[PACKET_OFFSET_PARAM + i] = params[i];
300 checksum += params[i];
304 __obuffer[3 + plength+2] = calc_checksum(
id, instruction, params, plength);
305 __obuffer_length = plength+2 + 4 ;
307 #ifdef DEBUG_RX28_COMM 309 for (
int i = 0; i < __obuffer_length; ++i) {
310 printf(
"%X ", __obuffer[i]);
315 int written = write(__fd, __obuffer, __obuffer_length);
320 while (readd < __obuffer_length) {
321 readd += read(__fd, __ibuffer + readd, __obuffer_length - readd);
323 #ifdef DEBUG_RX28_COMM 324 printf(
"Read %d junk bytes: ", readd);
325 for (
int i = 0; i < readd; ++i) {
326 printf(
"%X ", __ibuffer[i]);
332 throw Exception(errno,
"Failed to write RX28 packet %x for %x", instruction,
id);
333 }
else if (written < __obuffer_length) {
334 throw Exception(
"Failed to write RX28 packet %x for %x, only %d of %d bytes sent",
335 instruction,
id, written, __obuffer_length);
345 RobotisRX28::recv(
const unsigned char exp_length,
unsigned int timeout_ms)
347 timeval timeout = {0, (suseconds_t)(timeout_ms == 0xFFFFFFFF ? __default_timeout_ms : timeout_ms) * 1000};
351 FD_SET(__fd, &read_fds);
354 rv = select(__fd + 1, &read_fds, NULL, NULL, &timeout);
357 throw Exception(errno,
"Select on FD failed");
358 }
else if ( rv == 0 ) {
360 throw TimeoutException(
"Timeout reached while waiting for incoming RX28 data");
363 __ibuffer_length = 0;
367 while (bytes_read < 6) {
368 #ifdef DEBUG_RX28_COMM 369 printf(
"Trying to read %d bytes\n", 6 - bytes_read);
371 bytes_read += read(__fd, __ibuffer + bytes_read, 6 - bytes_read);
372 #ifdef DEBUG_RX28_COMM 373 printf(
"%d bytes read ", bytes_read);
374 for (
int i = 0; i < bytes_read; ++i) {
375 printf(
"%X ", __ibuffer[i]);
380 if (bytes_read < 6) {
381 throw Exception(
"Failed to read packet header");
383 if ( (__ibuffer[0] != 0xFF) || (__ibuffer[1] != 0xFF) ) {
384 throw Exception(
"Packet does not start with 0xFFFF.");
386 if (exp_length != __ibuffer[PACKET_OFFSET_LENGTH] - 2) {
387 tcflush(__fd, TCIFLUSH);
388 throw Exception(
"Wrong packet length, expected %u, got %u",
389 exp_length, __ibuffer[PACKET_OFFSET_LENGTH] - 2);
391 const unsigned char plength = __ibuffer[PACKET_OFFSET_LENGTH] - 2;
392 #ifdef DEBUG_RX28_COMM 393 printf(
"header read, params have length %d\n", plength);
397 while (bytes_read < plength) {
398 bytes_read += read(__fd, &__ibuffer[6] + bytes_read, plength - bytes_read);
400 if (bytes_read < plength) {
401 throw Exception(
"Failed to read packet data");
405 __ibuffer_length = plength+2 + 4;
406 #ifdef DEBUG_RX28_COMM 408 for (
int i = 0; i < __ibuffer_length; ++i) {
409 printf(
"%X ", __ibuffer[i]);
415 unsigned char checksum = calc_checksum(__ibuffer[PACKET_OFFSET_ID],
416 __ibuffer[PACKET_OFFSET_INST],
417 &__ibuffer[PACKET_OFFSET_PARAM], plength);
418 if (checksum != __ibuffer[plength + 5]) {
419 throw Exception(
"Checksum error while receiving packet, expected %d, got %d",
420 checksum, __ibuffer[plength + 5]);
423 __ibuffer_length = plength+2 + 4;
434 ioctl(__fd, FIONREAD, &num_bytes);
435 return (num_bytes > 0);
463 send(BROADCAST_ID, INST_PING, NULL, 0);
465 for (
unsigned int i = 0; i < RX28_MAX_NUM_SERVOS; ++i) {
468 rv.push_back(__ibuffer[PACKET_OFFSET_ID]);
476 for (DeviceList::iterator i = rv.begin(); i != rv.end(); ++i) {
478 read_table_values(*i);
480 e.
append(
"Failed to receive control table for servo %u", *i);
501 send(
id, INST_PING, NULL, 0);
519 start_read_table_values(
id);
520 finish_read_table_values();
535 unsigned char param[2];
537 param[1] = RX28_CONTROL_TABLE_LENGTH;
539 send(
id, INST_READ, param, 2);
551 recv(RX28_CONTROL_TABLE_LENGTH);
553 if (__ibuffer_length != 5 + RX28_CONTROL_TABLE_LENGTH + 1) {
554 throw Exception(
"Input buffer of invalid size: %u vs. %u", __ibuffer_length, 5 + RX28_CONTROL_TABLE_LENGTH + 1);
556 memcpy(__control_table[__ibuffer[PACKET_OFFSET_ID]],
557 &__ibuffer[PACKET_OFFSET_PARAM], RX28_CONTROL_TABLE_LENGTH);
571 unsigned char addr,
unsigned char read_length)
575 unsigned char param[2];
577 param[1] = read_length;
579 send(
id, INST_READ, param, 2);
582 if (__ibuffer_length != (5 + read_length + 1)) {
583 throw Exception(
"Input buffer not of expected size, expected %u, got %u",
584 (5 + read_length + 1), __ibuffer_length);
587 for (
unsigned int i = 0; i < read_length; ++i) {
588 __control_table[id][addr + i] = __ibuffer[PACKET_OFFSET_PARAM + i];
602 unsigned int value,
bool double_byte)
604 unsigned char param[3];
606 param[1] = value & 0xFF;
607 param[2] = (value >> 8) & 0xFF;
610 send(
id, INST_WRITE, param, double_byte ? 3 : 2);
612 if (
id == BROADCAST_ID) {
613 for (
unsigned int i = 0; i < RX28_MAX_NUM_SERVOS; ++i) {
614 __control_table[i][addr] = param[1];
615 if (double_byte) __control_table[i][addr + 1] = param[2];
618 __control_table[id][addr] = param[1];
619 if (double_byte) __control_table[id][addr + 1] = param[2];
622 if ((
id != BROADCAST_ID) && responds_all(
id)) recv(0);
638 unsigned char *values,
unsigned int num_values)
640 unsigned char param[num_values + 1];
641 param[0] = start_addr;
642 for (
unsigned int i = 0; i < num_values; ++i) {
643 param[i + 1] = values[i];
647 send(
id, INST_WRITE, param, num_values + 1);
649 if (
id == BROADCAST_ID) {
650 for (
unsigned int i = 0; i < RX28_MAX_NUM_SERVOS; ++i) {
651 for (
unsigned int j = 0; j < num_values; ++j) {
652 __control_table[i][start_addr + j] = values[j];
656 for (
unsigned int j = 0; j < num_values; ++j) {
657 __control_table[id][start_addr + j] = values[j];
661 if ((
id != BROADCAST_ID) && responds_all(
id)) recv(0);
675 RobotisRX28::assert_valid_id(
unsigned char id)
677 if (
id == BROADCAST_ID) {
678 throw Exception(
"Data can only be queried for a specific servo");
679 }
else if (
id >= RX28_MAX_NUM_SERVOS) {
691 RobotisRX28::merge_twobyte_value(
unsigned int id,
692 unsigned char ind_l,
unsigned char ind_h)
694 unsigned int rv = (__control_table[id][ind_h] & 0xFF) << 8;
695 rv |= __control_table[id][ind_l] & 0xFF;
709 RobotisRX28::get_value(
unsigned int id,
bool refresh,
710 unsigned int ind_l,
unsigned int ind_h)
714 if (refresh) read_table_value(
id, ind_l, (ind_h == 0xFFFFFFFF ? 1 : 2));
716 if (ind_h == 0xFFFFFFFF) {
717 return __control_table[id][ind_l];
719 return merge_twobyte_value(
id, ind_l, ind_h);
731 return get_value(
id, refresh, P_MODEL_NUMBER_L, P_MODEL_NUMBER_H);
743 return get_value(
id, refresh, P_PRESENT_POSITION_L, P_PRESENT_POSITION_H);
755 return get_value(
id, refresh, P_VERSION);
767 return get_value(
id, refresh, P_BAUD_RATE);
779 return get_value(
id, refresh, P_RETURN_DELAY_TIME);
791 unsigned int &cw_limit,
unsigned int &ccw_limit,
794 cw_limit = get_value(
id, refresh, P_CW_ANGLE_LIMIT_L, P_CW_ANGLE_LIMIT_H);
795 ccw_limit = get_value(
id, refresh, P_CCW_ANGLE_LIMIT_L, P_CCW_ANGLE_LIMIT_H);
807 return get_value(
id, refresh, P_LIMIT_TEMPERATURE);
819 unsigned char &low,
unsigned char &high,
822 low = get_value(
id, refresh, P_DOWN_LIMIT_VOLTAGE);
823 high = get_value(
id, refresh, P_UP_LIMIT_VOLTAGE);
835 return get_value(
id, refresh, P_MAX_TORQUE_L, P_MAX_TORQUE_H);
847 return get_value(
id, refresh, P_RETURN_LEVEL);
859 return get_value(
id, refresh, P_ALARM_LED);
871 return get_value(
id, refresh, P_ALARM_SHUTDOWN);
883 unsigned int &down_calib,
unsigned int &up_calib,
886 down_calib = get_value(
id, refresh, P_DOWN_CALIBRATION_L, P_DOWN_CALIBRATION_H);
887 up_calib = get_value(
id, refresh, P_UP_CALIBRATION_L, P_UP_CALIBRATION_H);
899 return (get_value(
id, refresh, P_TORQUE_ENABLE) == 1);
911 return (get_value(
id, refresh, P_LED) == 1);
925 unsigned char &cw_margin,
unsigned char &cw_slope,
926 unsigned char &ccw_margin,
unsigned char &ccw_slope,
929 cw_margin = get_value(
id, refresh, P_CW_COMPLIANCE_MARGIN);
930 cw_slope = get_value(
id, refresh, P_CW_COMPLIANCE_SLOPE);
931 ccw_margin = get_value(
id, refresh, P_CCW_COMPLIANCE_MARGIN);
932 ccw_slope = get_value(
id, refresh, P_CCW_COMPLIANCE_SLOPE);
944 return get_value(
id, refresh, P_GOAL_POSITION_L, P_GOAL_POSITION_H);
956 return get_value(
id, refresh, P_GOAL_SPEED_L, P_GOAL_SPEED_H);
968 float voltage = get_voltage(
id, refresh) / 10.0;
970 if ((voltage < 12.0) || (voltage > 16.0)) {
974 float sec_per_deg_12V = SEC_PER_60DEG_12V / 60.0;
975 float sec_per_deg_16V = SEC_PER_60DEG_16V / 60.0;
977 float range_sec_per_deg = sec_per_deg_12V - sec_per_deg_16V;
978 float pos = voltage - 12.0;
980 float sec_per_deg = sec_per_deg_16V + pos * range_sec_per_deg;
981 float deg_per_sec = 1.0 / sec_per_deg;
995 return get_value(
id, refresh, P_TORQUE_LIMIT_L, P_TORQUE_LIMIT_H);
1007 return get_value(
id, refresh, P_PRESENT_SPEED_L, P_PRESENT_SPEED_H);
1019 return get_value(
id, refresh, P_PRESENT_LOAD_L, P_PRESENT_LOAD_H);
1031 return get_value(
id, refresh, P_PRESENT_VOLTAGE);
1043 return get_value(
id, refresh, P_PRESENT_TEMPERATURE);
1055 return (get_value(
id, refresh, P_MOVING) == 1);
1067 return (get_value(
id, refresh, P_LOCK) == 1);
1079 return get_value(
id, refresh, P_PUNCH_L, P_PUNCH_H);
1090 write_table_value(
id, P_ID, new_id);
1101 write_table_value(
id, P_BAUD_RATE, baudrate);
1112 write_table_value(
id, P_RETURN_DELAY_TIME, return_delay_time);
1123 unsigned int cw_limit,
unsigned int ccw_limit)
1125 write_table_value(
id, P_CW_ANGLE_LIMIT_L, cw_limit,
true);
1126 write_table_value(
id, P_CCW_ANGLE_LIMIT_L, ccw_limit,
true);
1137 write_table_value(
id, P_LIMIT_TEMPERATURE, temp_limit);
1149 unsigned char param[2];
1152 write_table_values(
id, P_DOWN_LIMIT_VOLTAGE, param, 2);
1163 write_table_value(
id, P_MAX_TORQUE_L, max_torque,
true);
1175 write_table_value(
id, P_RETURN_LEVEL, status_return_level);
1186 write_table_value(
id, P_ALARM_LED, alarm_led);
1197 write_table_value(
id, P_ALARM_SHUTDOWN, alarm_shutdown);
1209 write_table_value(
id, P_TORQUE_ENABLE, enabled ? 1 : 0);
1223 if (num_servos > 120) {
1225 throw Exception(
"You cannot set more than 120 servos at once");
1229 va_start(arg, num_servos);
1231 unsigned int plength = 2 * num_servos + 2;
1232 unsigned char param[plength];
1233 param[0] = P_TORQUE_ENABLE;
1235 for (
unsigned int i = 0; i < num_servos; ++i) {
1236 unsigned char id = va_arg(arg,
unsigned int);
1237 param[2 + i * 2] = id;
1238 param[2 + i * 2 + 1] = enabled ? 1 : 0;
1242 send(BROADCAST_ID, INST_SYNC_WRITE, param, plength);
1253 write_table_value(
id, P_LED, led_enabled ? 1 : 0);
1266 unsigned char cw_margin,
unsigned char cw_slope,
1267 unsigned char ccw_margin,
unsigned char ccw_slope)
1269 unsigned char param[4];
1270 param[0] = cw_margin;
1271 param[1] = ccw_margin;
1272 param[2] = cw_slope;
1273 param[3] = ccw_slope;
1274 write_table_values(
id, P_CW_COMPLIANCE_MARGIN, param, 4);
1286 write_table_value(
id, P_GOAL_SPEED_L, goal_speed,
true);
1298 if (num_servos > 83) {
1300 throw Exception(
"You cannot set more than 83 speeds at once");
1304 va_start(arg, num_servos);
1306 unsigned int plength = 3 * num_servos + 2;
1307 unsigned char param[plength];
1308 param[0] = P_GOAL_SPEED_L;
1310 for (
unsigned int i = 0; i < num_servos; ++i) {
1311 unsigned char id = va_arg(arg,
unsigned int);
1312 unsigned int value = va_arg(arg,
unsigned int);
1314 param[2 + i * 3] = id;
1315 param[2 + i * 3 + 1] = (value & 0xFF);
1316 param[2 + i * 3 + 2] = (value >> 8) & 0xFF;
1320 send(BROADCAST_ID, INST_SYNC_WRITE, param, plength);
1331 write_table_value(
id, P_TORQUE_LIMIT_L, torque_limit,
true);
1342 write_table_value(
id, P_PUNCH_L, punch,
true);
1354 write_table_value(
id, P_LOCK, 1);
1366 write_table_value(
id, P_GOAL_POSITION_L, value,
true);
1379 if (num_servos > 83) {
1381 throw Exception(
"You cannot set more than 83 servos at once");
1385 va_start(arg, num_servos);
1387 unsigned int plength = 3 * num_servos + 2;
1388 unsigned char param[plength];
1389 param[0] = P_GOAL_POSITION_L;
1391 for (
unsigned int i = 0; i < num_servos; ++i) {
1392 unsigned char id = va_arg(arg,
unsigned int);
1393 unsigned int value = va_arg(arg,
unsigned int);
1394 param[2 + i * 3] = id;
1395 param[2 + i * 3 + 1] = (value & 0xFF);
1396 param[2 + i * 3 + 2] = (value >> 8) & 0xFF;
1400 send(BROADCAST_ID, INST_SYNC_WRITE, param, plength);
static const unsigned char P_PUNCH_L
P_PUNCH_L.
static const unsigned char P_CCW_COMPLIANCE_SLOPE
P_CCW_COMPLIANCE_SLOPE.
void read_table_value(unsigned char id, unsigned char addr, unsigned char read_length)
Read a table value.
std::list< unsigned char > DeviceList
List of servo IDs.
File could not be opened.
static const float MAX_ANGLE_RAD
MAX_ANGLE_RAD.
void set_torque_enabled(unsigned char id, bool enabled)
Enable or disable torque.
void start_read_table_values(unsigned char id)
Start to receive table values.
static const unsigned char P_UP_LIMIT_VOLTAGE
P_UP_LIMIT_VOLTAGE.
static const unsigned char P_VERSION
P_VERSION.
unsigned int get_goal_speed(unsigned char id, bool refresh=false)
Get goal speed.
void write_table_values(unsigned char id, unsigned char start_addr, unsigned char *values, unsigned int num_values)
Write multiple table values.
static const float SEC_PER_60DEG_12V
SEC_PER_60DEG_12V.
void set_goal_speed(unsigned char id, unsigned int goal_speed)
Set goal speed.
static const unsigned char P_PRESENT_POSITION_H
P_PRESENT_POSITION_H.
static const unsigned char P_UP_CALIBRATION_L
P_UP_CALIBRATION_L.
unsigned char get_delay_time(unsigned char id, bool refresh=false)
Get time of the delay before replies are sent.
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 char get_status_return_level(unsigned char id, bool refresh=false)
Get status return level.
static const unsigned char P_DOWN_LIMIT_VOLTAGE
P_DOWN_LIMIT_VOLTAGE.
static const unsigned char P_SYSTEM_DATA2
P_SYSTEM_DATA2.
void set_punch(unsigned char id, unsigned int punch)
Set punch.
void set_alarm_led(unsigned char id, unsigned char alarm_led)
Set alarm LED settings.
static const unsigned char P_PAUSE_TIME
P_PAUSE_TIME.
static const unsigned char P_LIMIT_TEMPERATURE
P_LIMIT_TEMPERATURE.
Fawkes library namespace.
float get_max_supported_speed(unsigned char id, bool refresh=false)
Get maximum supported speed.
void set_led_enabled(unsigned char id, bool enabled)
Turn LED on or off.
static const unsigned char P_PRESENT_TEMPERATURE
P_PRESENT_TEMPERATURE.
unsigned char get_temperature_limit(unsigned char id, bool refresh=false)
Get temperature limit.
static const unsigned char P_PRESENT_SPEED_L
P_PRESENT_SPEED_L.
unsigned int get_goal_position(unsigned char id, bool refresh=false)
Get goal position.
bool is_moving(unsigned char id, bool refresh=false)
Check if servo is moving.
static const unsigned char P_PRESENT_LOAD_L
P_PRESENT_LOAD_L.
~RobotisRX28()
Destructor.
unsigned int get_punch(unsigned char id, bool refresh=false)
Get punch.
The current system call has timed out before completion.
void finish_read_table_values()
Finish control table receive operations.
void set_id(unsigned char id, unsigned char new_id)
Set ID.
void set_torque_limit(unsigned char id, unsigned int torque_limit)
Set torque limit.
bool is_led_enabled(unsigned char id, bool refresh=false)
Check if LED is enabled.
void set_max_torque(unsigned char id, unsigned int max_torque)
Set maximum torque.
static const unsigned char P_REGISTERED_INSTRUCTION
P_REGISTERED_INSTRUCTION.
static const unsigned char SRL_RESPOND_NONE
SRL_RESPOND_NONE.
static const unsigned char P_PRESENT_SPEED_H
P_PRESENT_SPEED_H.
static const unsigned char P_MAX_TORQUE_H
P_MAX_TORQUE_H.
unsigned int get_load(unsigned char id, bool refresh=false)
Get current load.
static const unsigned char P_GOAL_SPEED_L
P_GOAL_SPEED_L.
static const unsigned char P_CCW_COMPLIANCE_MARGIN
P_CCW_COMPLIANCE_MARGIN.
void write_table_value(unsigned char id, unsigned char addr, unsigned int value, bool double_byte=false)
Write a table value.
static const unsigned char P_TORQUE_ENABLE
P_TORQUE_ENABLE.
static const unsigned char P_MOVING
P_MOVING.
unsigned char get_alarm_shutdown(unsigned char id, bool refresh=false)
Get shutdown on alarm state.
unsigned int get_model(unsigned char id, bool refresh=false)
Get model.
unsigned char get_voltage(unsigned char id, bool refresh=false)
Get current voltage.
bool is_torque_enabled(unsigned char id, bool refresh=false)
Check if torque is enabled.
void set_goal_speeds(unsigned int num_servos,...)
Set goal speeds for multiple servos.
static const float SEC_PER_60DEG_16V
SEC_PER_60DEG_16V.
void get_angle_limits(unsigned char id, unsigned int &cw_limit, unsigned int &ccw_limit, bool refresh=false)
Get angle limits.
unsigned char get_baudrate(unsigned char id, bool refresh=false)
Get baud rate.
static const unsigned char P_GOAL_SPEED_H
P_GOAL_SPEED_H.
static const unsigned char P_RETURN_DELAY_TIME
P_RETURN_DELAY_TIME.
DeviceList discover(unsigned int total_timeout_ms=50)
Discover devices on the bus.
static const unsigned char P_DOWN_CALIBRATION_H
P_DOWN_CALIBRATION_H.
Base class for exceptions in Fawkes.
static const unsigned char SRL_RESPOND_ALL
SRL_RESPOND_ALL.
static const unsigned char P_LED
P_LED.
static const float POS_TICKS_PER_RAD
POS_TICKS_PER_RAD.
static const float MAX_ANGLE_DEG
MAX_ANGLE_DEG.
static const unsigned char P_GOAL_POSITION_L
P_GOAL_POSITION_L.
unsigned int get_speed(unsigned char id, bool refresh=false)
Get current speed.
unsigned char get_temperature(unsigned char id, bool refresh=false)
Get temperature.
static const unsigned int MAX_SPEED
MAX_SPEED.
static const unsigned char P_RETURN_LEVEL
P_RETURN_LEVEL.
unsigned int get_position(unsigned char id, bool refresh=false)
Get current position.
void set_torques_enabled(bool enabled, unsigned char num_servos,...)
Enable or disable torque for multiple (selected) servos at once.
static const unsigned char P_MODEL_NUMBER_L
P_MODEL_NUMBER_L.
static const unsigned char P_CW_ANGLE_LIMIT_L
P_CW_ANGLE_LIMIT_L.
void set_baudrate(unsigned char id, unsigned char baudrate)
Set baud rate.
static const unsigned char P_CW_COMPLIANCE_SLOPE
P_CW_COMPLIANCE_SLOPE.
bool data_available()
Check data availability.
static const unsigned int MAX_POSITION
MAX_POSITION.
static const unsigned char P_GOAL_POSITION_H
P_GOAL_POSITION_H.
void open()
Open serial port.
void goto_position(unsigned char id, unsigned int value)
Move servo to specified position.
void get_voltage_limits(unsigned char id, unsigned char &low, unsigned char &high, bool refresh=false)
Get voltage limits.
void set_voltage_limits(unsigned char id, unsigned char low, unsigned char high)
Set voltage limits.
static const unsigned char P_BAUD_RATE
P_BAUD_RATE.
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.
static const unsigned char P_ALARM_LED
P_ALARM_LED.
unsigned char get_firmware_version(unsigned char id, bool refresh=false)
Get firmware version.
static const unsigned char P_CCW_ANGLE_LIMIT_L
P_CCW_ANGLE_LIMIT_L.
static const unsigned char P_MODEL_NUMBER_H
P_MODEL_NUMBER_H.
void set_temperature_limit(unsigned char id, unsigned char temp_limit)
Set temperature limit.
static const unsigned char P_PRESENT_LOAD_H
P_PRESENT_LOAD_H.
void print_trace()
Prints trace to stderr.
static const unsigned char P_PRESENT_POSITION_L
P_PRESENT_POSITION_L.
static const unsigned char P_ALARM_SHUTDOWN
P_ALARM_SHUTDOWN.
static const unsigned char P_PUNCH_H
P_PUNCH_H.
void set_status_return_level(unsigned char id, unsigned char status_return_level)
Set status return level.
static const unsigned char P_CW_COMPLIANCE_MARGIN
P_CW_COMPLIANCE_MARGIN.
RobotisRX28(const char *device_file, unsigned int default_timeout_ms=30)
Constructor.
static const unsigned int CENTER_POSITION
CENTER_POSITION.
static const unsigned char P_PRESENT_VOLTAGE
P_PRESENT_VOLTAGE.
static const unsigned char P_TORQUE_LIMIT_L
P_TORQUE_LIMIT_L.
void set_return_delay_time(unsigned char id, unsigned char return_delay_time)
Set return delay time.
bool is_locked(unsigned char id, bool refresh=false)
Check is servo is locked.
static const unsigned char P_CCW_ANGLE_LIMIT_H
P_CCW_ANGLE_LIMIT_H.
static const float RAD_PER_POS_TICK
RAD_PER_POS_TICK.
unsigned int get_torque_limit(unsigned char id, bool refresh=false)
Get torque limit.
static const unsigned char SRL_RESPOND_READ
SRL_RESPOND_READ.
static const unsigned char P_MAX_TORQUE_L
P_MAX_TORQUE_L.
static const unsigned char BROADCAST_ID
BROADCAST_ID.
static const unsigned char P_UP_CALIBRATION_H
P_UP_CALIBRATION_H.
static const unsigned char P_CW_ANGLE_LIMIT_H
P_CW_ANGLE_LIMIT_H.
void lock_config(unsigned char id)
Lock config.
void set_angle_limits(unsigned char id, unsigned int cw_limit, unsigned int ccw_limit)
Set angle limits.
float deg2rad(float deg)
Convert an angle given in degrees to radians.
static const unsigned char P_TORQUE_LIMIT_H
P_TORQUE_LIMIT_H.
void set_alarm_shutdown(unsigned char id, unsigned char alarm_shutdown)
Set shutdown on alarm.
unsigned int get_max_torque(unsigned char id, bool refresh=false)
Get maximum torque.
static const unsigned char P_ID
P_ID.
void goto_positions(unsigned int num_positions,...)
Move several servos to specified positions.
static const unsigned char P_OPERATING_MODE
P_OPERATING_MODE.
static const unsigned char P_LOCK
P_LOCK.
void append(const char *format,...)
Append messages to the message list.
unsigned char get_alarm_led(unsigned char id, bool refresh=false)
Get alarm LED status.
static const unsigned char P_DOWN_CALIBRATION_L
P_DOWN_CALIBRATION_L.
void read_table_values(unsigned char id)
Read all table values for given servo.
void get_calibration(unsigned char id, unsigned int &down_calib, unsigned int &up_calib, bool refresh=false)
Get calibration data.
bool ping(unsigned char id, unsigned int timeout_ms=100)
Ping servo.