Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #ifndef KOBUKI_DIFF_DRIVE_HPP_
00014 #define KOBUKI_DIFF_DRIVE_HPP_
00015
00016
00017
00018
00019
00020 #include <vector>
00021 #include <climits>
00022 #include <stdint.h>
00023 #include <ecl/geometry/legacy_pose2d.hpp>
00024 #include <ecl/mobile_robot.hpp>
00025 #include <ecl/threads/mutex.hpp>
00026 #include "../macros.hpp"
00027
00028
00029
00030
00031
00032 namespace kobuki {
00033
00034
00035
00036
00037
00038 class kobuki_PUBLIC DiffDrive {
00039 public:
00040 DiffDrive();
00041 const ecl::DifferentialDrive::Kinematics& kinematics() { return diff_drive_kinematics; }
00042 void update(const uint16_t &time_stamp,
00043 const uint16_t &left_encoder,
00044 const uint16_t &right_encoder,
00045 ecl::LegacyPose2D<double> &pose_update,
00046 ecl::linear_algebra::Vector3d &pose_update_rates);
00047 void reset();
00048 void getWheelJointStates(double &wheel_left_angle, double &wheel_left_angle_rate,
00049 double &wheel_right_angle, double &wheel_right_angle_rate);
00050 void setVelocityCommands(const double &vx, const double &wz);
00051 void velocityCommands(const double &vx, const double &wz);
00052 void velocityCommands(const short &cmd_speed, const short &cmd_radius);
00053 void velocityCommands(const std::vector<double> &cmd) { velocityCommands(cmd[0], cmd[1]); }
00054 void velocityCommands(const std::vector<short> &cmd) { velocityCommands(cmd[0], cmd[1]); }
00055
00056
00057
00058
00059 std::vector<short> velocityCommands();
00060 std::vector<double> pointVelocity() const;
00061
00062
00063
00064
00065 double wheel_bias() const { return bias; }
00066
00067 private:
00068 unsigned short last_timestamp;
00069 double last_velocity_left, last_velocity_right;
00070 double last_diff_time;
00071
00072 unsigned short last_tick_left, last_tick_right;
00073 double last_rad_left, last_rad_right;
00074
00075
00076 std::vector<double> point_velocity;
00077 double radius;
00078 double speed;
00079 double bias;
00080 double wheel_radius;
00081 int imu_heading_offset;
00082 const double tick_to_rad;
00083
00084 ecl::DifferentialDrive::Kinematics diff_drive_kinematics;
00085 ecl::Mutex velocity_mutex, state_mutex;
00086
00087
00088 short bound(const double &value);
00089 };
00090
00091 }
00092
00093 #endif