omni_motion_controller.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16 Authors:
17 
18 Oscar Lima Carrion, olima_84@yahoo.com
19 Ashok Meenakshi, mashoksc@gmail.com
20 Seguey Alexandrov, sergeyalexandrov@mail.com
21 
22 Review / Edits:
23 Manos Tsardoulias, etsardou@gmail.com
24 
25 About this code:
26 
27 This class represents a motion model for omnidirectional robot and could be
28 used to sample the possible pose given the starting pose and the commanded
29 robot's motion.
30 T
31 he motion is decomposed into two translations alond the x axis of the
32 robot (forward), and along the y axis of the robot (lateral), and one
33 rotation.
34 ******************************************************************************/
35 
37 
38 namespace stdr_robot {
39 
49  const geometry_msgs::Pose2D& pose,
51  ros::NodeHandle& n,
52  const std::string& name,
53  const stdr_msgs::KinematicMsg params)
54  : MotionController(pose, tf, name, n, params)
55  {
57  _freq,
59  this);
60  }
61 
62 
69  {
71 
72  ros::Duration dt = ros::Time::now() - event.last_real;
73 
74  // Simple omni model
75  // TODO: Add kinematic model uncertainties
76  if (_currentTwist.angular.z != 0 || _currentTwist.linear.x != 0 ||
77  _currentTwist.linear.y != 0)
78  {
79  // Dx and Dy takes under consideration both linear rotations,
80  // independently of each other
81  _pose.x +=
82  _currentTwist.linear.x * dt.toSec() * cosf(_pose.theta) +
83  _currentTwist.linear.y * dt.toSec() * cosf(_pose.theta + M_PI/2.0);
84 
85  _pose.y +=
86  _currentTwist.linear.y * dt.toSec() * sinf(_pose.theta + M_PI/2.0) +
87  _currentTwist.linear.x * dt.toSec() * sinf(_pose.theta);
88 
89  _pose.theta += _currentTwist.angular.z * dt.toSec();
90  }
91  }
92 
98  {
99 
100  }
101 
102 }
ros::Duration _freq
ROS timer for generating motion calculation events.
ros::Timer _calcTimer
Broadcaster of the robot tf transform.
The main namespace for STDR Robot.
Definition: exceptions.h:27
geometry_msgs::Pose2D _pose
Current motion command.
geometry_msgs::Twist _currentTwist
The kinematic model parameters.
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void calculateMotion(const ros::TimerEvent &event)
Calculates the motion - updates the robot pose.
Abstract class that provides motion controller abstraction.
OmniMotionController(const geometry_msgs::Pose2D &pose, tf::TransformBroadcaster &tf, ros::NodeHandle &n, const std::string &name, const stdr_msgs::KinematicMsg params)
Default constructor.
static Time now()
~OmniMotionController(void)
Default destructor.


stdr_robot
Author(s): Manos Tsardoulias, Chris Zalidis, Aris Thallas
autogenerated on Mon Jun 10 2019 15:15:10