roboteq.h
Go to the documentation of this file.
1 
31 #ifndef ROBOTEQ_H
32 #define ROBOTEQ_H
33 
34 #include <ros/ros.h>
35 #include <serial/serial.h>
36 
37 #include <std_msgs/Bool.h>
38 #include <roboteq_control/Service.h>
39 #include <roboteq_control/Peripheral.h>
40 
44 
45 #include <roboteq_control/RoboteqControllerConfig.h>
46 
51 #include "roboteq/motor.h"
52 
53 using namespace std;
54 
55 namespace roboteq
56 {
57 
58 typedef struct joint
59 {
61  // State of the motor
62  double position;
63  double velocity;
64  double effort;
66 } joint_t;
67 
68 typedef struct _status_flag {
69  uint8_t serial_mode : 1;
70  uint8_t pulse_mode : 1;
71  uint8_t analog_mode : 1;
72  uint8_t spectrum : 1;
73  uint8_t power_stage_off : 1;
74  uint8_t stall_detect : 1;
75  uint8_t at_limit : 1;
76  uint8_t microbasic_running : 1;
78 // Reference in pag 245
79 typedef struct _status_fault {
80  uint8_t overheat : 1;
81  uint8_t overvoltage : 1;
82  uint8_t undervoltage : 1;
83  uint8_t short_circuit : 1;
84  uint8_t emergency_stop : 1;
85  uint8_t brushless_sensor_fault : 1;
86  uint8_t mosfet_failure : 1;
88 
90 {
91 public:
98  Roboteq(const ros::NodeHandle &nh, const ros::NodeHandle &private_nh, serial_controller *serial);
102  ~Roboteq();
111  void initialize();
116  void initializeInterfaces(hardware_interface::JointStateInterface &joint_state_interface,
117  hardware_interface::VelocityJointInterface &velocity_joint_interface);
121  void updateDiagnostics();
122 
123  void initializeDiagnostic();
124 
125  void write(const ros::Time& time, const ros::Duration& period);
126 
127  void read(const ros::Time& time, const ros::Duration& period);
128 
129  bool prepareSwitch(const std::list<hardware_interface::ControllerInfo>& start_list, const std::list<hardware_interface::ControllerInfo>& stop_list);
130 
131  void doSwitch(const std::list<hardware_interface::ControllerInfo>& start_list, const std::list<hardware_interface::ControllerInfo>& stop_list);
132 
133 private:
134  //Initialization object
135  //NameSpace for bridge controller
138  // Serial controller
140  // Diagnostic
142  // Publisher status periheral
144  // stop publisher
146  // Service board
148 
151 
153  //hardware_interface::JointStateInterface joint_state_interface;
154  //hardware_interface::VelocityJointInterface velocity_joint_interface;
155 
156  // Check if is the first run
157  bool _first;
158  // Motor definition
159  //map<string, Motor*> mMotor;
160  std::vector<Motor*> mMotor;
161 
162  string _type, _model;
163  string _version;
164  string _uid;
165  // Status Roboteq board
167  // Fault flags Roboteq board
169  // Volts internal
170  double _volts_internal, _volts_five;
171  // Tempearture inside the Roboteq board
172  double _temp_mcu, _temp_bridge;
173 
174  bool first_read_ = true;
175  double first_read_pos_[2];
176 
177  // GPIO enable read
179  roboteq_control::Peripheral msg_peripheral;
180  std::vector<GPIOAnalogConfigurator*> _param_analog;
181  std::vector<GPIOPulseConfigurator*> _param_pulse;
182  // Encoder
183  std::vector<GPIOEncoderConfigurator*> _param_encoder;
184 
185 
186  // stop callback
187  void stop_Callback(const std_msgs::Bool::ConstPtr& msg);
191  void getRoboteqInformation();
192 
195 
197  dynamic_reconfigure::Server<roboteq_control::RoboteqControllerConfig> *ds_controller;
203  void reconfigureCBController(roboteq_control::RoboteqControllerConfig &config, uint32_t level);
204 
205  // Default parameter config
206  roboteq_control::RoboteqControllerConfig default_controller_config, _last_controller_config;
207 
211  void getControllerFromRoboteq();
212 
219  bool service_Callback(roboteq_control::Service::Request &req, roboteq_control::Service::Response &msg_system);
224  void connectionCallback(const ros::SingleSubscriberPublisher& pub);
225 
226 };
227 
228 }
229 
230 
231 #endif // ROBOTEQ_H
ros::NodeHandle mNh
Definition: roboteq.h:136
ros::Subscriber sub_stop
Definition: roboteq.h:145
serial_controller * mSerial
Definition: roboteq.h:139
diagnostic_updater::Updater diagnostic_updater
Definition: roboteq.h:141
double _volts_internal
Definition: roboteq.h:170
ROSCONSOLE_DECL void initialize()
double velocity
Definition: roboteq.h:63
std::vector< GPIOAnalogConfigurator * > _param_analog
Definition: roboteq.h:180
ros::Publisher pub_peripheral
Definition: roboteq.h:143
roboteq_control::Peripheral msg_peripheral
Definition: roboteq.h:179
urdf::Model model
URDF information about robot.
Definition: roboteq.h:150
double effort
Definition: roboteq.h:64
std::vector< GPIOEncoderConfigurator * > _param_encoder
Definition: roboteq.h:183
bool _isGPIOreading
Definition: roboteq.h:178
std::vector< Motor * > mMotor
Definition: roboteq.h:160
string _type
Definition: roboteq.h:162
ros::NodeHandle private_mNh
Definition: roboteq.h:137
bool _first
ROS Control interfaces.
Definition: roboteq.h:157
bool setup_controller
Setup variable.
Definition: roboteq.h:194
double velocity_command
Definition: roboteq.h:65
string _version
Definition: roboteq.h:163
Definition: motor.h:51
roboteq_control::RoboteqControllerConfig default_controller_config
Definition: roboteq.h:206
status_flag_t _flag
Definition: roboteq.h:166
struct roboteq::_status_flag status_flag_t
std::vector< GPIOPulseConfigurator * > _param_pulse
Definition: roboteq.h:181
double position
Definition: roboteq.h:62
struct roboteq::joint joint_t
struct roboteq::_status_fault status_fault_t
status_fault_t _fault
Definition: roboteq.h:168
void run(ClassLoader *loader)
double _temp_mcu
Definition: roboteq.h:172
dynamic_reconfigure::Server< roboteq_control::RoboteqControllerConfig > * ds_controller
Dynamic reconfigure PID.
Definition: roboteq.h:197
Motor * motor
Definition: roboteq.h:60
ros::ServiceServer srv_board
Definition: roboteq.h:147


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