motor.h
Go to the documentation of this file.
1 
31 #ifndef MOTOR_H
32 #define MOTOR_H
33 
34 #include <ros/ros.h>
35 #include <urdf/model.h>
36 
42 
43 #include <roboteq_control/MotorStatus.h>
44 #include <roboteq_control/ControlStatus.h>
45 
49 #include "configurator/motor_pid.h"
50 
51 namespace roboteq
52 {
53 
54 typedef struct _motor_status {
55  uint8_t amps_limit : 1;
56  uint8_t motor_stalled : 1;
57  uint8_t loop_error_detect : 1;
58  uint8_t safety_stop_active : 1;
61  uint8_t amps_triggered_active : 1;
62  uint8_t : 1;
64 
66 {
67 public:
75  explicit Motor(const ros::NodeHandle &nh, serial_controller *serial, string name, unsigned int number);
80  void initializeMotor(bool load_from_board);
90  void setupLimits(urdf::Model model);
95  void resetPosition(double position);
100  void writeCommandsToHardware(ros::Duration period);
105  void switchController(string type);
109  void stopMotor();
114  int getNumber() {
115  return mNumber;
116  }
117 
122  string getName() {
123  return mMotorName;
124  }
130  {
131  _sensor = sensor;
132  }
137  void readVector(std::vector<std::string> fields);
138 
141 
142  // Number of motor
143  unsigned int mNumber;
144 protected:
149  static double to_rpm(double x)
150  {
151  return x * 60 / (2 * M_PI);
152  }
153 
158  static double from_rpm(double x)
159  {
160  return x * (2 * M_PI) / 60;
161  }
162 
169  double to_encoder_ticks(double x);
170 
177  double from_encoder_ticks(double x);
178 public:
179  double position;
180 
181 private:
182  //Initialization object
183  //NameSpace for bridge controller
185  // Name of the motor
186  string mMotorName;
187  // Serial controller communication
189  // State of the motor
190  double max_position;
191  double velocity, max_velocity;
192  double effort, max_effort;
193  double command;
194 
197 
200 
201  // Publisher diagnostic information
203  // Message
204  roboteq_control::MotorStatus msg_status;
205  roboteq_control::ControlStatus msg_control;
206 
211 
213 
214  // Reader motor message
215  void read(string data);
216 
217  void connectionCallback(const ros::SingleSubscriberPublisher& pub);
218 };
219 
220 }
221 
222 #endif // MOTOR_H
uint8_t loop_error_detect
Definition: motor.h:57
ros::Publisher pub_status
Definition: motor.h:202
roboteq_control::ControlStatus msg_control
Definition: motor.h:205
double command
Definition: motor.h:193
double max_position
Definition: motor.h:190
double max_effort
Definition: motor.h:192
hardware_interface::JointStateHandle joint_state_handle
Definition: motor.h:139
uint8_t reverse_limit_triggered
Definition: motor.h:60
hardware_interface::JointHandle joint_handle
Definition: motor.h:140
struct roboteq::_motor_status motor_status_t
uint8_t amps_limit
Definition: motor.h:55
uint8_t safety_stop_active
Definition: motor.h:58
joint_limits_interface::VelocityJointSoftLimitsInterface vel_limits_interface
ROS joint limits interface.
Definition: motor.h:199
GPIOSensor * _sensor
Definition: motor.h:212
uint8_t motor_stalled
Definition: motor.h:56
string getName()
getName the name of the motor
Definition: motor.h:122
unsigned int mNumber
Definition: motor.h:143
uint8_t amps_triggered_active
Definition: motor.h:61
motor_status_t _status
Definition: motor.h:196
TFSIMD_FORCE_INLINE const tfScalar & x() const
MotorPIDConfigurator * pid_position
Definition: motor.h:210
static double to_rpm(double x)
Definition: motor.h:149
int getNumber()
getNumber The roboteq number
Definition: motor.h:114
MotorParamConfigurator * parameter
Definition: motor.h:207
void registerSensor(GPIOSensor *sensor)
registerSensor register the sensor
Definition: motor.h:129
MotorPIDConfigurator * pid_velocity
Definition: motor.h:208
MotorPIDConfigurator * pid_torque
Definition: motor.h:209
static double from_rpm(double x)
Definition: motor.h:158
Definition: motor.h:51
uint8_t forward_limit_triggered
Definition: motor.h:59
ros::NodeHandle mNh
Definition: motor.h:184
string mMotorName
Definition: motor.h:186
int _control_mode
Definition: motor.h:195
double velocity
Definition: motor.h:191
void run(ClassLoader *loader)
roboteq_control::MotorStatus msg_status
Definition: motor.h:204
double position
Definition: motor.h:179
serial_controller * mSerial
Definition: motor.h:188


roboteq_control
Author(s): Raffaello Bonghi
autogenerated on Wed Jan 3 2018 03:48:23