mecanum_drive_controller.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: Enrique Fernández
37  */
38 
42 
43 #include <nav_msgs/Odometry.h>
44 #include <tf/tfMessage.h>
45 
48 
51 
53 {
54 
65  : public controller_interface::Controller<hardware_interface::VelocityJointInterface>
66 {
67 public:
69 
77  ros::NodeHandle& root_nh,
78  ros::NodeHandle &controller_nh);
79 
85  void update(const ros::Time& time, const ros::Duration& period);
86 
91  void starting(const ros::Time& time);
92 
97  void stopping(const ros::Time& time);
98 
99 private:
100  std::string name_;
101 
106 
112 
114  struct Commands
115  {
116  double linX;
117  double linY;
118  double ang;
120 
121  Commands() : linX(0.0), linY(0.0), ang(0.0), stamp(0.0) {}
122  };
126 
131  geometry_msgs::TransformStamped odom_frame_;
132 
135  double wheels_k_; // wheels geometric param used in mecanum wheels' ik
139 
142 
144  std::string base_frame_id_;
145  std::string odom_frame_id_;
146 
149 
152 
153  // Speed limiters:
158 
159 private:
163  void brake();
164 
169  void cmdVelCallback(const geometry_msgs::Twist& command);
170 
180  ros::NodeHandle &controller_nh,
181  const std::string& wheel0_name,
182  const std::string& wheel1_name,
183  const std::string& wheel2_name,
184  const std::string& wheel3_name);
185 
192  bool getWheelRadius(const urdf::ModelInterfaceSharedPtr model, const urdf::LinkConstSharedPtr& wheel_link, double& wheel_radius);
193 
199  void setupRtPublishersMsg(ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh);
200 
201 };
202 
204 
205 } // namespace mecanum_drive_controller
double cmd_vel_timeout_
Timeout to consider cmd_vel commands old:
void update(const ros::Time &time, const ros::Duration &period)
Updates controller, i.e. computes the odometry and sets the new velocity commands.
realtime_tools::RealtimeBuffer< Commands > command_
bool getWheelRadius(const urdf::ModelInterfaceSharedPtr model, const urdf::LinkConstSharedPtr &wheel_link, double &wheel_radius)
Get the radius of a given wheel.
void brake()
Brakes the wheels, i.e. sets the velocity to 0.
boost::shared_ptr< realtime_tools::RealtimePublisher< tf::tfMessage > > tf_odom_pub_
void starting(const ros::Time &time)
Starts controller.
void setupRtPublishersMsg(ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh)
Sets the odometry publishing fields.
bool setWheelParamsFromUrdf(ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh, const std::string &wheel0_name, const std::string &wheel1_name, const std::string &wheel2_name, const std::string &wheel3_name)
Sets odometry parameters from the URDF, i.e. the wheel radius and separation.
boost::shared_ptr< realtime_tools::RealtimePublisher< nav_msgs::Odometry > > odom_pub_
Odometry related:
void stopping(const ros::Time &time)
Stops controller.
bool use_realigned_roller_joints_
Wheel radius (assuming it&#39;s the same for the left and right wheels):
void cmdVelCallback(const geometry_msgs::Twist &command)
Velocity command callback.
bool init(hardware_interface::VelocityJointInterface *hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh)
Initialize controller.
hardware_interface::JointHandle wheel0_jointHandle_
Hardware handles:
std::string base_frame_id_
Frame to use for the robot base:
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
The Odometry class handles odometry readings (2D pose and velocity with related timestamp) ...
Definition: odometry.h:60
bool enable_odom_tf_
Whether to publish odometry to tf or not:


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