#include <mrp2_serial.h>
Public Types | |
enum | serial_t { setSPEEDS = 1, setSPEED_L = 2, setSPEED_R = 3, setPARAM_KP_L = 4, setPARAM_KP_R = 5, setPARAM_KI_L = 6, setPARAM_KI_R = 7, setPARAM_KD_L = 8, setPARAM_KD_R = 9, setPARAM_IMAX_L = 10, setPARAM_IMAX_R = 11, setMAXSPEED_FWD = 12, setMAXSPEED_REV = 13, setMAXACCEL = 14, setBATT_CELL_V = 15, setBATT_PARALLEL_COUNT = 16, setBATT_SERIES_COUNT = 17, setBATT_CELL_NOMINAL_V = 18, setESTOP = 19, clearDIAG = 20, getSPEEDS = 21, getSPEED_L = 22, getSPEED_R = 23, getPARAM_KP_L = 24, getPARAM_KP_R = 25, getPARAM_KI_L = 26, getPARAM_KI_R = 27, getPARAM_KD_L = 28, getPARAM_KD_R = 29, getPARAM_IMAX_L = 30, getPARAM_IMAX_R = 31, getMAXSPEED_FWD = 32, getMAXSPEED_REV = 33, getMAXACCEL = 34, getBATT_CELL_V = 35, getBATT_PARALLEL_COUNT = 37, getBATT_SERIES_COUNT = 38, getBATT_CELL_NOMINAL_V = 39, getBATT_VOLT = 40, getBATT_CURRENT = 41, getBATT_SOC = 42, getPOSITIONS = 43, getPOSITION_L = 44, getPOSITION_R = 45, getBUMPERS = 46, resetPOSITIONS = 47, resetPOSITION_L = 48, resetPOSITION_R = 49, getESTOP = 50, getDIAG = 51, ACK = 52, getBATT_CELL_CAPACITY = 53, setBUMPER_ESTOP = 54, getBUMPER_ESTOP = 55, getESTOP_BTN = 56, getSONARS = 83 } |
Public Member Functions | |
void | clear_diag (int diag) |
int | get_batt_cell_capacity (bool update=false) |
int | get_batt_current (bool update=false) |
int | get_batt_soc (bool update=false) |
int | get_batt_volt (bool update=false) |
bool | get_bumper_estop (bool update=false) |
std::vector< int > | get_bumpers (bool update=false) |
bool | get_diag (int diag) |
bool | get_estop (bool update=false) |
bool | get_estop_button (bool update=false) |
int | get_maxaccel (bool update=false) |
int | get_maxspeed_fwd (bool update=false) |
int | get_maxspeed_rev (bool update=false) |
std::vector< int > | get_param_imax (char side, bool update=false) |
float | get_param_pid (char side, char param, bool update=false) |
int | get_position_l (bool update=false) |
int | get_position_r (bool update=false) |
std::vector< int > | get_positions (bool update=false) |
double | get_read_timeout (void) |
std::vector< int > | get_sonars (bool update=false) |
int | get_speed_l (bool update=false) |
int | get_speed_r (bool update=false) |
std::vector< int > | get_speeds (bool update=false) |
bool | is_available () |
MRP2_Serial (std::string port_name, uint32_t baudrate=38400, std::string mode="8N1", bool simple=true) | |
MRP2_Serial (uint16_t vendor_id, uint16_t product_id, int ep_in_addr, int ep_out_addr, bool simple=true) | |
void | reset_position_l () |
void | reset_position_r () |
void | reset_positions () |
void | set_bumper_estop (bool value) |
void | set_estop (bool value) |
void | set_max_accel (uint32_t value) |
void | set_maxspeed_fwd (uint32_t value) |
void | set_maxspeed_rev (uint32_t value) |
void | set_param_imax (char side, uint32_t value) |
void | set_param_pid (char side, char param, float value) |
void | set_read_timeout (double timeout) |
void | set_speed_l (int32_t left_speed) |
void | set_speed_r (int32_t right_speed) |
void | set_speeds (int32_t left_speed, int32_t right_speed) |
void | update () |
void | update_diag () |
virtual | ~MRP2_Serial () |
Private Member Functions | |
bool | _get_ack (serial_t command) |
void | array_chopper (uint8_t *buf, int start, int end) |
unsigned char | checksum (int size) |
unsigned char | checksum_check_array (uint8_t *arr, int size) |
bool | checksum_match (uint8_t *buf, int size) |
int | execute_command (uint8_t *buf) |
int | find_message_start (uint8_t *buf, int lastIndex) |
int | first_validator (uint8_t *buf) |
void | print_array (uint8_t *buf, int length) |
int | process (uint8_t *inData, int recievedData, uint8_t _command_to_read) |
int | process_simple (uint8_t *inData, int recievedData, uint8_t _command_to_read) |
int | read_serial (uint8_t _command_to_read) |
int | second_validator (uint8_t *buf, int data_len) |
int | send_and_get_reply (uint8_t _command, uint8_t *send_array, int send_size, bool is_ack) |
Private Attributes | |
uint8_t | _ack_data |
int | _batt_cell_capacity |
int | _batt_current |
int | _batt_soc |
int | _batt_volt |
int | _baudrate |
int | _bumper_estop |
std::vector< int > | _bumpers |
bool | _diag_aux_lights_err |
bool | _diag_batt_high |
bool | _diag_batt_low |
bool | _diag_motor_drvr_err |
bool | _diag_motor_stall_l |
bool | _diag_motor_stall_r |
bool | _estop |
int | _estop_btn |
std::vector< int > | _imax |
int | _imax_l |
int | _imax_r |
double | _Kd_l |
double | _Kd_r |
double | _Ki_l |
double | _Ki_r |
double | _Kp_l |
double | _Kp_r |
int | _maxaccel |
int | _maxspeed_fwd |
int | _maxspeed_rev |
std::string | _mode |
std::string | _port_name |
int | _port_nr |
int | _position_l |
int | _position_r |
std::vector< int > | _positions |
std::vector< int > | _sonars |
int | _speed_l |
int | _speed_r |
std::vector< int > | _speeds |
bool | dir_left |
bool | dir_right |
bool | e_stop |
int | ep_in_addr_ |
int | ep_out_addr_ |
double | Kd |
double | Ki |
double | Kol |
double | Kp |
bool | line_ok_ |
uint16_t | product_id_ |
double | read_timeout_ |
bool | seekForChar |
char | sendArray [20] |
milvus::SerialComm | serial_port |
bool | simple_ |
int | speeds [2] |
char | startChar |
uint8_t | tempData [10000] |
uint8_t | tempDataIndex |
milvus::UsbComm | usb_port |
bool | use_usb_ |
uint16_t | vendor_id_ |
Definition at line 25 of file mrp2_serial.h.
Definition at line 75 of file mrp2_serial.h.
MRP2_Serial::MRP2_Serial | ( | std::string | port_name, |
uint32_t | baudrate = 38400 , |
||
std::string | mode = "8N1" , |
||
bool | simple = true |
||
) |
Definition at line 6 of file mrp2_serial.cpp.
MRP2_Serial::MRP2_Serial | ( | uint16_t | vendor_id, |
uint16_t | product_id, | ||
int | ep_in_addr, | ||
int | ep_out_addr, | ||
bool | simple = true |
||
) |
Definition at line 23 of file mrp2_serial.cpp.
MRP2_Serial::~MRP2_Serial | ( | ) | [virtual] |
Definition at line 40 of file mrp2_serial.cpp.
bool MRP2_Serial::_get_ack | ( | serial_t | command | ) | [private] |
void MRP2_Serial::array_chopper | ( | uint8_t * | buf, |
int | start, | ||
int | end | ||
) | [private] |
Definition at line 890 of file mrp2_serial.cpp.
unsigned char MRP2_Serial::checksum | ( | int | size | ) | [private] |
Definition at line 900 of file mrp2_serial.cpp.
unsigned char MRP2_Serial::checksum_check_array | ( | uint8_t * | arr, |
int | size | ||
) | [private] |
Definition at line 915 of file mrp2_serial.cpp.
bool MRP2_Serial::checksum_match | ( | uint8_t * | buf, |
int | size | ||
) | [private] |
Definition at line 933 of file mrp2_serial.cpp.
void MRP2_Serial::clear_diag | ( | int | diag | ) |
Definition at line 301 of file mrp2_serial.cpp.
int MRP2_Serial::execute_command | ( | uint8_t * | buf | ) | [private] |
Definition at line 993 of file mrp2_serial.cpp.
int MRP2_Serial::find_message_start | ( | uint8_t * | buf, |
int | lastIndex | ||
) | [private] |
Definition at line 975 of file mrp2_serial.cpp.
int MRP2_Serial::first_validator | ( | uint8_t * | buf | ) | [private] |
Definition at line 956 of file mrp2_serial.cpp.
int MRP2_Serial::get_batt_cell_capacity | ( | bool | update = false | ) |
Definition at line 630 of file mrp2_serial.cpp.
int MRP2_Serial::get_batt_current | ( | bool | update = false | ) |
Definition at line 473 of file mrp2_serial.cpp.
int MRP2_Serial::get_batt_soc | ( | bool | update = false | ) |
Definition at line 485 of file mrp2_serial.cpp.
int MRP2_Serial::get_batt_volt | ( | bool | update = false | ) |
Definition at line 461 of file mrp2_serial.cpp.
bool MRP2_Serial::get_bumper_estop | ( | bool | update = false | ) |
Definition at line 657 of file mrp2_serial.cpp.
std::vector< int > MRP2_Serial::get_bumpers | ( | bool | update = false | ) |
Definition at line 533 of file mrp2_serial.cpp.
bool MRP2_Serial::get_diag | ( | int | diag | ) |
Definition at line 605 of file mrp2_serial.cpp.
bool MRP2_Serial::get_estop | ( | bool | update = false | ) |
Definition at line 584 of file mrp2_serial.cpp.
bool MRP2_Serial::get_estop_button | ( | bool | update = false | ) |
Definition at line 669 of file mrp2_serial.cpp.
int MRP2_Serial::get_maxaccel | ( | bool | update = false | ) |
Definition at line 449 of file mrp2_serial.cpp.
int MRP2_Serial::get_maxspeed_fwd | ( | bool | update = false | ) |
Definition at line 425 of file mrp2_serial.cpp.
int MRP2_Serial::get_maxspeed_rev | ( | bool | update = false | ) |
Definition at line 437 of file mrp2_serial.cpp.
std::vector< int > MRP2_Serial::get_param_imax | ( | char | side, |
bool | update = false |
||
) |
Definition at line 404 of file mrp2_serial.cpp.
float MRP2_Serial::get_param_pid | ( | char | side, |
char | param, | ||
bool | update = false |
||
) |
Definition at line 351 of file mrp2_serial.cpp.
int MRP2_Serial::get_position_l | ( | bool | update = false | ) |
Definition at line 509 of file mrp2_serial.cpp.
int MRP2_Serial::get_position_r | ( | bool | update = false | ) |
Definition at line 521 of file mrp2_serial.cpp.
std::vector< int > MRP2_Serial::get_positions | ( | bool | update = false | ) |
Definition at line 497 of file mrp2_serial.cpp.
double MRP2_Serial::get_read_timeout | ( | void | ) |
Definition at line 1255 of file mrp2_serial.cpp.
std::vector< int > MRP2_Serial::get_sonars | ( | bool | update = false | ) |
Definition at line 681 of file mrp2_serial.cpp.
int MRP2_Serial::get_speed_l | ( | bool | update = false | ) |
Definition at line 327 of file mrp2_serial.cpp.
int MRP2_Serial::get_speed_r | ( | bool | update = false | ) |
Definition at line 339 of file mrp2_serial.cpp.
std::vector< int > MRP2_Serial::get_speeds | ( | bool | update = false | ) |
Definition at line 315 of file mrp2_serial.cpp.
bool MRP2_Serial::is_available | ( | ) |
Definition at line 772 of file mrp2_serial.cpp.
void MRP2_Serial::print_array | ( | uint8_t * | buf, |
int | length | ||
) | [private] |
Definition at line 1238 of file mrp2_serial.cpp.
int MRP2_Serial::process | ( | uint8_t * | inData, |
int | recievedData, | ||
uint8_t | _command_to_read | ||
) | [private] |
Definition at line 817 of file mrp2_serial.cpp.
int MRP2_Serial::process_simple | ( | uint8_t * | inData, |
int | recievedData, | ||
uint8_t | _command_to_read | ||
) | [private] |
Definition at line 801 of file mrp2_serial.cpp.
int MRP2_Serial::read_serial | ( | uint8_t | _command_to_read | ) | [private] |
Definition at line 778 of file mrp2_serial.cpp.
void MRP2_Serial::reset_position_l | ( | ) |
Definition at line 558 of file mrp2_serial.cpp.
void MRP2_Serial::reset_position_r | ( | ) |
Definition at line 571 of file mrp2_serial.cpp.
void MRP2_Serial::reset_positions | ( | ) |
Definition at line 545 of file mrp2_serial.cpp.
int MRP2_Serial::second_validator | ( | uint8_t * | buf, |
int | data_len | ||
) | [private] |
Definition at line 965 of file mrp2_serial.cpp.
int MRP2_Serial::send_and_get_reply | ( | uint8_t | _command, |
uint8_t * | send_array, | ||
int | send_size, | ||
bool | is_ack | ||
) | [private] |
Definition at line 693 of file mrp2_serial.cpp.
void MRP2_Serial::set_bumper_estop | ( | bool | value | ) |
Definition at line 642 of file mrp2_serial.cpp.
void MRP2_Serial::set_estop | ( | bool | value | ) |
Definition at line 286 of file mrp2_serial.cpp.
void MRP2_Serial::set_max_accel | ( | uint32_t | value | ) |
Definition at line 267 of file mrp2_serial.cpp.
void MRP2_Serial::set_maxspeed_fwd | ( | uint32_t | value | ) |
Definition at line 231 of file mrp2_serial.cpp.
void MRP2_Serial::set_maxspeed_rev | ( | uint32_t | value | ) |
Definition at line 249 of file mrp2_serial.cpp.
void MRP2_Serial::set_param_imax | ( | char | side, |
uint32_t | value | ||
) |
Definition at line 207 of file mrp2_serial.cpp.
void MRP2_Serial::set_param_pid | ( | char | side, |
char | param, | ||
float | value | ||
) |
Definition at line 139 of file mrp2_serial.cpp.
void MRP2_Serial::set_read_timeout | ( | double | timeout | ) |
Definition at line 1250 of file mrp2_serial.cpp.
void MRP2_Serial::set_speed_l | ( | int32_t | left_speed | ) |
Definition at line 87 of file mrp2_serial.cpp.
void MRP2_Serial::set_speed_r | ( | int32_t | right_speed | ) |
Definition at line 113 of file mrp2_serial.cpp.
void MRP2_Serial::set_speeds | ( | int32_t | left_speed, |
int32_t | right_speed | ||
) |
Definition at line 51 of file mrp2_serial.cpp.
void MRP2_Serial::update | ( | ) |
Definition at line 46 of file mrp2_serial.cpp.
void MRP2_Serial::update_diag | ( | ) |
Definition at line 596 of file mrp2_serial.cpp.
uint8_t MRP2_Serial::_ack_data [private] |
Definition at line 172 of file mrp2_serial.h.
int MRP2_Serial::_batt_cell_capacity [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_batt_current [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_batt_soc [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_batt_volt [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_baudrate [private] |
Definition at line 163 of file mrp2_serial.h.
int MRP2_Serial::_bumper_estop [private] |
Definition at line 150 of file mrp2_serial.h.
std::vector<int> MRP2_Serial::_bumpers [private] |
Definition at line 154 of file mrp2_serial.h.
bool MRP2_Serial::_diag_aux_lights_err [private] |
Definition at line 151 of file mrp2_serial.h.
bool MRP2_Serial::_diag_batt_high [private] |
Definition at line 151 of file mrp2_serial.h.
bool MRP2_Serial::_diag_batt_low [private] |
Definition at line 151 of file mrp2_serial.h.
bool MRP2_Serial::_diag_motor_drvr_err [private] |
Definition at line 151 of file mrp2_serial.h.
bool MRP2_Serial::_diag_motor_stall_l [private] |
Definition at line 151 of file mrp2_serial.h.
bool MRP2_Serial::_diag_motor_stall_r [private] |
Definition at line 151 of file mrp2_serial.h.
bool MRP2_Serial::_estop [private] |
Definition at line 151 of file mrp2_serial.h.
int MRP2_Serial::_estop_btn [private] |
Definition at line 150 of file mrp2_serial.h.
std::vector<int> MRP2_Serial::_imax [private] |
Definition at line 154 of file mrp2_serial.h.
int MRP2_Serial::_imax_l [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_imax_r [private] |
Definition at line 150 of file mrp2_serial.h.
double MRP2_Serial::_Kd_l [private] |
Definition at line 152 of file mrp2_serial.h.
double MRP2_Serial::_Kd_r [private] |
Definition at line 152 of file mrp2_serial.h.
double MRP2_Serial::_Ki_l [private] |
Definition at line 152 of file mrp2_serial.h.
double MRP2_Serial::_Ki_r [private] |
Definition at line 152 of file mrp2_serial.h.
double MRP2_Serial::_Kp_l [private] |
Definition at line 152 of file mrp2_serial.h.
double MRP2_Serial::_Kp_r [private] |
Definition at line 152 of file mrp2_serial.h.
int MRP2_Serial::_maxaccel [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_maxspeed_fwd [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_maxspeed_rev [private] |
Definition at line 150 of file mrp2_serial.h.
std::string MRP2_Serial::_mode [private] |
Definition at line 164 of file mrp2_serial.h.
std::string MRP2_Serial::_port_name [private] |
Definition at line 164 of file mrp2_serial.h.
int MRP2_Serial::_port_nr [private] |
Definition at line 162 of file mrp2_serial.h.
int MRP2_Serial::_position_l [private] |
Definition at line 153 of file mrp2_serial.h.
int MRP2_Serial::_position_r [private] |
Definition at line 153 of file mrp2_serial.h.
std::vector<int> MRP2_Serial::_positions [private] |
Definition at line 154 of file mrp2_serial.h.
std::vector<int> MRP2_Serial::_sonars [private] |
Definition at line 154 of file mrp2_serial.h.
int MRP2_Serial::_speed_l [private] |
Definition at line 150 of file mrp2_serial.h.
int MRP2_Serial::_speed_r [private] |
Definition at line 150 of file mrp2_serial.h.
std::vector<int> MRP2_Serial::_speeds [private] |
Definition at line 154 of file mrp2_serial.h.
bool MRP2_Serial::dir_left [private] |
Definition at line 159 of file mrp2_serial.h.
bool MRP2_Serial::dir_right [private] |
Definition at line 160 of file mrp2_serial.h.
bool MRP2_Serial::e_stop [private] |
Definition at line 158 of file mrp2_serial.h.
int MRP2_Serial::ep_in_addr_ [private] |
Definition at line 181 of file mrp2_serial.h.
int MRP2_Serial::ep_out_addr_ [private] |
Definition at line 181 of file mrp2_serial.h.
double MRP2_Serial::Kd [private] |
Definition at line 174 of file mrp2_serial.h.
double MRP2_Serial::Ki [private] |
Definition at line 174 of file mrp2_serial.h.
double MRP2_Serial::Kol [private] |
Definition at line 174 of file mrp2_serial.h.
double MRP2_Serial::Kp [private] |
Definition at line 174 of file mrp2_serial.h.
bool MRP2_Serial::line_ok_ [private] |
Definition at line 185 of file mrp2_serial.h.
uint16_t MRP2_Serial::product_id_ [private] |
Definition at line 180 of file mrp2_serial.h.
double MRP2_Serial::read_timeout_ [private] |
Definition at line 175 of file mrp2_serial.h.
bool MRP2_Serial::seekForChar [private] |
Definition at line 170 of file mrp2_serial.h.
char MRP2_Serial::sendArray[20] [private] |
Definition at line 157 of file mrp2_serial.h.
milvus::SerialComm MRP2_Serial::serial_port [private] |
Definition at line 177 of file mrp2_serial.h.
bool MRP2_Serial::simple_ [private] |
Definition at line 187 of file mrp2_serial.h.
int MRP2_Serial::speeds[2] [private] |
Definition at line 156 of file mrp2_serial.h.
char MRP2_Serial::startChar [private] |
Definition at line 171 of file mrp2_serial.h.
uint8_t MRP2_Serial::tempData[10000] [private] |
Definition at line 167 of file mrp2_serial.h.
uint8_t MRP2_Serial::tempDataIndex [private] |
Definition at line 168 of file mrp2_serial.h.
milvus::UsbComm MRP2_Serial::usb_port [private] |
Definition at line 178 of file mrp2_serial.h.
bool MRP2_Serial::use_usb_ [private] |
Definition at line 183 of file mrp2_serial.h.
uint16_t MRP2_Serial::vendor_id_ [private] |
Definition at line 180 of file mrp2_serial.h.