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>
23 #include <ecl/geometry/legacy_pose2d.hpp>
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 
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;
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]
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_ */
ecl::Mutex velocity_mutex
Definition: diff_drive.hpp:85
void velocityCommands(const std::vector< short > &cmd)
Definition: diff_drive.hpp:54
std::vector< double > point_velocity
Definition: diff_drive.hpp:76
void velocityCommands(const std::vector< double > &cmd)
Definition: diff_drive.hpp:53
double wheel_bias() const
Definition: diff_drive.hpp:65
#define kobuki_PUBLIC
Definition: macros.hpp:39
const double tick_to_rad
Definition: diff_drive.hpp:82
ecl::DifferentialDrive::Kinematics diff_drive_kinematics
Definition: diff_drive.hpp:84
double bias
const ecl::DifferentialDrive::Kinematics & kinematics()
Definition: diff_drive.hpp:41
unsigned short last_timestamp
Definition: diff_drive.hpp:68
unsigned short last_tick_right
Definition: diff_drive.hpp:72
double last_velocity_right
Definition: diff_drive.hpp:69


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Mar 27 2017 01:02:59