30 #include <gazebo/gazebo_config.h> 31 #include <gazebo/transport/transport.hh> 32 #include <gazebo/msgs/msgs.hh> 33 #include <gazebo/gazebo_client.hh> 36 #include "camera_utils_request.pb.h" 37 #include "camera_utils_response.pb.h" 38 #include "visual_utils_request.pb.h" 39 #include "visual_utils_response.pb.h" 40 #include "world_utils_request.pb.h" 41 #include "world_utils_response.pb.h" 53 #include <boost/filesystem.hpp> 64 #include <Eigen/Dense> 75 #define MOVING_VIEW_POS 1 77 #define MOVING_VIEW_POS_ROT 2 83 #define REGEX_XML_MODEL "<model name=(\"([^\"]|\"\")*\")>" 84 #define REGEX_XML_UID "<uid>[\\s\\S]*?<\\/uid>" 96 #define MOVE_REQUEST gap::msgs::CameraUtilsRequest::MOVE 97 #define MOVE_RESPONSE gap::msgs::CameraUtilsResponse::MOVE 99 #define CAPTURE_REQUEST gap::msgs::CameraUtilsRequest::CAPTURE 101 #define CAPTURE_RESPONSE gap::msgs::CameraUtilsResponse::CAPTURE 103 #define PROJECTION_REQUEST gap::msgs::CameraUtilsRequest::PROJECTION 105 #define PROJECTION_RESPONSE gap::msgs::CameraUtilsResponse::PROJECTION 107 #define OPTIONS gap::msgs::CameraUtilsRequest::OPTIONS 113 #define UPDATE gap::msgs::VisualUtilsRequest::UPDATE 114 #define UPDATED gap::msgs::VisualUtilsResponse::UPDATED 120 #define SPAWN gap::msgs::WorldUtilsRequest::SPAWN 121 #define WORLD_MOVE gap::msgs::WorldUtilsRequest::MOVE 123 #define PHYSICS gap::msgs::WorldUtilsRequest::PHYSICS 127 #define CUSTOM gap::msgs::Object::CUSTOM 128 #define CUSTOM_LIGHT gap::msgs::Object::CUSTOM_LIGHT 136 #define CAMERA_UTILS_TOPIC "~/gap/camera_utils" 137 #define CAMERA_UTILS_RESPONSE_TOPIC "~/gap/camera_utils/response" 139 #define VISUAL_UTILS_TOPIC "~/gap/visual_utils" 141 #define VISUAL_UTILS_RESPONSE_TOPIC "~/gap/visual_utils/response" 143 #define WORLD_UTILS_TOPIC "~/gap/world_utils" 145 #define WORLD_UTILS_RESPONSE_TOPIC "~/gap/world_utils/response" 151 typedef const boost::shared_ptr<const gap::msgs::CameraUtilsResponse>
154 typedef const boost::shared_ptr<const gap::msgs::VisualUtilsResponse>
157 typedef const boost::shared_ptr<const gap::msgs::WorldUtilsResponse>
168 gap::msgs::WorldUtilsRequest & msg,
169 const std::string & file);
184 gap::msgs::WorldUtilsRequest & msg,
185 const std::string & name,
187 const ignition::math::Pose3d & pose);
200 void captureScene(gazebo::transport::PublisherPtr pub,
int iteration);
224 void moveCamera(gazebo::transport::PublisherPtr pub);
241 void setPhysics(gazebo::transport::PublisherPtr pub,
bool enable);
245 void visualizeData(
const std::string & image_dir,
int iteration);
251 const std::string & path,
252 const int iteration);
void onWorldUtilsResponse(WorldUtilsResponsePtr &_msg)
Callback function for WorldUtils response.
Definition: scene_example.cc:506
void addDynamicModels(gap::msgs::WorldUtilsRequest &msg)
Add objects in global grid to WorldUtils spawn request.
Definition: scene_example.cc:257
bool waitForCamera()
Wait for camera to save frame to disk.
Definition: scene_example.cc:471
void onVisualUtilsResponse(VisualUtilsResponsePtr &_msg)
Callback function for VisualUtils response.
Definition: scene_example.cc:493
void moveCamera(gazebo::transport::PublisherPtr pub)
Move camera to global camera pose.
Definition: scene_example.cc:427
ignition::math::Pose3d getRandomCameraPose()
Obtain random camera pose in dome.
Definition: scene_example.cc:333
const boost::shared_ptr< const gap::msgs::VisualUtilsResponse > VisualUtilsResponsePtr
Pointer to VisualUtils request message.
Definition: scene_example.hh:155
void visualizeData(const std::string &image_dir, int iteration)
Debug function to visualise scene Debug function to visualise acquired frame and object bounding boxe...
bool waitForMove()
Wait for camera to move to new pose.
Definition: scene_example.cc:449
bool waitForProjections()
Wait for projected points.
Definition: scene_example.cc:482
ObjectGrid and Object classes.
ignition::math::Pose3d getRandomLightPose()
Obtain random light pose in dome.
Definition: scene_example.cc:373
void captureScene(gazebo::transport::PublisherPtr pub, int iteration)
Send CameraUtils request to capture current scene.
Definition: scene_example.cc:440
bool waitForVisuals()
Wait for visuals to update.
Definition: scene_example.cc:460
void addProjections(gap::msgs::CameraUtilsRequest &msg)
Add 3D points to projection request.
Definition: scene_example.cc:407
void storeAnnotations(const std::string &path, const int iteration)
Store current scene annotations.
Definition: scene_example.cc:575
const boost::shared_ptr< const gap::msgs::WorldUtilsResponse > WorldUtilsResponsePtr
Pointer to WorldUtils request message.
Definition: scene_example.hh:158
void addMoveObject(gap::msgs::WorldUtilsRequest &msg, const std::string &name, const bool is_light, const ignition::math::Pose3d &pose)
Add move object command to WorldUtils request.
Definition: scene_example.cc:315
void updateObjects(gap::msgs::VisualUtilsRequest &msg)
Add objects in global grid to VisualUtils update request.
Definition: scene_example.cc:290
void onCameraUtilsResponse(CameraUtilsResponsePtr &_msg)
Callback function for CameraUtils response.
Definition: scene_example.cc:512
void setPhysics(gazebo::transport::PublisherPtr pub, bool enable)
Enables/disables physics engine.
Definition: scene_example.cc:566
Generic utilities for scene generation example.
const boost::shared_ptr< const gap::msgs::CameraUtilsResponse > CameraUtilsResponsePtr
Pointer to CameraUtils response message.
Definition: scene_example.hh:152
void addModelFromFile(gap::msgs::WorldUtilsRequest &msg, const std::string &file)
Function prototypes.
Definition: scene_example.cc:240
void createNameSet()
Create set with names of existing objects.
Definition: scene_example.cc:390