Tetrapod Project
footstep_planner_plugin.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Gazebo
4 #include <gazebo/gazebo.hh>
5 #include <gazebo/physics/physics.hh>
6 #include <gazebo/common/common.hh>
7 #include <gazebo/gazebo_client.hh>
8 #include <gazebo/transport/transport.hh>
9 #include <gazebo/msgs/msgs.hh>
10 
11 #include "ros/ros.h"
12 #include "ros/package.h"
13 #include "ros/console.h"
14 #include "ros/callback_queue.h"
15 #include "ros/subscribe_options.h"
16 #include "eigen_conversions/eigen_msg.h"
17 #include "geometry_msgs/PoseArray.h"
20 #include<string>
21 #include<vector>
22 #include<iostream>
23 #include<Eigen/Core>
24 #include <ignition/math.hh>
25 
26 namespace gazebo{
27 
28 
29 class FootstepPlannerPlugin : public WorldPlugin
30 {
31  public: FootstepPlannerPlugin();
32 
33  public: virtual ~FootstepPlannerPlugin();
34 
40  public: virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf);
41 
42  public: void UpdateFootstepPlan(const geometry_msgs::PoseArray::ConstPtr& msg);
43 
44  public: void InitRos();
45 
46  public: void InitRosQueueThreads();
47 
48  public: void ProcessQueueThread();
49 
50  public: void InitGazebo();
51 
52  public: void DeleteVisuals();
53 
54  public: void SetVisuals(Eigen::MatrixX3d &poses);
55 
56  public: void PublishVisuals();
57 
59  private: physics::WorldPtr world;
60 
62  private: std::unique_ptr<ros::NodeHandle> rosNode;
63 
64  private: ros::Subscriber footstepPlannerSub;
65 
67  private: ros::CallbackQueue rosProcessQueue;
68 
70  private: std::thread rosProcessQueueThread;
71 
72  private: Eigen::Matrix<msgs::Visual, Eigen::Dynamic, 1> indicators;
73 
74  private: transport::PublisherPtr indicatorPub;
75 
76  private: transport::NodePtr gazeboNode;
77 };
78 
79  // Tell Gazebo about this plugin, so that Gazebo can call Load on this plugin.
80 GZ_REGISTER_WORLD_PLUGIN(FootstepPlannerPlugin)
81 }
physics::WorldPtr world
Pointer to the world.
transport::PublisherPtr indicatorPub
void UpdateFootstepPlan(const geometry_msgs::PoseArray::ConstPtr &msg)
std::unique_ptr< ros::NodeHandle > rosNode
Node used for ROS transport.
std::thread rosProcessQueueThread
Thread running the rosProcessQueue.
void SetVisuals(Eigen::MatrixX3d &poses)
Eigen::Matrix< msgs::Visual, Eigen::Dynamic, 1 > indicators
ros::CallbackQueue rosProcessQueue
ROS callbackque that helps process messages.
virtual void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
The Load function is called by Gazebo when the plugin is inserted into simulation.