Definition at line 15 of file RFlex.H.
Public Member Functions | |
RFlex (const std::string &filename, const std::string &robotType) | |
~RFlex () | |
bool | systemUpdate () |
bool | systemLCDDump () |
bool | motionSetDefaults () |
bool | setBrake () |
bool | releaseBrake () |
void | motorSetTranslateVelocity (const double velocity) |
void | motorSetRotateVelocity (const double velocity) |
void | motorSetVelocity (const double translate, const double rotate) |
bool | odometryOn (const int period=100) |
bool | odometryOff () |
bool | digitalIOOn (const int period=100) |
bool | digitalIOOff () |
bool | joystickReport () |
bool | sonarOn () |
bool | sonarOff () |
int | getNumSonars () |
double | getSonar (int i) |
float | batteryVoltage () |
bool | brakeOn () |
bool | brakeOff () |
double | x () |
double | y () |
double | heading () |
double | translateVelocity () |
double | translateAcceleration () |
double | translateTorque () |
double | rotateVelocity () |
double | rotateAcceleration () |
double | rotateTorque () |
void | zero () |
Private Member Functions | |
bool | motorSendTranslateVelocity (const double velocity) |
bool | motorSendRotateVelocity (const double velocity) |
bool | sendCommand (const unsigned char port, const unsigned char id, const unsigned char opcode, const int length) |
bool | writePacket (const int size) const |
void | readPacket () |
int | readData () |
void | parseSystemReport () |
void | parseMotorReport () |
void | parseJoystickReport () |
void | parseSonarReport () |
void | parseDigitalIOReport () |
void | parseIRReport () |
unsigned char | convertChar (const int offset) const |
unsigned short | convertShort (const int offset) const |
unsigned long | convertLong (const int offset) const |
void | insertChar (const unsigned char value, const int offset) |
void | insertLong (const long value, const int offset) |
template<typename T> | |
T | lockedValue (T &value, pthread_mutex_t &mutex) |
RFlex (const RFlex &rflex) | |
RFlex & | operator= (const RFlex &rflex) |
Static Private Member Functions | |
static unsigned char | computeCRC (const unsigned char *buffer, const int n) |
static void * | rFlexReadThread (void *ptr) |
static void * | rFlexPeriodicThread (void *ptr) |
Private Attributes | |
SerialPort | m_port |
unsigned char | m_type |
The type of RFlex based robot to access. | |
double | m_magicDistance |
double | m_magicAngle |
double | m_magicTorque |
double | m_sonars [MAX_SONAR] |
int | m_numSonar |
bool | m_found |
int | m_offset |
unsigned char | m_read_buffer [s_buffer_size] |
unsigned char | m_write_buffer [s_buffer_size] |
pthread_mutex_t | m_write_mutex |
pthread_mutex_t | m_motor_mutex |
pthread_mutex_t | m_command_mutex |
pthread_t | m_read_thread |
pthread_t | m_periodic_thread |
double | m_translate_command |
double | m_rotate_command |
float | m_battery_voltage |
bool | m_brake |
double | m_x |
double | m_y |
Angle | m_theta |
double | m_trans_velocity |
double | m_trans_acceleration |
double | m_trans_torque |
double | m_rot_velocity |
double | m_rot_acceleration |
double | m_rot_torque |
long | m_last_distance |
long | m_last_angdistance |
bool | m_last_distance_set |
bool | m_last_angdistance_set |
Static Private Attributes | |
static const int | s_buffer_size = 1024 |
RFlex | ( | const std::string & | filename, | |
const std::string & | robotType | |||
) |
Definition at line 112 of file RFlex.cpp.
References ATRVJR_MAGIC_ANGLE, ATRVJR_MAGIC_DISTANCE, ATRVJR_MAGIC_TORQUE, B21_MAGIC_ANGLE, B21_MAGIC_DISTANCE, B21_MAGIC_TORQUE, m_command_mutex, m_last_angdistance, m_last_angdistance_set, m_last_distance, m_last_distance_set, m_magicAngle, m_magicDistance, m_magicTorque, m_motor_mutex, m_numSonar, m_periodic_thread, m_read_thread, m_rot_velocity, m_sonars, m_theta, m_trans_velocity, m_type, m_write_mutex, m_x, m_y, MAX_SONAR, odometryOn(), RFLEX_ATRVJR, RFLEX_B21R, rFlexPeriodicThread(), rFlexReadThread(), and systemUpdate().
~RFlex | ( | ) |
Definition at line 158 of file RFlex.cpp.
References digitalIOOff(), m_motor_mutex, m_write_mutex, motorSetRotateVelocity(), motorSetTranslateVelocity(), odometryOff(), and sonarOff().
bool systemUpdate | ( | ) |
Definition at line 174 of file RFlex.cpp.
References m_write_mutex, sendCommand(), SYSTEM_PORT, and SYSTEM_STATUS.
Referenced by main(), RFlex(), and rFlexPeriodicThread().
bool systemLCDDump | ( | ) |
Definition at line 184 of file RFlex.cpp.
References m_write_mutex, sendCommand(), SYSTEM_LCD_DUMP, and SYSTEM_PORT.
bool motionSetDefaults | ( | ) |
bool setBrake | ( | ) |
Definition at line 203 of file RFlex.cpp.
References m_write_mutex, MOTOR_BRAKE_SET, MOTOR_PORT, and sendCommand().
Referenced by main().
bool releaseBrake | ( | ) |
Definition at line 213 of file RFlex.cpp.
References m_write_mutex, MOTOR_BRAKE_RELEASE, MOTOR_PORT, and sendCommand().
void motorSetTranslateVelocity | ( | const double | velocity | ) |
void motorSetRotateVelocity | ( | const double | velocity | ) |
void motorSetVelocity | ( | const double | translate, | |
const double | rotate | |||
) |
Definition at line 236 of file RFlex.cpp.
References m_command_mutex, m_rotate_command, and m_translate_command.
Referenced by main().
bool odometryOn | ( | const int | period = 100 |
) |
Definition at line 244 of file RFlex.cpp.
References insertLong(), m_write_mutex, MOTOR_PORT, MOTOR_SYSTEM_REPORT_REQUEST, and sendCommand().
bool odometryOff | ( | ) |
Definition at line 256 of file RFlex.cpp.
References insertLong(), m_write_mutex, MOTOR_PORT, MOTOR_SYSTEM_REPORT_REQUEST, and sendCommand().
Referenced by ~RFlex().
bool digitalIOOn | ( | const int | period = 100 |
) |
Definition at line 268 of file RFlex.cpp.
References DIGITAL_IO_PORT, DIGITAL_IO_REPORT_REQUEST, insertLong(), m_write_mutex, and sendCommand().
bool digitalIOOff | ( | ) |
Definition at line 279 of file RFlex.cpp.
References DIGITAL_IO_PORT, DIGITAL_IO_REPORT_REQUEST, insertLong(), m_write_mutex, and sendCommand().
Referenced by ~RFlex().
bool joystickReport | ( | ) |
Definition at line 290 of file RFlex.cpp.
References JOYSTICK_GET_STATE, JOYSTICK_PORT, m_write_mutex, and sendCommand().
bool sonarOn | ( | ) |
Definition at line 299 of file RFlex.cpp.
References insertChar(), insertLong(), m_write_mutex, sendCommand(), SONAR_CONTINUOUS_REPORT, SONAR_PORT, and SONAR_RUN.
Referenced by main().
bool sonarOff | ( | ) |
Definition at line 313 of file RFlex.cpp.
References m_write_buffer, m_write_mutex, PACKET_DATA_START_BYTE, sendCommand(), SONAR_PORT, and SONAR_RUN.
int getNumSonars | ( | ) | [inline] |
double getSonar | ( | int | i | ) | [inline] |
float batteryVoltage | ( | ) | [inline] |
bool brakeOn | ( | ) | [inline] |
bool brakeOff | ( | ) | [inline] |
double x | ( | ) | [inline] |
Definition at line 61 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_x.
Referenced by main(), and parseJoystickReport().
double y | ( | ) | [inline] |
Definition at line 62 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_y.
Referenced by main(), and parseJoystickReport().
double heading | ( | ) | [inline] |
Definition at line 63 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_theta.
Referenced by main().
double translateVelocity | ( | ) | [inline] |
Definition at line 66 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_trans_velocity.
Referenced by main().
double translateAcceleration | ( | ) | [inline] |
Definition at line 67 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_trans_acceleration.
Referenced by main().
double translateTorque | ( | ) | [inline] |
Definition at line 68 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_trans_torque.
Referenced by main().
double rotateVelocity | ( | ) | [inline] |
Definition at line 70 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_rot_velocity.
Referenced by main().
double rotateAcceleration | ( | ) | [inline] |
Definition at line 71 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_rot_acceleration.
Referenced by main().
double rotateTorque | ( | ) | [inline] |
Definition at line 72 of file RFlex.H.
References lockedValue(), m_motor_mutex, and m_rot_torque.
Referenced by main().
void zero | ( | ) | [inline] |
Definition at line 74 of file RFlex.H.
References m_last_angdistance_set, m_last_distance_set, m_theta, m_x, and m_y.
bool motorSendTranslateVelocity | ( | const double | velocity | ) | [private] |
Definition at line 325 of file RFlex.cpp.
References insertChar(), insertLong(), m_magicDistance, m_magicTorque, m_write_mutex, MOTOR_AXIS_SET_DIR, MOTOR_PORT, and sendCommand().
Referenced by rFlexPeriodicThread().
bool motorSendRotateVelocity | ( | const double | velocity | ) | [private] |
Definition at line 344 of file RFlex.cpp.
References insertChar(), insertLong(), m_magicAngle, m_magicDistance, m_magicTorque, m_write_mutex, MOTOR_AXIS_SET_DIR, MOTOR_PORT, and sendCommand().
Referenced by rFlexPeriodicThread().
bool sendCommand | ( | const unsigned char | port, | |
const unsigned char | id, | |||
const unsigned char | opcode, | |||
const int | length | |||
) | [private] |
Definition at line 363 of file RFlex.cpp.
References computeCRC(), ESC, ETX, m_write_buffer, PACKET_CRC_OFFSET, PACKET_CRC_START, PACKET_DATA_START_BYTE, PACKET_ID_BYTE, PACKET_OPCODE_BYTE, PACKET_PORT_BYTE, PACKET_SIZE_BYTE, PROTOCOL_SIZE, s_buffer_size, STX, and writePacket().
Referenced by digitalIOOff(), digitalIOOn(), joystickReport(), motorSendRotateVelocity(), motorSendTranslateVelocity(), odometryOff(), odometryOn(), releaseBrake(), setBrake(), sonarOff(), sonarOn(), systemLCDDump(), and systemUpdate().
bool writePacket | ( | const int | size | ) | const [private] |
Definition at line 384 of file RFlex.cpp.
References SerialPort::fail(), m_port, and m_write_buffer.
Referenced by sendCommand().
void readPacket | ( | ) | [private] |
Definition at line 405 of file RFlex.cpp.
References computeCRC(), DIGITAL_IO_PORT, ETX, IR_PORT, JOYSTICK_PORT, m_port, m_read_buffer, MOTOR_PORT, PACKET_CRC_OFFSET, PACKET_CRC_START, PACKET_DATA_START_BYTE, PACKET_PORT_BYTE, PACKET_SIZE_BYTE, parseDigitalIOReport(), parseIRReport(), parseJoystickReport(), parseMotorReport(), parseSonarReport(), parseSystemReport(), PROTOCOL_SIZE, readData(), s_buffer_size, SONAR_PORT, and SYSTEM_PORT.
Referenced by rFlexReadThread().
int readData | ( | ) | [private] |
void parseSystemReport | ( | ) | [private] |
Definition at line 535 of file RFlex.cpp.
References convertChar(), convertLong(), m_battery_voltage, m_read_buffer, PACKET_OPCODE_BYTE, PACKET_PORT_BYTE, SYSTEM_LCD_DUMP, SYSTEM_PORT, SYSTEM_STATUS, and timestamp.
Referenced by readPacket().
void parseMotorReport | ( | ) | [private] |
Definition at line 573 of file RFlex.cpp.
References convertLong(), m_last_angdistance, m_last_angdistance_set, m_last_distance, m_last_distance_set, m_magicAngle, m_magicDistance, m_motor_mutex, m_read_buffer, m_rot_acceleration, m_rot_torque, m_rot_velocity, m_theta, m_trans_acceleration, m_trans_torque, m_trans_velocity, m_x, m_y, MOTOR_AXIS_SET_DIR, MOTOR_PORT, MOTOR_SYSTEM_REPORT, PACKET_OPCODE_BYTE, PACKET_PORT_BYTE, and timestamp.
Referenced by readPacket().
void parseJoystickReport | ( | ) | [private] |
Definition at line 644 of file RFlex.cpp.
References convertChar(), convertLong(), JOYSTICK_GET_STATE, JOYSTICK_PORT, m_read_buffer, PACKET_OPCODE_BYTE, PACKET_PORT_BYTE, timestamp, x(), and y().
Referenced by readPacket().
void parseSonarReport | ( | ) | [private] |
Definition at line 672 of file RFlex.cpp.
References convertChar(), convertLong(), convertShort(), m_read_buffer, m_sonars, m_type, PACKET_OPCODE_BYTE, PACKET_PORT_BYTE, RFLEX_ATRVJR, SONAR_PORT, SONAR_REPORT, and timestamp.
Referenced by readPacket().
void parseDigitalIOReport | ( | ) | [private] |
Definition at line 762 of file RFlex.cpp.
References DIGITAL_IO_PORT, m_read_buffer, and PACKET_PORT_BYTE.
Referenced by readPacket().
void parseIRReport | ( | ) | [private] |
Definition at line 769 of file RFlex.cpp.
References IR_PORT, m_read_buffer, and PACKET_PORT_BYTE.
Referenced by readPacket().
unsigned char convertChar | ( | const int | offset | ) | const [private] |
Definition at line 775 of file RFlex.cpp.
References m_read_buffer.
Referenced by parseJoystickReport(), parseSonarReport(), and parseSystemReport().
unsigned short convertShort | ( | const int | offset | ) | const [private] |
Definition at line 784 of file RFlex.cpp.
References m_read_buffer.
Referenced by parseSonarReport().
unsigned long convertLong | ( | const int | offset | ) | const [private] |
Definition at line 793 of file RFlex.cpp.
References m_read_buffer.
Referenced by parseJoystickReport(), parseMotorReport(), parseSonarReport(), and parseSystemReport().
void insertChar | ( | const unsigned char | value, | |
const int | offset | |||
) | [private] |
Definition at line 802 of file RFlex.cpp.
References m_write_buffer, and PACKET_DATA_START_BYTE.
Referenced by motorSendRotateVelocity(), motorSendTranslateVelocity(), and sonarOn().
void insertLong | ( | const long | value, | |
const int | offset | |||
) | [private] |
Definition at line 810 of file RFlex.cpp.
References m_write_buffer, and PACKET_DATA_START_BYTE.
Referenced by digitalIOOff(), digitalIOOn(), motorSendRotateVelocity(), motorSendTranslateVelocity(), odometryOff(), odometryOn(), and sonarOn().
unsigned char computeCRC | ( | const unsigned char * | buffer, | |
const int | n | |||
) | [static, private] |
void * rFlexReadThread | ( | void * | ptr | ) | [static, private] |
Definition at line 831 of file RFlex.cpp.
References m_port, and readPacket().
Referenced by RFlex().
void * rFlexPeriodicThread | ( | void * | ptr | ) | [static, private] |
Definition at line 850 of file RFlex.cpp.
References m_command_mutex, m_rotate_command, m_translate_command, motorSendRotateVelocity(), motorSendTranslateVelocity(), and systemUpdate().
Referenced by RFlex().
T lockedValue | ( | T & | value, | |
pthread_mutex_t & | mutex | |||
) | [inline, private] |
Definition at line 161 of file RFlex.H.
Referenced by heading(), rotateAcceleration(), rotateTorque(), rotateVelocity(), translateAcceleration(), translateTorque(), translateVelocity(), x(), and y().
SerialPort m_port [private] |
Definition at line 77 of file RFlex.H.
Referenced by readData(), readPacket(), rFlexReadThread(), and writePacket().
unsigned char m_type [private] |
The type of RFlex based robot to access.
Valid values at init are B21r, ATRVJr . Case sensitive.
Definition at line 82 of file RFlex.H.
Referenced by parseSonarReport(), and RFlex().
double m_magicDistance [private] |
Definition at line 85 of file RFlex.H.
Referenced by motorSendRotateVelocity(), motorSendTranslateVelocity(), parseMotorReport(), and RFlex().
double m_magicAngle [private] |
Definition at line 86 of file RFlex.H.
Referenced by motorSendRotateVelocity(), parseMotorReport(), and RFlex().
double m_magicTorque [private] |
Definition at line 87 of file RFlex.H.
Referenced by motorSendRotateVelocity(), motorSendTranslateVelocity(), and RFlex().
double m_sonars[MAX_SONAR] [private] |
int m_numSonar [private] |
const int s_buffer_size = 1024 [static, private] |
bool m_found [private] |
int m_offset [private] |
unsigned char m_read_buffer[s_buffer_size] [private] |
Definition at line 96 of file RFlex.H.
Referenced by convertChar(), convertLong(), convertShort(), parseDigitalIOReport(), parseIRReport(), parseJoystickReport(), parseMotorReport(), parseSonarReport(), parseSystemReport(), readData(), and readPacket().
unsigned char m_write_buffer[s_buffer_size] [private] |
Definition at line 97 of file RFlex.H.
Referenced by insertChar(), insertLong(), sendCommand(), sonarOff(), and writePacket().
pthread_mutex_t m_write_mutex [private] |
Definition at line 100 of file RFlex.H.
Referenced by digitalIOOff(), digitalIOOn(), joystickReport(), motionSetDefaults(), motorSendRotateVelocity(), motorSendTranslateVelocity(), odometryOff(), odometryOn(), releaseBrake(), RFlex(), setBrake(), sonarOff(), sonarOn(), systemLCDDump(), systemUpdate(), and ~RFlex().
pthread_mutex_t m_motor_mutex [private] |
Definition at line 101 of file RFlex.H.
Referenced by heading(), parseMotorReport(), RFlex(), rotateAcceleration(), rotateTorque(), rotateVelocity(), translateAcceleration(), translateTorque(), translateVelocity(), x(), y(), and ~RFlex().
pthread_mutex_t m_command_mutex [private] |
Definition at line 102 of file RFlex.H.
Referenced by motorSetRotateVelocity(), motorSetTranslateVelocity(), motorSetVelocity(), RFlex(), and rFlexPeriodicThread().
pthread_t m_read_thread [private] |
pthread_t m_periodic_thread [private] |
double m_translate_command [private] |
Definition at line 109 of file RFlex.H.
Referenced by motorSetTranslateVelocity(), motorSetVelocity(), and rFlexPeriodicThread().
double m_rotate_command [private] |
Definition at line 110 of file RFlex.H.
Referenced by motorSetRotateVelocity(), motorSetVelocity(), and rFlexPeriodicThread().
float m_battery_voltage [private] |
double m_x [private] |
double m_y [private] |
double m_trans_velocity [private] |
Definition at line 121 of file RFlex.H.
Referenced by parseMotorReport(), RFlex(), and translateVelocity().
double m_trans_acceleration [private] |
Definition at line 122 of file RFlex.H.
Referenced by parseMotorReport(), and translateAcceleration().
double m_trans_torque [private] |
double m_rot_velocity [private] |
Definition at line 125 of file RFlex.H.
Referenced by parseMotorReport(), RFlex(), and rotateVelocity().
double m_rot_acceleration [private] |
double m_rot_torque [private] |
long m_last_distance [private] |
long m_last_angdistance [private] |
bool m_last_distance_set [private] |
bool m_last_angdistance_set [private] |