#include <sr_motor_robot_lib.hpp>
Public Member Functions | |
void | add_diagnostics (std::vector< diagnostic_msgs::DiagnosticStatus > &vec, diagnostic_updater::DiagnosticStatusWrapper &d) |
void | build_command (CommandType *command) |
void | reinitialize_motors () |
SrMotorRobotLib (pr2_hardware_interface::HardwareInterface *hw) | |
void | update (StatusType *status_data) |
virtual | ~SrMotorRobotLib () |
Public Attributes | |
operation_mode::device_update_state::DeviceUpdateState | motor_current_state |
Current update state of the motor (initialization, operation..) | |
Protected Types | |
typedef std::pair< int, std::vector < crc_unions::union16 > > | ForceConfig |
Protected Member Functions | |
bool | change_control_parameters (int16_t control_type) |
bool | change_control_type_callback_ (sr_robot_msgs::ChangeControlType::Request &request, sr_robot_msgs::ChangeControlType::Response &response) |
void | generate_force_control_config (int motor_index, int max_pwm, int sg_left, int sg_right, int f, int p, int i, int d, int imax, int deadband, int sign) |
std::vector< std::pair < std::string, bool > > | humanize_flags (int flag) |
virtual void | initialize (std::vector< std::string > joint_names, std::vector< int > actuator_ids, std::vector< shadow_joints::JointToSensor > joint_to_sensors, std::vector< sr_actuator::SrGenericActuator * > actuators)=0 |
bool | motor_system_controls_callback_ (sr_robot_msgs::ChangeMotorSystemControls::Request &request, sr_robot_msgs::ChangeMotorSystemControls::Response &response) |
void | read_additional_data (boost::ptr_vector< shadow_joints::Joint >::iterator joint_tmp, StatusType *status_data) |
Protected Attributes | |
ros::ServiceServer | change_control_type_ |
A service server used to change the control type on the fly. | |
int | config_index |
this index is used to iterate over the config we're sending. | |
sr_robot_msgs::ControlType | control_type_ |
The current type of control (FORCE demand or PWM demand sent to the motors) | |
bool | control_type_changed_flag_ |
int8u | crc_byte |
int8u | crc_i |
int16u | crc_result |
int | index_motor_in_msg |
The index of the motor in the current message (from 0 to 9) | |
boost::shared_ptr< boost::mutex > | lock_command_sending_ |
A mutual exclusion object to ensure that no command will be sent to the robot while a change in the control type (PWM or torque) is ongoing. | |
boost::shared_ptr < generic_updater::MotorDataChecker > | motor_data_checker |
int | motor_index_full |
The index of the motor in all the 20 motors. | |
std::queue< std::vector < sr_robot_msgs::MotorSystemControls > , std::list< std::vector < sr_robot_msgs::MotorSystemControls > > > | motor_system_control_flags_ |
The Flag which will be sent to change the motor controls. | |
ros::ServiceServer | motor_system_control_server_ |
A service server used to call the different motor system controls "buttons". | |
std::vector < generic_updater::UpdateConfig > | motor_update_rate_configs_vector |
The update rate for each motor information. | |
boost::shared_ptr < generic_updater::MotorUpdater < CommandType > > | motor_updater_ |
std::queue< ForceConfig, std::list< ForceConfig > > | reconfig_queue |
std::queue< short, std::list < short > > | reset_motors_queue |
contains a queue of motor indexes to reset |
Definition at line 46 of file sr_motor_robot_lib.hpp.
typedef std::pair<int, std::vector<crc_unions::union16> > shadow_robot::SrMotorRobotLib< StatusType, CommandType >::ForceConfig [protected] |
The ForceConfig type consists of an int representing the motor index for this config followed by a vector of config: the index in the vector of config corresponds to the type of the data, and the value at this index corresponds to the value we want to set.
Definition at line 153 of file sr_motor_robot_lib.hpp.
shadow_robot::SrMotorRobotLib< StatusType, CommandType >::SrMotorRobotLib | ( | pr2_hardware_interface::HardwareInterface * | hw | ) |
Initialising service
Definition at line 45 of file sr_motor_robot_lib.cpp.
virtual shadow_robot::SrMotorRobotLib< StatusType, CommandType >::~SrMotorRobotLib | ( | ) | [inline, virtual] |
Definition at line 50 of file sr_motor_robot_lib.hpp.
void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::add_diagnostics | ( | std::vector< diagnostic_msgs::DiagnosticStatus > & | vec, |
diagnostic_updater::DiagnosticStatusWrapper & | d | ||
) | [virtual] |
This function adds the diagnostics for the hand to the multi diagnostic status published in sr06.cpp.
Implements shadow_robot::SrRobotLib< StatusType, CommandType >.
Definition at line 410 of file sr_motor_robot_lib.cpp.
void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::build_command | ( | CommandType * | command | ) | [virtual] |
Builds a motor command: either send a torque demand or a configuration demand if one is waiting.
command | The command we're building. |
Implements shadow_robot::SrRobotLib< StatusType, CommandType >.
Definition at line 172 of file sr_motor_robot_lib.cpp.
bool shadow_robot::SrMotorRobotLib< StatusType, CommandType >::change_control_parameters | ( | int16_t | control_type | ) | [protected] |
Load the necessary parameters in the Parameter Server and calls a service for every controller currently loaded in the controller manager to make it reload (resetGains()) its parameters from the Parameter Server
control_type | The new active control type (PWM or torque) |
Definition at line 966 of file sr_motor_robot_lib.cpp.
bool shadow_robot::SrMotorRobotLib< StatusType, CommandType >::change_control_type_callback_ | ( | sr_robot_msgs::ChangeControlType::Request & | request, |
sr_robot_msgs::ChangeControlType::Response & | response | ||
) | [protected] |
The callback to the change_control_type_ service. Updates the current control_type_ with the requested control_type.
request | Requested control_type_ |
response | The new control_type we'll use |
Definition at line 917 of file sr_motor_robot_lib.cpp.
void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::generate_force_control_config | ( | int | motor_index, |
int | max_pwm, | ||
int | sg_left, | ||
int | sg_right, | ||
int | f, | ||
int | p, | ||
int | i, | ||
int | d, | ||
int | imax, | ||
int | deadband, | ||
int | sign | ||
) | [protected] |
Generates a force control config and adds it to the reconfig_queue with its CRC. The config will be sent as soon as possible.
motor_index | The motor index. |
max_pwm | The max pwm the motor will apply |
sg_left | Strain gauge left |
sg_right | Strain gauge right |
f | The feedforward term (directly adds f*error to the output of the PID) |
p | The p value. |
i | the i value. |
d | the d value. |
imax | the imax value. |
deadband | the deadband on the force. |
sign | can be 0 or 1 depending on the way the motor is plugged in. |
Definition at line 840 of file sr_motor_robot_lib.cpp.
std::vector< std::pair< std::string, bool > > shadow_robot::SrMotorRobotLib< StatusType, CommandType >::humanize_flags | ( | int | flag | ) | [protected] |
Transforms the incoming flag as a human readable vector of strings.
flag | incoming flag. |
Definition at line 816 of file sr_motor_robot_lib.cpp.
virtual void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::initialize | ( | std::vector< std::string > | joint_names, |
std::vector< int > | actuator_ids, | ||
std::vector< shadow_joints::JointToSensor > | joint_to_sensors, | ||
std::vector< sr_actuator::SrGenericActuator * > | actuators | ||
) | [protected, pure virtual] |
Initializes the hand library with the needed values.
joint_names | A vector containing all the joint names. |
actuator_ids | A vector containing the corresponding actuator ids. |
joint_to_sensors | A vector mapping the joint to the sensor index we read from the palm. |
actuators | A vector containing the actuators for the different joints. |
Implements shadow_robot::SrRobotLib< StatusType, CommandType >.
Implemented in shadow_robot::SrMotorHandLib< StatusType, CommandType >, and shadow_robot::SrMotorHandLib< STATUS_TYPE, COMMAND_TYPE >.
bool shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_system_controls_callback_ | ( | sr_robot_msgs::ChangeMotorSystemControls::Request & | request, |
sr_robot_msgs::ChangeMotorSystemControls::Response & | response | ||
) | [protected] |
The callback to the control_motor_ service. Sets the correct flags to 1 or 0 for the MOTOR_SYSTEM_CONTROLS, to control the motors (backlash compensation on/off, increase sg tracking, jiggling, write config to EEprom)
request | Contains the different flags the user wants to set |
response | SUCCESS if success, MOTOR_ID_OUT_OF_RANGE if bad motor_id given |
Definition at line 1052 of file sr_motor_robot_lib.cpp.
void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::read_additional_data | ( | boost::ptr_vector< shadow_joints::Joint >::iterator | joint_tmp, |
StatusType * | status_data | ||
) | [protected] |
Read additional data from the latest message and stores it into the joints_vector.
joint_tmp | The joint we want to read the data for. |
status_data | The status information that comes from the robot |
Definition at line 535 of file sr_motor_robot_lib.cpp.
void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::reinitialize_motors | ( | ) |
Initiates the process to retrieve the initialization information from the motors
Definition at line 907 of file sr_motor_robot_lib.cpp.
void shadow_robot::SrMotorRobotLib< StatusType, CommandType >::update | ( | StatusType * | status_data | ) | [virtual] |
This function is called each time a new etherCAT message is received in the sr06.cpp driver. It updates the joints_vector, updating the different values, computing the calibrated joint positions, etc... It also updates the tactile sensors values.
status_data | the received etherCAT message |
Implements shadow_robot::SrRobotLib< StatusType, CommandType >.
Definition at line 87 of file sr_motor_robot_lib.cpp.
ros::ServiceServer shadow_robot::SrMotorRobotLib< StatusType, CommandType >::change_control_type_ [protected] |
A service server used to change the control type on the fly.
Definition at line 193 of file sr_motor_robot_lib.hpp.
int shadow_robot::SrMotorRobotLib< StatusType, CommandType >::config_index [protected] |
this index is used to iterate over the config we're sending.
Definition at line 159 of file sr_motor_robot_lib.hpp.
sr_robot_msgs::ControlType shadow_robot::SrMotorRobotLib< StatusType, CommandType >::control_type_ [protected] |
The current type of control (FORCE demand or PWM demand sent to the motors)
Definition at line 182 of file sr_motor_robot_lib.hpp.
bool shadow_robot::SrMotorRobotLib< StatusType, CommandType >::control_type_changed_flag_ [protected] |
Flag to signal that there has been a change in the value of control_type_ and certain actions are required. The flag is set in the callback function of the change_control_type_ service. The flag is checked in build_command() and the necessary actions are taken there. These actions involve calling services in the controller manager and all the active controllers. This is the reason why we don't do it directly in the callback function. As we use a single thread to serve the callbacks, doing so would cause a deadlock, thus we do it in the realtime loop thread instead.
Definition at line 191 of file sr_motor_robot_lib.hpp.
int8u shadow_robot::SrMotorRobotLib< StatusType, CommandType >::crc_byte [protected] |
Definition at line 170 of file sr_motor_robot_lib.hpp.
int8u shadow_robot::SrMotorRobotLib< StatusType, CommandType >::crc_i [protected] |
Definition at line 172 of file sr_motor_robot_lib.hpp.
int16u shadow_robot::SrMotorRobotLib< StatusType, CommandType >::crc_result [protected] |
Definition at line 171 of file sr_motor_robot_lib.hpp.
int shadow_robot::SrMotorRobotLib< StatusType, CommandType >::index_motor_in_msg [protected] |
The index of the motor in the current message (from 0 to 9)
Definition at line 168 of file sr_motor_robot_lib.hpp.
boost::shared_ptr<boost::mutex> shadow_robot::SrMotorRobotLib< StatusType, CommandType >::lock_command_sending_ [protected] |
A mutual exclusion object to ensure that no command will be sent to the robot while a change in the control type (PWM or torque) is ongoing.
Definition at line 195 of file sr_motor_robot_lib.hpp.
operation_mode::device_update_state::DeviceUpdateState shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_current_state |
Current update state of the motor (initialization, operation..)
Definition at line 84 of file sr_motor_robot_lib.hpp.
boost::shared_ptr<generic_updater::MotorDataChecker> shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_data_checker [protected] |
Definition at line 178 of file sr_motor_robot_lib.hpp.
int shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_index_full [protected] |
The index of the motor in all the 20 motors.
Definition at line 166 of file sr_motor_robot_lib.hpp.
std::queue<std::vector<sr_robot_msgs::MotorSystemControls>, std::list<std::vector<sr_robot_msgs::MotorSystemControls> > > shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_system_control_flags_ [protected] |
The Flag which will be sent to change the motor controls.
Definition at line 221 of file sr_motor_robot_lib.hpp.
ros::ServiceServer shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_system_control_server_ [protected] |
A service server used to call the different motor system controls "buttons".
Definition at line 223 of file sr_motor_robot_lib.hpp.
std::vector<generic_updater::UpdateConfig> shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_update_rate_configs_vector [protected] |
The update rate for each motor information.
Definition at line 176 of file sr_motor_robot_lib.hpp.
boost::shared_ptr<generic_updater::MotorUpdater<CommandType> > shadow_robot::SrMotorRobotLib< StatusType, CommandType >::motor_updater_ [protected] |
The motor updater is used to create a correct command to send to the motor. It's build_command() is called each time the SR06::packCommand() is called.
Definition at line 145 of file sr_motor_robot_lib.hpp.
std::queue<ForceConfig, std::list<ForceConfig> > shadow_robot::SrMotorRobotLib< StatusType, CommandType >::reconfig_queue [protected] |
This queue contains the force PID config waiting to be pushed to the motor.
Definition at line 157 of file sr_motor_robot_lib.hpp.
std::queue<short, std::list<short> > shadow_robot::SrMotorRobotLib< StatusType, CommandType >::reset_motors_queue [protected] |
contains a queue of motor indexes to reset
Definition at line 162 of file sr_motor_robot_lib.hpp.