dxlport_control.h
Go to the documentation of this file.
1 #ifndef DXLPORT_CONTROL_H
2 #define DXLPORT_CONTROL_H
3 
4 #include <map>
5 #include <string>
6 #include <vector>
7 #include <queue>
8 #include <ros/ros.h>
12 
13 #include <dynamixel_sdk/dynamixel_sdk.h> // Uses Dynamixel SDK library
16 
17 #include "device_mutex.h"
18 
19 // Motion data
20 typedef struct HOME_MOTION_DATA {
21  uint16_t home;
22  double home_rad;
23  uint16_t start;
24  double start_rad;
25  uint16_t step;
26  double step_rad;
28 
29 
30 // Dynamixel protocol serial port class
32 {
33 public:
35  ~DXLPORT_CONTROL();
36  ros::Time getTime() const { return ros::Time::now(); }
37  ros::Duration getDuration( ros::Time t ) const { return (ros::Time::now() - t); }
38  bool read( ros::Time, ros::Duration );
39  bool readId( ros::Time, ros::Duration );
40  bool readPos( ros::Time, ros::Duration );
41  bool readCurrent( ros::Time, ros::Duration );
42  bool readTemp( ros::Time, ros::Duration );
43  bool readVel( ros::Time, ros::Duration );
44  void write( ros::Time, ros::Duration );
45  void set_torque_all( bool torque );
46  bool set_torque( uint8_t dxl_id, bool torque );
47  void set_watchdog( uint8_t dxl_id, uint8_t value );
48  void set_watchdog_all( uint8_t value );
49  void startup_motion( void );
50  void set_gain_all( uint16_t gain );
51  void set_gain( uint8_t dxl_id, uint16_t gain );
52  void set_goal_current_all( uint16_t current );
53  void set_goal_current( uint8_t dxl_id, uint16_t current );
54  bool get_init_stat( void ){ return init_stat; }
55  uint8_t get_joint_num( void ){ return joint_num; }
56  std::string self_check( void );
57  void init_joint_params( ST_JOINT_PARAM &param, int table_id, int value );
58 
59  void set_param_delay_time( uint8_t dxl_id, int val );
60  void set_param_drive_mode( uint8_t dxl_id, int val );
61  void set_param_ope_mode( uint8_t dxl_id, int val );
62  void set_param_home_offset( uint8_t dxl_id, int val );
63  void set_param_moving_threshold( uint8_t dxl_id, int val );
64  void set_param_temp_limit( uint8_t dxl_id, int val );
65  void set_param_vol_limit( uint8_t dxl_id, int max, int min );
66  void set_param_current_limit( uint8_t dxl_id, int val );
67  void set_param_vel_gain( uint8_t dxl_id, int p, int i );
68  void set_param_pos_gain_all( int p, int i, int d );
69  void set_param_pos_gain( uint8_t dxl_id, int p, int i, int d );
70 
71  bool is_change_positions( void );
72  void lock_port( void ){ dev_mtx->lock(); }
73  void unlock_port( void ){ dev_mtx->unlock(); }
74  std::string::size_type get_error( std::string& errorlog );
75  bool setup_indirect( uint8_t dxl_id );
76 
77  uint32_t tempCount;
78  std::vector<JOINT_CONTROL> joints;
79 
80 private:
81  uint8_t joint_num;
82  bool port_stat;
93 
94  bool init_stat;
95  uint32_t rx_err;
96  uint32_t tx_err;
98 
100  std::queue<std::string> error_queue;
101 
102  bool check_servo_param( uint8_t dxl_id, uint32_t test_addr, uint8_t equal, uint8_t& read_val );
103  bool check_servo_param( uint8_t dxl_id, uint32_t test_addr, uint16_t equal, uint16_t& read_val );
104  bool check_servo_param( uint8_t dxl_id, uint32_t test_addr, uint32_t equal, uint32_t& read_val );
105 };
106 
107 #endif /* DXLPORT_CONTROL_H */
d
bool param(const std::string &param_name, T &param_val, const T &default_val)
std::queue< std::string > error_queue
dynamixel::GroupBulkRead * readIndirectGroup
DEVICE_MUTEX * dev_mtx
void lock_port(void)
hardware_interface::JointStateInterface joint_stat_if
ros::Duration getDuration(ros::Time t) const
bool get_init_stat(void)
ros::Time getTime() const
ros::Time tempTime
struct HOME_MOTION_DATA ST_HOME_MOTION_DATA
dynamixel::GroupBulkRead * readTempGroup
dynamixel::GroupBulkWrite * writeGoalGroup
int min(int a, int b)
dynamixel::GroupBulkWrite * writePosGoalGroup
hardware_interface::EffortJointInterface joint_eff_if
void unlock_port(void)
static Time now()
hardware_interface::PositionJointInterface joint_pos_if
dynamixel::PacketHandler * packetHandler
std::vector< JOINT_CONTROL > joints
uint8_t get_joint_num(void)
dynamixel::PortHandler * portHandler
joint_limits_interface::PositionJointSoftLimitsInterface joint_limits_if


sciurus17_control
Author(s): Hiroyuki Nomura
autogenerated on Sun Oct 2 2022 02:21:42