odometry.h
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 
42 #ifndef ODOMETRY_H_
43 #define ODOMETRY_H_
44 
45 #include <ros/time.h>
46 #include <boost/accumulators/accumulators.hpp>
47 #include <boost/accumulators/statistics/stats.hpp>
48 #include <boost/accumulators/statistics/rolling_mean.hpp>
49 #include <boost/function.hpp>
50 
52 {
53 
54 namespace bacc = boost::accumulators;
55 
60 class Odometry
61 {
62 public:
63 
65  typedef boost::function<void(double, double, double)> IntegrationFunction;
66 
73  Odometry(size_t velocity_rolling_window_size = 10);
74 
79  void init(const ros::Time &time);
80 
90  bool update(double wheel0_vel, double wheel1_vel, double wheel2_vel, double wheel3_vel, const ros::Time &time);
91 
98  void updateOpenLoop(double linearX, double linearY, double angular, const ros::Time &time);
99 
104  double getHeading() const
105  {
106  return heading_;
107  }
108 
113  double getX() const
114  {
115  return x_;
116  }
117 
122  double getY() const
123  {
124  return y_;
125  }
126 
131  double getLinearX() const
132  {
133  return linearX_;
134  }
135 
140  double getLinearY() const
141  {
142  return linearY_;
143  }
144 
149  double getAngular() const
150  {
151  return angular_;
152  }
153 
159  void setWheelsParams(double wheels_k, double wheels_radius);
160 
161 private:
162 
164  typedef bacc::accumulator_set<double, bacc::stats<bacc::tag::rolling_mean> > RollingMeanAcc;
165  typedef bacc::tag::rolling_window RollingWindow;
166 
173  void integrateExact(double linearX, double linearY, double angular);
174 
177 
179  double x_; // [m]
180  double y_; // [m]
181  double heading_; // [rad]
182 
184  double linearX_; // [m/s]
185  double linearY_; // [m/s]
186  double angular_; // [rad/s]
187 
189  double wheels_k_;
191 
194  RollingMeanAcc linearX_acc_;
195  RollingMeanAcc linearY_acc_;
196  RollingMeanAcc angular_acc_;
197 
199  IntegrationFunction integrate_fun_;
200 };
201 
202 } // namespace mecanum_drive_controller
203 
204 #endif /* ODOMETRY_H_ */
void setWheelsParams(double wheels_k, double wheels_radius)
Sets the wheels parameters: mecanum geometric param and radius.
Definition: odometry.cpp:124
double getLinearX() const
linearX velocity getter
Definition: odometry.h:131
void integrateExact(double linearX, double linearY, double angular)
Integrates the velocities (linear and angular) using exact method.
Definition: odometry.cpp:132
IntegrationFunction integrate_fun_
Integration funcion, used to integrate the odometry:
Definition: odometry.h:199
size_t velocity_rolling_window_size_
Rolling mean accumulators for the linar and angular velocities:
Definition: odometry.h:193
double getY() const
y position getter
Definition: odometry.h:122
double linearX_
Current velocity:
Definition: odometry.h:184
double getLinearY() const
linearY velocity getter
Definition: odometry.h:140
double x_
Current pose:
Definition: odometry.h:179
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:54
void updateOpenLoop(double linearX, double linearY, double angular, const ros::Time &time)
Updates the odometry class with latest velocity command.
Definition: odometry.cpp:110
double getAngular() const
angular velocity getter
Definition: odometry.h:149
double getHeading() const
heading getter
Definition: odometry.h:104
void init(const ros::Time &time)
Initialize the odometry.
Definition: odometry.cpp:73
bacc::tag::rolling_window RollingWindow
Definition: odometry.h:165
double wheels_k_
Wheels kinematic parameters [m]:
Definition: odometry.h:189
boost::function< void(double, double, double)> IntegrationFunction
Integration function, used to integrate the odometry:
Definition: odometry.h:65
double getX() const
x position getter
Definition: odometry.h:113
bool update(double wheel0_vel, double wheel1_vel, double wheel2_vel, double wheel3_vel, const ros::Time &time)
Updates the odometry class with latest wheels position.
Definition: odometry.cpp:85
ros::Time timestamp_
Current timestamp:
Definition: odometry.h:176
The Odometry class handles odometry readings (2D pose and velocity with related timestamp) ...
Definition: odometry.h:60
bacc::accumulator_set< double, bacc::stats< bacc::tag::rolling_mean > > RollingMeanAcc
Rolling mean accumulator and window:
Definition: odometry.h:164


ridgeback_control
Author(s): Mike Purvis
autogenerated on Thu Mar 5 2020 03:31:54