29 #include <gazebo/common/Events.hh> 30 #include "gazebo/common/Plugin.hh" 31 #include <gazebo/msgs/msgs.hh> 32 #include "gazebo/physics/physics.hh" 33 #include <gazebo/transport/transport.hh> 45 #include <boost/algorithm/string/predicate.hpp> 46 #include <boost/lexical_cast.hpp> 49 #include "world_utils_request.pb.h" 50 #include "world_utils_response.pb.h" 58 #define REQUEST_TOPIC "~/gap/world_utils" 59 #define RESPONSE_TOPIC "~/gap/world_utils/response" 67 #define SPAWN gap::msgs::WorldUtilsRequest::SPAWN 68 #define MOVE gap::msgs::WorldUtilsRequest::MOVE 70 #define REMOVE gap::msgs::WorldUtilsRequest::REMOVE 72 #define PHYSICS gap::msgs::WorldUtilsRequest::PHYSICS 74 #define PAUSE gap::msgs::WorldUtilsRequest::PAUSE 76 #define STATUS gap::msgs::WorldUtilsRequest::STATUS 80 #define SPHERE gap::msgs::Object::SPHERE 81 #define CYLINDER gap::msgs::Object::CYLINDER 83 #define BOX gap::msgs::Object::BOX 85 #define CUSTOM gap::msgs::Object::CUSTOM 87 #define CUSTOM_LIGHT gap::msgs::Object::CUSTOM_LIGHT 89 #define MODEL gap::msgs::Object::MODEL 95 #define INFO gap::msgs::WorldUtilsResponse::INFO 96 #define SUCCESS gap::msgs::WorldUtilsResponse::SUCCESS 105 #define REGEX_XML_SCRIPT "<script>[\\s\\S]*?<\\/script>" 106 #define REGEX_XML_POSE "<pose>[\\s\\S]*?<\\/pose>" 116 typedef const boost::shared_ptr<const gap::msgs::WorldUtilsRequest>
119 typedef const boost::shared_ptr<const gap::msgs::WorldUtilsResponse>
145 private: transport::NodePtr
node;
147 private: transport::SubscriberPtr
sub;
149 private: transport::PublisherPtr
pub;
168 private:
int sphere_counter {0};
170 private:
int cylinder_counter {0};
172 private:
int box_counter {0};
174 private:
int light_counter {0};
187 public:
void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf);
190 public:
void onUpdate();
199 private:
void clearWorld();
204 private:
void clearMatching(
const std::string & match,
const bool is_light);
214 private:
const std::string genSphere(
215 const std::string &model_name,
218 const ignition::math::Vector3d position,
219 const ignition::math::Quaterniond orientation);
230 private:
const std::string genCylinder(
231 const std::string &model_name,
235 const ignition::math::Vector3d position,
236 const ignition::math::Quaterniond orientation);
246 private:
const std::string genBox(
247 const std::string &model_name,
249 const ignition::math::Vector3d size,
250 const ignition::math::Vector3d position,
251 const ignition::math::Quaterniond orientation);
Definition: WorldUtils.hh:55
transport::PublisherPtr pub
A publisher to the reply topic.
Definition: WorldUtils.hh:149
Definition: CameraUtils.cc:30
transport::SubscriberPtr sub
A subscriber to the request topic.
Definition: WorldUtils.hh:147
transport::PublisherPtr request_pub
A publisher to the gazebo request topic.
Definition: WorldUtils.hh:152
const boost::shared_ptr< const gap::msgs::WorldUtilsRequest > WorldUtilsRequestPtr
Shared pointer declaration for request message type.
Definition: WorldUtils.hh:117
event::ConnectionPtr updateConnection
Connection to World Update events.
Definition: WorldUtils.hh:142
std::queue< MoveObject > move_queue
Queue of objects with pending move actions.
Definition: WorldUtils.hh:177
transport::PublisherPtr light_pub
A publisher to light modify topic.
Definition: WorldUtils.hh:156
transport::SubscriberPtr response_sub
A subscriber to the gazebo response topic.
Definition: WorldUtils.hh:154
const boost::shared_ptr< const gap::msgs::WorldUtilsResponse > WorldUtilsResponsePtr
Pointer to WorldUtils request message.
Definition: scene_example.hh:158
std::regex script_reg
Regex for applying custom material.
Definition: WorldUtils.hh:161
std::regex pose_reg
Regex for applying custom pose.
Definition: WorldUtils.hh:163
std::mutex mutex
Mutex for safe data access.
Definition: WorldUtils.hh:137
transport::NodePtr node
A node used for transport.
Definition: WorldUtils.hh:145
physics::WorldPtr world
A pointer to the world.
Definition: WorldUtils.hh:140