diff_drive.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Ifdefs
11 *****************************************************************************/
12 
13 #ifndef XBOT_DIFF_DRIVE_HPP_
14 #define XBOT_DIFF_DRIVE_HPP_
15 
16 /*****************************************************************************
17 ** Includes
18 *****************************************************************************/
19 
20 #include <vector>
21 #include <climits>
22 #include <stdint.h>
23 #include <ecl/mobile_robot.hpp>
24 #include <ecl/threads/mutex.hpp>
25 #include "../macros.hpp"
26 
27 /*****************************************************************************
28 ** Namespaces
29 *****************************************************************************/
30 
31 namespace xbot {
32 
33 /*****************************************************************************
34 ** Interfaces
35 *****************************************************************************/
36 
38 public:
39  DiffDrive();
40  const ecl::DifferentialDrive::Kinematics& kinematics() { return diff_drive_kinematics; }
41  void update(const unsigned int &time_stamp,
42  const uint16_t &left_encoder,
43  const uint16_t &right_encoder,
44  ecl::Pose2D<double> &pose_update,
45  ecl::linear_algebra::Vector3d &pose_update_rates);
46  void reset();
47  void getWheelJointStates(float &wheel_left_angle, float &wheel_left_angle_rate,
48  float &wheel_right_angle, float &wheel_right_angle_rate);
49  void setVelocityCommands(const float &vx, const float &wz);
50  void velocityCommands(const float &vx, const float &wz);
51  void velocityCommands(const std::vector<float> &cmd) { velocityCommands(cmd[0], cmd[1]); }
52 
53  /*********************
54  ** Command Accessors
55  **********************/
56  std::vector<float> velocityCommands(); // (speed, radius), in [mm/s] and [mm]
57  std::vector<float> pointVelocity() const; // (vx, wz), in [m/s] and [rad/s]
58 
59  /*********************
60  ** Property Accessors
61  **********************/
62  float wheel_bias() const { return bias; }
63 
64 private:
65  unsigned int last_timestamp;
66  float last_velocity_left, last_velocity_right;
68 
69  unsigned short last_tick_left, last_tick_right;
70  float last_rad_left, last_rad_right;
71 
72  //float v, w; // in [m/s] and [rad/s]
73  std::vector<float> point_velocity; // (vx, wz), in [m/s] and [rad/s]
74  float angular_velocity; // in [m/s]
75  float linear_velocity; // in [rad/s]
76  float bias; //wheelbase, wheel_to_wheel, in [m]
77  float wheel_radius; // in [m]
79  const float tick_to_rad;
80 
82  ecl::Mutex velocity_mutex, state_mutex;
83 
84  // Utility
85  short bound(const float &value);
86 };
87 
88 } // namespace xbot
89 
90 #endif /* XBOT_DIFF_DRIVE_HPP_ */
std::vector< float > point_velocity
Definition: diff_drive.hpp:73
float angular_velocity
Definition: diff_drive.hpp:74
float last_rad_right
Definition: diff_drive.hpp:70
unsigned int last_timestamp
Definition: diff_drive.hpp:65
#define xbot_PUBLIC
unsigned short last_tick_right
Definition: diff_drive.hpp:69
ecl::DifferentialDrive::Kinematics diff_drive_kinematics
Definition: diff_drive.hpp:81
float last_diff_time
Definition: diff_drive.hpp:67
mobile_robot::DifferentialDriveKinematics Kinematics
float linear_velocity
Definition: diff_drive.hpp:75
float wheel_bias() const
Definition: diff_drive.hpp:62
void velocityCommands(const std::vector< float > &cmd)
Definition: diff_drive.hpp:51
float last_velocity_right
Definition: diff_drive.hpp:66
double bias
const float tick_to_rad
Definition: diff_drive.hpp:79
ecl::Mutex velocity_mutex
Definition: diff_drive.hpp:82
Definition: command.hpp:30
const ecl::DifferentialDrive::Kinematics & kinematics()
Definition: diff_drive.hpp:40


xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:37