Random scene generation example. More...
#include <gazebo/gazebo_config.h>#include <gazebo/transport/transport.hh>#include <gazebo/msgs/msgs.hh>#include <gazebo/gazebo_client.hh>#include "camera_utils_request.pb.h"#include "camera_utils_response.pb.h"#include "visual_utils_request.pb.h"#include "visual_utils_response.pb.h"#include "world_utils_request.pb.h"#include "world_utils_response.pb.h"#include "utils.hh"#include "ObjectGrid.hh"#include <iostream>#include <fstream>#include <boost/filesystem.hpp>#include <mutex>#include <set>#include <chrono>#include <thread>#include <regex>#include <Eigen/Dense>#include <climits>Go to the source code of this file.
Macros | |
| #define | FIXED_VIEW 0 |
| #define | MOVING_VIEW_POS 1 |
| #define | MOVING_VIEW_POS_ROT 2 |
| #define | MOVE_REQUEST gap::msgs::CameraUtilsRequest::MOVE |
| Request to move camera to given pose. More... | |
| #define | MOVE_RESPONSE gap::msgs::CameraUtilsResponse::MOVE |
| Response acknowledging move camera request. More... | |
| #define | CAPTURE_REQUEST gap::msgs::CameraUtilsRequest::CAPTURE |
| Request to capture a frame and save it to disk. More... | |
| #define | CAPTURE_RESPONSE gap::msgs::CameraUtilsResponse::CAPTURE |
| Response acknowledging captured frame. More... | |
| #define | PROJECTION_REQUEST gap::msgs::CameraUtilsRequest::PROJECTION |
| Request 3D to 2D point projection. More... | |
| #define | PROJECTION_RESPONSE gap::msgs::CameraUtilsResponse::PROJECTION |
| Response 3D to 2D point projection. More... | |
| #define | OPTIONS gap::msgs::CameraUtilsRequest::OPTIONS |
| Request to change camera plugin settings. More... | |
| #define | UPDATE gap::msgs::VisualUtilsRequest::UPDATE |
| Request update. More... | |
| #define | UPDATED gap::msgs::VisualUtilsResponse::UPDATED |
| Visual updated response. More... | |
| #define | SPAWN gap::msgs::WorldUtilsRequest::SPAWN |
| Spawn entity. More... | |
| #define | WORLD_MOVE gap::msgs::WorldUtilsRequest::MOVE |
| Move entity. More... | |
| #define | PHYSICS gap::msgs::WorldUtilsRequest::PHYSICS |
| Start or stop physcis simulation. More... | |
| #define | CUSTOM gap::msgs::Object::CUSTOM |
| Spawn custom object. More... | |
| #define | CUSTOM_LIGHT gap::msgs::Object::CUSTOM_LIGHT |
| Spawn custom light object. More... | |
| #define | CAMERA_UTILS_TOPIC "~/gap/camera_utils" |
| Topic monitored by CameraUtils plugin for incoming requests. More... | |
| #define | CAMERA_UTILS_RESPONSE_TOPIC "~/gap/camera_utils/response" |
| Topic for receiving replies from CameraUtils plugin. More... | |
| #define | VISUAL_UTILS_TOPIC "~/gap/visual_utils" |
| Topic monitored by VisualUtils plugin for incoming requests. More... | |
| #define | VISUAL_UTILS_RESPONSE_TOPIC "~/gap/visual_utils/response" |
| Topic for receiving replies from VisualUtils plugin. More... | |
| #define | WORLD_UTILS_TOPIC "~/gap/world_utils" |
| Topic monitored by WorldUtils plugin for incoming requests. More... | |
| #define | WORLD_UTILS_RESPONSE_TOPIC "~/gap/world_utils/response" |
| Topic for receiving replies from WorldUtils plugin. More... | |
Typedefs | |
| typedef const boost::shared_ptr< const gap::msgs::CameraUtilsResponse > | CameraUtilsResponsePtr |
| Pointer to CameraUtils response message. More... | |
| typedef const boost::shared_ptr< const gap::msgs::VisualUtilsResponse > | VisualUtilsResponsePtr |
| Pointer to VisualUtils request message. More... | |
| typedef const boost::shared_ptr< const gap::msgs::WorldUtilsResponse > | WorldUtilsResponsePtr |
| Pointer to WorldUtils request message. More... | |
Functions | |
| void | addModelFromFile (gap::msgs::WorldUtilsRequest &msg, const std::string &file) |
| Function prototypes. More... | |
| void | addDynamicModels (gap::msgs::WorldUtilsRequest &msg) |
| Add objects in global grid to WorldUtils spawn request. More... | |
| void | updateObjects (gap::msgs::VisualUtilsRequest &msg) |
| Add objects in global grid to VisualUtils update request. More... | |
| 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. More... | |
| ignition::math::Pose3d | getRandomCameraPose () |
| Obtain random camera pose in dome. More... | |
| ignition::math::Pose3d | getRandomLightPose () |
| Obtain random light pose in dome. More... | |
| void | captureScene (gazebo::transport::PublisherPtr pub, int iteration) |
| Send CameraUtils request to capture current scene. More... | |
| bool | waitForMove () |
| Wait for camera to move to new pose. More... | |
| bool | waitForVisuals () |
| Wait for visuals to update. More... | |
| bool | waitForCamera () |
| Wait for camera to save frame to disk. More... | |
| bool | waitForProjections () |
| Wait for projected points. More... | |
| void | createNameSet () |
| Create set with names of existing objects. More... | |
| void | addProjections (gap::msgs::CameraUtilsRequest &msg) |
| Add 3D points to projection request. More... | |
| void | moveCamera (gazebo::transport::PublisherPtr pub) |
| Move camera to global camera pose. More... | |
| void | onCameraUtilsResponse (CameraUtilsResponsePtr &_msg) |
| Callback function for CameraUtils response. More... | |
| void | onVisualUtilsResponse (VisualUtilsResponsePtr &_msg) |
| Callback function for VisualUtils response. More... | |
| void | onWorldUtilsResponse (WorldUtilsResponsePtr &_msg) |
| Callback function for WorldUtils response. More... | |
| void | setPhysics (gazebo::transport::PublisherPtr pub, bool enable) |
| Enables/disables physics engine. More... | |
| void | visualizeData (const std::string &image_dir, int iteration) |
| Debug function to visualise scene Debug function to visualise acquired frame and object bounding boxes. More... | |
| void | storeAnnotations (const std::string &path, const int iteration) |
| Store current scene annotations. More... | |
Random scene generation example.
Generates a scene with up to 10 objects in a 4x4 grid.
| #define CAMERA_UTILS_RESPONSE_TOPIC "~/gap/camera_utils/response" |
Topic for receiving replies from CameraUtils plugin.
| #define CAMERA_UTILS_TOPIC "~/gap/camera_utils" |
Topic monitored by CameraUtils plugin for incoming requests.
| #define CAPTURE_REQUEST gap::msgs::CameraUtilsRequest::CAPTURE |
Request to capture a frame and save it to disk.
| #define CAPTURE_RESPONSE gap::msgs::CameraUtilsResponse::CAPTURE |
Response acknowledging captured frame.
| #define CUSTOM gap::msgs::Object::CUSTOM |
Spawn custom object.
| #define CUSTOM_LIGHT gap::msgs::Object::CUSTOM_LIGHT |
Spawn custom light object.
| #define FIXED_VIEW 0 |
| #define MOVE_REQUEST gap::msgs::CameraUtilsRequest::MOVE |
Request to move camera to given pose.
| #define MOVE_RESPONSE gap::msgs::CameraUtilsResponse::MOVE |
Response acknowledging move camera request.
| #define MOVING_VIEW_POS 1 |
| #define MOVING_VIEW_POS_ROT 2 |
| #define OPTIONS gap::msgs::CameraUtilsRequest::OPTIONS |
Request to change camera plugin settings.
| #define PHYSICS gap::msgs::WorldUtilsRequest::PHYSICS |
Start or stop physcis simulation.
| #define PROJECTION_REQUEST gap::msgs::CameraUtilsRequest::PROJECTION |
Request 3D to 2D point projection.
| #define PROJECTION_RESPONSE gap::msgs::CameraUtilsResponse::PROJECTION |
Response 3D to 2D point projection.
| #define SPAWN gap::msgs::WorldUtilsRequest::SPAWN |
Spawn entity.
| #define UPDATE gap::msgs::VisualUtilsRequest::UPDATE |
Request update.
| #define UPDATED gap::msgs::VisualUtilsResponse::UPDATED |
Visual updated response.
| #define VISUAL_UTILS_RESPONSE_TOPIC "~/gap/visual_utils/response" |
Topic for receiving replies from VisualUtils plugin.
| #define VISUAL_UTILS_TOPIC "~/gap/visual_utils" |
Topic monitored by VisualUtils plugin for incoming requests.
| #define WORLD_MOVE gap::msgs::WorldUtilsRequest::MOVE |
Move entity.
| #define WORLD_UTILS_RESPONSE_TOPIC "~/gap/world_utils/response" |
Topic for receiving replies from WorldUtils plugin.
| #define WORLD_UTILS_TOPIC "~/gap/world_utils" |
Topic monitored by WorldUtils plugin for incoming requests.
| typedef const boost::shared_ptr<const gap::msgs::CameraUtilsResponse> CameraUtilsResponsePtr |
Pointer to CameraUtils response message.
| typedef const boost::shared_ptr<const gap::msgs::VisualUtilsResponse> VisualUtilsResponsePtr |
Pointer to VisualUtils request message.
| typedef const boost::shared_ptr<const gap::msgs::WorldUtilsResponse> WorldUtilsResponsePtr |
Pointer to WorldUtils request message.
| void addDynamicModels | ( | gap::msgs::WorldUtilsRequest & | msg | ) |
Add objects in global grid to WorldUtils spawn request.
| msg | WorldUtils request message |
| void addModelFromFile | ( | gap::msgs::WorldUtilsRequest & | msg, |
| const std::string & | file | ||
| ) |
Function prototypes.
Adds an SDF model to a WorldUtils request
| msg | WorldUtils request message |
| file | SDF file with model |
| 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.
| msg | WordlUtils request |
| name | Object name |
| is_light | Whether object is a light |
| pose | New object pose |
| void addProjections | ( | gap::msgs::CameraUtilsRequest & | msg | ) |
Add 3D points to projection request.
| void captureScene | ( | gazebo::transport::PublisherPtr | pub, |
| int | iteration | ||
| ) |
Send CameraUtils request to capture current scene.
| pub | Publisher for CameraUtils request topic |
| iteration | Current iteration |
| void createNameSet | ( | ) |
Create set with names of existing objects.
| ignition::math::Pose3d getRandomCameraPose | ( | ) |
Obtain random camera pose in dome.
| ignition::math::Pose3d getRandomLightPose | ( | ) |
Obtain random light pose in dome.
| void moveCamera | ( | gazebo::transport::PublisherPtr | pub | ) |
Move camera to global camera pose.
| void onCameraUtilsResponse | ( | CameraUtilsResponsePtr & | _msg | ) |
Callback function for CameraUtils response.
| _msg | Incoming message |
| void onVisualUtilsResponse | ( | VisualUtilsResponsePtr & | _msg | ) |
Callback function for VisualUtils response.
| _msg | Incoming message |
| void onWorldUtilsResponse | ( | WorldUtilsResponsePtr & | _msg | ) |
Callback function for WorldUtils response.
| _msg | Incoming message |
| void setPhysics | ( | gazebo::transport::PublisherPtr | pub, |
| bool | enable | ||
| ) |
Enables/disables physics engine.
| pub | WorldUtils publisher ptr |
| enable | Desired physics engine status |
| void storeAnnotations | ( | const std::string & | path, |
| const int | iteration | ||
| ) |
Store current scene annotations.
| path | Path to dataset folder |
| iteration | Current iteration |
| void updateObjects | ( | gap::msgs::VisualUtilsRequest & | msg | ) |
Add objects in global grid to VisualUtils update request.
| void visualizeData | ( | const std::string & | image_dir, |
| int | iteration | ||
| ) |
Debug function to visualise scene Debug function to visualise acquired frame and object bounding boxes.
| bool waitForCamera | ( | ) |
Wait for camera to save frame to disk.
| bool waitForMove | ( | ) |
Wait for camera to move to new pose.
| bool waitForProjections | ( | ) |
Wait for projected points.
| bool waitForVisuals | ( | ) |
Wait for visuals to update.