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


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14