sr_actuator.hpp
Go to the documentation of this file.
00001 
00027 #ifndef _SR_ACTUATOR_HPP_
00028 #define _SR_ACTUATOR_HPP_
00029 
00030 #include "sr_hardware_interface/tactile_sensors.hpp"
00031 #include <pr2_hardware_interface/hardware_interface.h>
00032 
00033 namespace sr_actuator
00034 {
00035   class SrActuatorState : public pr2_hardware_interface::ActuatorState
00036   {
00037   public:
00038     SrActuatorState() :
00039       pr2_hardware_interface::ActuatorState(),
00040       temperature_(0),
00041       position_unfiltered_(0.0),
00042       can_msgs_received_(0),
00043       can_msgs_transmitted_(0),
00044       pic_firmware_svn_revision_(0),
00045       server_firmware_svn_revision_(0),
00046       firmware_modified_(0),
00047       serial_number_low_set(false),
00048       serial_number_high_set(false),
00049       serial_number_low(0),
00050       serial_number_high(0),
00051       serial_number(0),
00052       assembly_data_year(0),
00053       assembly_data_month(0),
00054       assembly_data_day(0),
00055       tests_(0),
00056       can_error_counters(0)
00057     {}
00058 
00059 
00060     std::vector<int> raw_sensor_values_;
00061     std::vector<double> calibrated_sensor_values_;
00062 
00070     std::vector<std::pair<std::string, bool> > flags_;
00071 
00072     double temperature_;
00073 
00074     double position_unfiltered_;
00075 
00076     uint64_t can_msgs_received_;
00077     uint64_t can_msgs_transmitted_;
00078 
00079     unsigned int pic_firmware_svn_revision_;
00080     unsigned int server_firmware_svn_revision_;
00081     bool firmware_modified_;
00082 
00083     //Serial number is composed of a low and
00084     // a high byte.
00085     void set_serial_number_low(unsigned int serial)
00086     {
00087       serial_number_low = serial;
00088 
00089       serial_number_low_set = true;
00090       if( serial_number_high_set ) //we received both bytes
00091         compute_serial();
00092     };
00093     void set_serial_number_high(unsigned int serial)
00094     {
00095       serial_number_high = serial;
00096 
00097       serial_number_high_set = true;
00098       if( serial_number_low_set ) //we received both bytes
00099         compute_serial();
00100     };
00101     void compute_serial()
00102     {
00103       serial_number = serial_number_low + (serial_number_high * 65536);
00104     };
00105 
00106     bool serial_number_low_set;
00107     bool serial_number_high_set;
00108     unsigned int serial_number_low;
00109     unsigned int serial_number_high;
00110     unsigned int serial_number;
00111 
00112     unsigned int assembly_data_year;
00113     unsigned int assembly_data_month;
00114     unsigned int assembly_data_day;
00115 
00116     int tests_;
00117     unsigned int can_error_counters;
00118 
00119     std::vector<tactiles::AllTactileData>* tactiles_;
00120   }; //end class SrActuatorState
00121 
00122   class SrMotorActuatorState : public SrActuatorState
00123   {
00124   public:
00125     SrMotorActuatorState() :
00126       SrActuatorState(),
00127       strain_gauge_left_(0),
00128       strain_gauge_right_(0),
00129       force_unfiltered_(0.0),
00130       pwm_(0),
00131       motor_gear_ratio(0),
00132       force_control_f_(0),
00133       force_control_p_(0),
00134       force_control_i_(0),
00135       force_control_d_(0),
00136       force_control_imax_(0),
00137       force_control_deadband_(0),
00138       force_control_sign_(0),
00139       force_control_frequency_(0)
00140     {}
00141 
00142     signed short strain_gauge_left_;
00143     signed short strain_gauge_right_;
00144 
00145 
00146     double force_unfiltered_;
00147 
00148     int pwm_;
00149 
00150     unsigned int motor_gear_ratio;
00151 
00152     int force_control_f_;
00153     int force_control_p_;
00154     int force_control_i_;
00155     int force_control_d_;
00156     int force_control_imax_;
00157     int force_control_deadband_;
00158     int force_control_sign_;
00159     int force_control_frequency_;
00160 
00161     int force_control_pterm;
00162     int force_control_iterm;
00163     int force_control_dterm;
00164   }; //end class SrMotorActuatorState
00165 
00166   class SrMuscleActuatorState : public SrActuatorState
00167   {
00168   public:
00169     SrMuscleActuatorState() :
00170       SrActuatorState()
00171     {}
00172 
00174     uint16_t pressure_[2];
00175     int8_t last_commanded_valve_[2];
00176   }; //end class SrMuscleActuatorState
00177 
00178   class SrMuscleActuatorCommand : public pr2_hardware_interface::ActuatorCommand
00179   {
00180   public:
00181     SrMuscleActuatorCommand() :
00182       pr2_hardware_interface::ActuatorCommand(),
00183       valve_{0, 0}
00184     {}
00185 
00186     int8_t valve_[2];
00187   }; //end class SrMuscleActuatorCommand
00188 
00189 
00190   class SrGenericActuator : public pr2_hardware_interface::Actuator
00191   {
00192   public:
00193     SrGenericActuator()
00194       : pr2_hardware_interface::Actuator()
00195     {}
00196 
00197     SrGenericActuator(std::string name)
00198       : pr2_hardware_interface::Actuator(name)
00199     {}
00200 
00201     //A virtual destructor to make the class polymorphic (the compiler is picky about trying to dynamic_cast non-polymorphic classes)
00202     virtual ~SrGenericActuator()
00203     {}
00204 
00205     //SrActuatorState state_;
00206   }; //end class SrGenericActuator
00207 
00211   class SrActuator : public SrGenericActuator
00212   {
00213   public:
00214     SrActuator()
00215       : SrGenericActuator()
00216     {}
00217 
00218     SrActuator(std::string name)
00219       : SrGenericActuator(name)
00220     {}
00221 
00222     virtual ~SrActuator()
00223     {}
00224 
00225     SrMotorActuatorState state_;
00226   }; //end class SrActuator
00227 
00231   class SrMuscleActuator : public SrGenericActuator
00232   {
00233   public:
00234     SrMuscleActuator()
00235       : SrGenericActuator()
00236     {}
00237 
00238     SrMuscleActuator(std::string name)
00239       : SrGenericActuator(name)
00240     {}
00241 
00242     virtual ~SrMuscleActuator()
00243     {}
00244 
00245     SrMuscleActuatorState state_;
00246     SrMuscleActuatorCommand command_;
00247   }; //end class SrActuator
00248 }
00249 
00250 /* For the emacs weenies in the crowd.
00251 Local Variables:
00252    c-basic-offset: 2
00253 End:
00254 */
00255 
00256 #endif
00257 


sr_hardware_interface
Author(s): Ugo Cupcic / ugo@shadowrobot.com
autogenerated on Mon Oct 6 2014 07:46:07