gazebo_ros_force_based_move.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Stefan Kohlbrecher, TU Darmstadt
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 /*
19  * Desc: Simple model controller that uses a twist message to exert
20  * forces on a robot, resulting in motion. Based on the
21  * planar_move plugin by Piyush Khandelwal.
22  * Author: Stefan Kohlbrecher
23  * Date: 06 August 2015
24  */
25 
26 #ifndef GAZEBO_ROS_FORCE_BASED_MOVE_HH
27 #define GAZEBO_ROS_FORCE_BASED_MOVE_HH
28 
29 #include <boost/bind.hpp>
30 #include <boost/thread.hpp>
31 #include <map>
32 
33 #include <gazebo/common/common.hh>
34 #include <gazebo/physics/physics.hh>
35 #include <sdf/sdf.hh>
36 
37 #include <geometry_msgs/Twist.h>
38 #include <nav_msgs/OccupancyGrid.h>
39 #include <nav_msgs/Odometry.h>
40 #include <ros/advertise_options.h>
41 #include <ros/callback_queue.h>
42 #include <ros/ros.h>
44 #include <tf/transform_listener.h>
45 
46 namespace gazebo {
47 
48  class GazeboRosForceBasedMove : public ModelPlugin {
49 
50  public:
53  void Load(physics::ModelPtr parent, sdf::ElementPtr sdf);
54 
55  protected:
56  virtual void UpdateChild();
57  virtual void FiniChild();
58 
59  private:
60  void publishOdometry(double step_time);
61 
62  tf::Transform getTransformForMotion(double linear_vel_x, double angular_vel, double timeSeconds) const;
63 
64  physics::ModelPtr parent_;
65  event::ConnectionPtr update_connection_;
66 
68  physics::LinkPtr link_;
69 
71  private: std::string link_name_;
72 
77  nav_msgs::Odometry odom_;
78  std::string tf_prefix_;
79 
81 
82  boost::mutex lock;
83 
84  std::string robot_namespace_;
85  std::string command_topic_;
86  std::string odometry_topic_;
87  std::string odometry_frame_;
88  std::string robot_base_frame_;
91 
92  // Custom Callback Queue
94  boost::thread callback_queue_thread_;
95  void QueueThread();
96 
97  // command velocity callback
98  void cmdVelCallback(const geometry_msgs::Twist::ConstPtr& cmd_msg);
99 
100  double x_;
101  double y_;
102  double rot_;
103  bool alive_;
105 #if (GAZEBO_MAJOR_VERSION >= 8)
106  ignition::math::Pose3d last_odom_pose_;
107 #else
108  math::Pose last_odom_pose_;
109 #endif
110 
114 
115  };
116 
117 }
118 
119 #endif /* end of include guard: GAZEBO_ROS_PLANAR_MOVE_HH */
boost::shared_ptr< ros::NodeHandle > rosnode_
physics::LinkPtr link_
A pointer to the Link, where force is applied.
std::string link_name_
The Link this plugin is attached to, and will exert forces on.
tf::Transform getTransformForMotion(double linear_vel_x, double angular_vel, double timeSeconds) const
void Load(physics::ModelPtr parent, sdf::ElementPtr sdf)
boost::shared_ptr< tf::TransformBroadcaster > transform_broadcaster_
void cmdVelCallback(const geometry_msgs::Twist::ConstPtr &cmd_msg)


hector_gazebo_plugins
Author(s): Stefan Kohlbrecher , Johannes Meyer
autogenerated on Wed Jun 5 2019 22:40:23