sr_motor_robot_lib.hpp
Go to the documentation of this file.
00001 
00027 #ifndef _SR_MOTOR_ROBOT_LIB_HPP_
00028 #define _SR_MOTOR_ROBOT_LIB_HPP_
00029 
00030 #include "sr_robot_lib/sr_robot_lib.hpp"
00031 
00032 #include <sr_robot_msgs/ForceController.h>
00033 #include <sr_robot_msgs/ControlType.h>
00034 #include <sr_robot_msgs/ChangeControlType.h>
00035 #include <sr_robot_msgs/MotorSystemControls.h>
00036 #include <sr_robot_msgs/ChangeMotorSystemControls.h>
00037 
00038 #include "sr_robot_lib/motor_updater.hpp"
00039 #include "sr_robot_lib/motor_data_checker.hpp"
00040 
00041 
00042 
00043 namespace shadow_robot
00044 {
00045   template <class StatusType, class CommandType>
00046   class SrMotorRobotLib : public SrRobotLib<StatusType, CommandType>
00047   {
00048   public:
00049     SrMotorRobotLib(pr2_hardware_interface::HardwareInterface *hw);
00050     virtual ~SrMotorRobotLib() {};
00051 
00060     void update(StatusType* status_data);
00061 
00068     void build_command(CommandType* command);
00069 
00074     void add_diagnostics(std::vector<diagnostic_msgs::DiagnosticStatus> &vec,
00075                          diagnostic_updater::DiagnosticStatusWrapper &d);
00076 
00080     void reinitialize_motors();
00081 
00082 
00084     operation_mode::device_update_state::DeviceUpdateState motor_current_state;
00085 
00086 
00087   protected:
00088 
00097     virtual void initialize(std::vector<std::string> joint_names, std::vector<int> actuator_ids,
00098                             std::vector<shadow_joints::JointToSensor> joint_to_sensors,
00099                             std::vector<sr_actuator::SrGenericActuator*> actuators) = 0;
00100 
00108     void read_additional_data(boost::ptr_vector<shadow_joints::Joint>::iterator joint_tmp, StatusType* status_data);
00109 
00118     std::vector<std::pair<std::string, bool> > humanize_flags(int flag);
00119 
00136     void generate_force_control_config(int motor_index, int max_pwm, int sg_left, int sg_right,
00137                                        int f, int p, int i, int d, int imax,
00138                                        int deadband, int sign);
00139 
00145     boost::shared_ptr<generic_updater::MotorUpdater<CommandType> > motor_updater_;
00146 
00147 
00153     typedef std::pair<int, std::vector<crc_unions::union16> > ForceConfig;
00157     std::queue<ForceConfig, std::list<ForceConfig> > reconfig_queue;
00159     int config_index;
00160 
00162     std::queue<short, std::list<short> > reset_motors_queue;
00163 
00164 
00166     int motor_index_full;
00168     int index_motor_in_msg;
00169 
00170     int8u crc_byte;
00171     int16u crc_result;
00172     int8u crc_i;
00173 
00174 
00176     std::vector<generic_updater::UpdateConfig> motor_update_rate_configs_vector;
00177 
00178     boost::shared_ptr<generic_updater::MotorDataChecker> motor_data_checker;
00179 
00180 
00182     sr_robot_msgs::ControlType control_type_;
00191     bool control_type_changed_flag_;
00193     ros::ServiceServer change_control_type_;
00195     boost::shared_ptr<boost::mutex> lock_command_sending_;
00196 
00206     bool change_control_type_callback_( sr_robot_msgs::ChangeControlType::Request& request,
00207                                         sr_robot_msgs::ChangeControlType::Response& response );
00208 
00218     bool change_control_parameters(int16_t control_type);
00219 
00221     std::queue<std::vector<sr_robot_msgs::MotorSystemControls>, std::list<std::vector<sr_robot_msgs::MotorSystemControls> > > motor_system_control_flags_;
00223     ros::ServiceServer motor_system_control_server_;
00224 
00235     bool motor_system_controls_callback_( sr_robot_msgs::ChangeMotorSystemControls::Request& request,
00236                                           sr_robot_msgs::ChangeMotorSystemControls::Response& response );
00237   };//end class
00238 }//end namespace
00239 
00240 /* For the emacs weenies in the crowd.
00241 Local Variables:
00242    c-basic-offset: 2
00243 End:
00244 */
00245 
00246 #endif


sr_robot_lib
Author(s): Ugo Cupcic / ugo@shadowrobot.com , software@shadowrobot.com
autogenerated on Mon Oct 6 2014 07:37:50