sr_muscle_robot_lib.hpp
Go to the documentation of this file.
00001 
00027 #ifndef _SR_MUSCLE_ROBOT_LIB_HPP_
00028 #define _SR_MUSCLE_ROBOT_LIB_HPP_
00029 
00030 #include "sr_robot_lib/sr_robot_lib.hpp"
00031 
00032 #include "sr_robot_lib/muscle_updater.hpp"
00033 #include <sr_utilities/calibration.hpp>
00034 
00035 #define NUM_MUSCLE_DRIVERS      4
00036 
00037 namespace shadow_robot
00038 {
00039   template <class StatusType, class CommandType>
00040   class SrMuscleRobotLib : public SrRobotLib<StatusType, CommandType>
00041   {
00042   public:
00043     SrMuscleRobotLib(pr2_hardware_interface::HardwareInterface *hw);
00044     virtual ~SrMuscleRobotLib() {};
00045 
00054     void update(StatusType* status_data);
00055 
00062     void build_command(CommandType* command);
00063 
00068     void add_diagnostics(std::vector<diagnostic_msgs::DiagnosticStatus> &vec,
00069                          diagnostic_updater::DiagnosticStatusWrapper &d);
00070 
00074     void reinitialize_motors();
00075 
00076 
00078     operation_mode::device_update_state::DeviceUpdateState muscle_current_state;
00079 
00080 
00081   protected:
00082 
00091     virtual void initialize(std::vector<std::string> joint_names, std::vector<int> actuator_ids,
00092                             std::vector<shadow_joints::JointToSensor> joint_to_sensors,
00093                             std::vector<sr_actuator::SrGenericActuator*> actuators) = 0;
00094 
00096      shadow_joints::CalibrationMap pressure_calibration_map_;
00098      boost::shared_ptr<shadow_robot::JointCalibration> pressure_calibration_tmp_;
00099 
00100 
00106     virtual shadow_joints::CalibrationMap read_pressure_calibration();
00107 
00108 
00116     void read_additional_muscle_data(boost::ptr_vector<shadow_joints::Joint>::iterator joint_tmp, StatusType* status_data);
00117 
00125     void read_muscle_driver_data(boost::ptr_vector<shadow_joints::MuscleDriver>::iterator muscle_driver_tmp, StatusType* status_data);
00126 
00135     std::vector<std::pair<std::string, bool> > humanize_flags(int flag);
00136 
00140     unsigned int get_muscle_pressure(int muscle_driver_id, int muscle_id, StatusType *status_data);
00141 
00142     inline void set_muscle_driver_data_received_flags(unsigned int msg_type, int muscle_driver_id);
00143 
00144     inline bool check_muscle_driver_data_received_flags();
00145 
00155     inline void set_valve_demand(uint8_t *muscle_data_byte_to_set, int8_t valve_value, uint8_t shifting_index);
00156 
00160     void init_timer_callback(const ros::TimerEvent& event);
00161 
00162     boost::ptr_vector<shadow_joints::MuscleDriver> muscle_drivers_vector_;
00163 
00164 
00170     boost::shared_ptr<generic_updater::MuscleUpdater<CommandType> > muscle_updater_;
00171 
00172 
00174     std::queue<short, std::list<short> > reset_muscle_driver_queue;
00175 
00176 
00177 
00179     std::vector<generic_updater::UpdateConfig> muscle_update_rate_configs_vector;
00180 
00187     std::map<unsigned int, unsigned int> from_muscle_driver_data_received_flags_;
00188 
00189 
00190     ros::Timer check_init_timeout_timer;
00191     static const double timeout;
00192     ros::Duration init_max_duration;
00193 
00195     boost::shared_ptr<boost::mutex> lock_init_timeout_;
00196   };//end class
00197 }//end namespace
00198 
00199 /* For the emacs weenies in the crowd.
00200 Local Variables:
00201    c-basic-offset: 2
00202 End:
00203 */
00204 
00205 #endif


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