37 #include <boost/bind.hpp> 41 namespace bacc = boost::accumulators;
44 : last_update_timestamp_(0.0)
52 , steering_track_(0.0)
53 , wheel_steering_y_offset_(0.0)
57 , velocity_rolling_window_size_(velocity_rolling_window_size)
58 , linear_accel_acc_(
RollingWindow::window_size = velocity_rolling_window_size)
59 , linear_jerk_acc_(
RollingWindow::window_size = velocity_rolling_window_size)
60 , front_steer_vel_acc_(
RollingWindow::window_size = velocity_rolling_window_size)
61 , rear_steer_vel_acc_(
RollingWindow::window_size = velocity_rolling_window_size)
73 const double &rl_speed,
const double &rr_speed,
74 double front_steering,
double rear_steering,
const ros::Time &time)
76 const double front_tmp = cos(front_steering)*(tan(front_steering)-tan(rear_steering))/
wheel_base_;
77 const double front_left_tmp = front_tmp/sqrt(1-
steering_track_*front_tmp*cos(front_steering)
79 const double front_right_tmp = front_tmp/sqrt(1+
steering_track_*front_tmp*cos(front_steering)
83 const double front_linear_speed =
wheel_radius_ * copysign(1.0, fl_speed_tmp+fr_speed_tmp)*
84 sqrt((pow(fl_speed,2)+pow(fr_speed,2))/(2+pow(
steering_track_*front_tmp,2)/2.0));
86 const double rear_tmp = cos(rear_steering)*(tan(front_steering)-tan(rear_steering))/
wheel_base_;
87 const double rear_left_tmp = rear_tmp/sqrt(1-
steering_track_*rear_tmp*cos(rear_steering)
89 const double rear_right_tmp = rear_tmp/sqrt(1+
steering_track_*rear_tmp*cos(rear_steering)
93 const double rear_linear_speed =
wheel_radius_ * copysign(1.0, rl_speed_tmp+rr_speed_tmp)*
94 sqrt((pow(rl_speed_tmp,2)+pow(rr_speed_tmp,2))/(2+pow(
steering_track_*rear_tmp,2)/2.0));
96 angular_ = (front_linear_speed*front_tmp + rear_linear_speed*rear_tmp)/2.0;
98 linear_x_ = (front_linear_speed*cos(front_steering) + rear_linear_speed*cos(rear_steering))/2.0;
150 const double direction =
heading_ + angular * 0.5;
153 x_ += linear * cos(direction);
154 y_ += linear * sin(direction);
160 if (fabs(angular) < 1e-6)
165 const double heading_old =
heading_;
166 const double r = linear/angular;
169 y_ += -r * (cos(
heading_) - cos(heading_old));
void setVelocityRollingWindowSize(size_t velocity_rolling_window_size)
Velocity rolling window size setter.
size_t velocity_rolling_window_size_
Rolling mean accumulators for the linar and angular velocities:
RollingMeanAcc linear_accel_acc_
RollingMeanAcc rear_steer_vel_acc_
double front_steer_vel_prev_
double wheel_steering_y_offset_
Odometry(size_t velocity_rolling_window_size=10)
Constructor Timestamp will get the current time value Value will be set to zero.
RollingMeanAcc front_steer_vel_acc_
ros::Time last_update_timestamp_
Current timestamp:
bool update(const double &fl_speed, const double &fr_speed, const double &rl_speed, const double &rr_speed, double front_steering, double rear_steering, const ros::Time &time)
Updates the odometry class with latest wheels and steerings position.
double linear_
Current velocity:
bacc::tag::rolling_window RollingWindow
double linear_accel_prev_
void setWheelParams(double steering_track, double wheel_steering_y_offset, double wheel_radius, double wheel_base)
Sets the wheel parameters: radius and separation.
void integrateXY(double linear_x, double linear_y, double angular)
Integrates the velocities (linear on x and y and angular)
void resetAccumulators()
Reset linear and angular accumulators.
double rear_steer_vel_prev_
bacc::accumulator_set< double, bacc::stats< bacc::tag::rolling_mean > > RollingMeanAcc
Rolling mean accumulator and window:
void integrateRungeKutta2(double linear, double angular)
Integrates the velocities (linear and angular) using 2nd order Runge-Kutta.
void init(const ros::Time &time)
Initialize the odometry.
double steering_track_
Wheel kinematic parameters [m]:
RollingMeanAcc linear_jerk_acc_
void integrateExact(double linear, double angular)
Integrates the velocities (linear and angular) using exact method.