14 #include "../../include/xbot_driver/modules/diff_drive.hpp" 26 : last_velocity_left(0.0),
27 last_velocity_right(0.0),
33 angular_velocity(0.0),
35 point_velocity(2, 0.0),
41 diff_drive_kinematics(
bias, wheel_radius) {}
55 const uint16_t &left_encoder,
56 const uint16_t &right_encoder,
58 ecl::linear_algebra::Vector3d &pose_update_rates) {
60 static bool init_l =
false;
61 static bool init_r =
false;
62 float left_diff_ticks = 0.0f;
63 float right_diff_ticks = 0.0f;
64 unsigned short curr_tick_left = 0;
65 unsigned short curr_tick_right = 0;
67 unsigned int curr_timestamp = 0;
68 curr_timestamp = time_stamp;
69 curr_tick_left = left_encoder;
74 left_diff_ticks = (float)(
short)((curr_tick_left -
last_tick_left) & 0xffff);
78 curr_tick_right = right_encoder;
123 float &wheel_left_angle_rate,
124 float &wheel_right_angle,
125 float &wheel_right_angle_rate) {
137 std::vector<float> cmd_vel;
138 cmd_vel.push_back(vx);
139 cmd_vel.push_back(wz);
157 std::vector<float> cmd(2);
166 if (value > static_cast<float>(SHRT_MAX))
return SHRT_MAX;
167 if (value < static_cast<float>(SHRT_MIN))
return SHRT_MIN;
168 return static_cast<short>(value);
unsigned short last_tick_left
std::vector< float > point_velocity
std::vector< float > velocityCommands()
void update(const unsigned int &time_stamp, const uint16_t &left_encoder, const uint16_t &right_encoder, ecl::Pose2D< double > &pose_update, ecl::linear_algebra::Vector3d &pose_update_rates)
Updates the odometry from firmware stamps and encoders.
std::vector< float > pointVelocity() const
unsigned int last_timestamp
void getWheelJointStates(float &wheel_left_angle, float &wheel_left_angle_rate, float &wheel_right_angle, float &wheel_right_angle_rate)
unsigned short last_tick_right
ecl::DifferentialDrive::Kinematics diff_drive_kinematics
void setVelocityCommands(const float &vx, const float &wz)
short bound(const float &value)
float last_velocity_right
ecl::Mutex velocity_mutex
void f(int i) ecl_debug_throw_decl(StandardException)