odometry.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2013, PAL Robotics, S.L.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the PAL Robotics nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /*
00036  * Author: Luca Marchionni
00037  * Author: Bence Magyar
00038  */
00039 
00040 #ifndef ODOMETRY_H_
00041 #define ODOMETRY_H_
00042 
00043 #include <ros/time.h>
00044 #include <boost/accumulators/accumulators.hpp>
00045 #include <boost/accumulators/statistics/stats.hpp>
00046 #include <boost/accumulators/statistics/rolling_mean.hpp>
00047 #include <boost/function.hpp>
00048 
00049 namespace diff_drive_controller
00050 {
00051   namespace bacc = boost::accumulators;
00052 
00057   class Odometry
00058   {
00059   public:
00060 
00062     typedef boost::function<void(double, double)> IntegrationFunction;
00063 
00070     Odometry(size_t velocity_rolling_window_size = 10);
00071 
00079     bool update(double left_pos, double right_pos, const ros::Time &time);
00080 
00085     double getHeading() const
00086     {
00087       return heading_;
00088     }
00089 
00094     double getX() const
00095     {
00096       return x_;
00097     }
00098 
00103     double getY() const
00104     {
00105       return y_;
00106     }
00107 
00112     ros::Time getTimestamp() const
00113     {
00114       return timestamp_;
00115     }
00116 
00121     double getLinearEstimated() const;
00122 
00127     double getAngularEstimated() const;
00128 
00134     void setWheelParams(double wheel_separation, double wheel_radius);
00135 
00136   private:
00137 
00139     typedef bacc::accumulator_set<double, bacc::stats<bacc::tag::rolling_mean> > RollingMeanAcc;
00140     typedef bacc::tag::rolling_window RollingWindow;
00141 
00147     void integrateRungeKutta2(double linear, double angular);
00148 
00154     void integrateExact(double linear, double angular);
00155 
00157     ros::Time timestamp_;
00158 
00160     double x_;        //   [m]
00161     double y_;        //   [m]
00162     double heading_;  // [rad]
00163 
00165     double wheel_separation_;
00166     double wheel_radius_;
00167 
00169     double left_wheel_old_pos_;
00170     double right_wheel_old_pos_;
00171 
00173     RollingMeanAcc linear_acc_;
00174     RollingMeanAcc angular_acc_;
00175 
00177     IntegrationFunction integrate_fun_;
00178   };
00179 }
00180 
00181 #endif /* ODOMETRY_H_ */


diff_drive_controller
Author(s): Bence Magyar
autogenerated on Fri Aug 28 2015 12:36:51