odometry.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, PAL Robotics, S.L.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the PAL Robotics nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /*
36  * Author: Luca Marchionni
37  * Author: Bence Magyar
38  * Author: Enrique Fernández
39  * Author: Paul Mathieu
40  *
41  * Author: Braden McDorman (Semio AI, Inc.)
42  */
43 
44 #pragma once
45 
46 
47 #include <ros/time.h>
48 #include <boost/accumulators/accumulators.hpp>
49 #include <boost/accumulators/statistics/stats.hpp>
50 #include <boost/accumulators/statistics/rolling_mean.hpp>
51 #include <boost/function.hpp>
52 
54 {
55  namespace bacc = boost::accumulators;
56 
61  class Odometry
62  {
63  public:
64 
66  typedef boost::function<void(double, double)> IntegrationFunction;
67 
74  Odometry(size_t velocity_rolling_window_size = 10);
75 
80  void init(const ros::Time &time);
81 
89  bool update(double left_pos, double right_pos, const ros::Time &time);
90 
97  void updateOpenLoop(double linear, double angular, const ros::Time &time);
98 
103  double getHeading() const
104  {
105  return heading_;
106  }
107 
112  double getX() const
113  {
114  return x_;
115  }
116 
121  double getY() const
122  {
123  return y_;
124  }
125 
130  double getLinear() const
131  {
132  return linear_;
133  }
134 
139  double getAngular() const
140  {
141  return angular_;
142  }
143 
150  void setWheelParams(double wheel_separation, double left_wheel_radius, double right_wheel_radius);
151 
156  void setVelocityRollingWindowSize(size_t velocity_rolling_window_size);
157 
158  private:
159 
161  typedef bacc::accumulator_set<double, bacc::stats<bacc::tag::rolling_mean> > RollingMeanAcc;
162  typedef bacc::tag::rolling_window RollingWindow;
163 
169  void integrateRungeKutta2(double linear, double angular);
170 
176  void integrateExact(double linear, double angular);
177 
181  void resetAccumulators();
182 
185 
187  double x_; // [m]
188  double y_; // [m]
189  double heading_; // [rad]
190 
192  double linear_; // [m/s]
193  double angular_; // [rad/s]
194 
196  double wheel_separation_;
197  double left_wheel_radius_;
198  double right_wheel_radius_;
199 
201  double left_wheel_old_pos_;
202  double right_wheel_old_pos_;
203 
208 
211  };
212 }
quori_holonomic_drive_controller::Odometry::RollingMeanAcc
bacc::accumulator_set< double, bacc::stats< bacc::tag::rolling_mean > > RollingMeanAcc
Rolling mean accumulator and window:
Definition: odometry.hpp:225
quori_holonomic_drive_controller::Odometry::right_wheel_radius_
double right_wheel_radius_
Definition: odometry.hpp:262
quori_holonomic_drive_controller::Odometry::angular_acc_
RollingMeanAcc angular_acc_
Definition: odometry.hpp:271
quori_holonomic_drive_controller::Odometry::angular_
double angular_
Definition: odometry.hpp:257
quori_holonomic_drive_controller::Odometry::integrateExact
void integrateExact(double linear, double angular)
Integrates the velocities (linear and angular) using exact method.
Definition: odometry.cpp:157
quori_holonomic_drive_controller::Odometry::velocity_rolling_window_size_
size_t velocity_rolling_window_size_
Rolling mean accumulators for the linar and angular velocities:
Definition: odometry.hpp:269
quori_holonomic_drive_controller::Odometry::Odometry
Odometry(size_t velocity_rolling_window_size=10)
Constructor Timestamp will get the current time value Value will be set to zero.
Definition: odometry.cpp:52
time.h
quori_holonomic_drive_controller::Odometry::right_wheel_old_pos_
double right_wheel_old_pos_
Definition: odometry.hpp:266
quori_holonomic_drive_controller::Odometry::left_wheel_old_pos_
double left_wheel_old_pos_
Previou wheel position/state [rad]:
Definition: odometry.hpp:265
quori_holonomic_drive_controller::Odometry::integrateRungeKutta2
void integrateRungeKutta2(double linear, double angular)
Integrates the velocities (linear and angular) using 2nd order Runge-Kutta.
Definition: odometry.cpp:142
quori_holonomic_drive_controller::Odometry::init
void init(const ros::Time &time)
Initialize the odometry.
Definition: odometry.cpp:71
quori_holonomic_drive_controller::Odometry::getAngular
double getAngular() const
angular velocity getter
Definition: odometry.hpp:203
quori_holonomic_drive_controller::Odometry::heading_
double heading_
Definition: odometry.hpp:253
quori_holonomic_drive_controller::Odometry::RollingWindow
bacc::tag::rolling_window RollingWindow
Definition: odometry.hpp:226
quori_holonomic_drive_controller
Definition: holonomic.hpp:5
quori_holonomic_drive_controller::Odometry::updateOpenLoop
void updateOpenLoop(double linear, double angular, const ros::Time &time)
Updates the odometry class with latest velocity command.
Definition: odometry.cpp:116
quori_holonomic_drive_controller::Odometry::resetAccumulators
void resetAccumulators()
Reset linear and angular accumulators.
Definition: odometry.cpp:172
quori_holonomic_drive_controller::Odometry::linear_
double linear_
Current velocity:
Definition: odometry.hpp:256
quori_holonomic_drive_controller::Odometry::update
bool update(double left_pos, double right_pos, const ros::Time &time)
Updates the odometry class with latest wheels position.
Definition: odometry.cpp:78
quori_holonomic_drive_controller::Odometry::IntegrationFunction
boost::function< void(double, double)> IntegrationFunction
Integration function, used to integrate the odometry:
Definition: odometry.hpp:130
quori_holonomic_drive_controller::Odometry::getHeading
double getHeading() const
heading getter
Definition: odometry.hpp:167
quori_holonomic_drive_controller::Odometry::wheel_separation_
double wheel_separation_
Wheel kinematic parameters [m]:
Definition: odometry.hpp:260
quori_holonomic_drive_controller::Odometry::setWheelParams
void setWheelParams(double wheel_separation, double left_wheel_radius, double right_wheel_radius)
Sets the wheel parameters: radius and separation.
Definition: odometry.cpp:128
ros::Time
quori_holonomic_drive_controller::Odometry::getY
double getY() const
y position getter
Definition: odometry.hpp:185
quori_holonomic_drive_controller::Odometry::timestamp_
ros::Time timestamp_
Current timestamp:
Definition: odometry.hpp:248
quori_holonomic_drive_controller::Odometry::x_
double x_
Current pose:
Definition: odometry.hpp:251
quori_holonomic_drive_controller::Odometry::getLinear
double getLinear() const
linear velocity getter
Definition: odometry.hpp:194
quori_holonomic_drive_controller::Odometry::y_
double y_
Definition: odometry.hpp:252
quori_holonomic_drive_controller::Odometry::linear_acc_
RollingMeanAcc linear_acc_
Definition: odometry.hpp:270
quori_holonomic_drive_controller::Odometry::left_wheel_radius_
double left_wheel_radius_
Definition: odometry.hpp:261
quori_holonomic_drive_controller::Odometry::getX
double getX() const
x position getter
Definition: odometry.hpp:176
quori_holonomic_drive_controller::Odometry::setVelocityRollingWindowSize
void setVelocityRollingWindowSize(size_t velocity_rolling_window_size)
Velocity rolling window size setter.
Definition: odometry.cpp:135
quori_holonomic_drive_controller::Odometry::integrate_fun_
IntegrationFunction integrate_fun_
Integration funcion, used to integrate the odometry:
Definition: odometry.hpp:274


quori_holonomic_drive_controller
Author(s):
autogenerated on Wed Mar 2 2022 00:53:24