scene_example.cc File Reference

Random scene generation example implementation. More...

#include "scene_example.hh"

Functions

std::regex g_regex_uid (REGEX_XML_UID)
 
std::regex g_regex_model (REGEX_XML_MODEL)
 
int main (int argc, char **argv)
 
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 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 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 onVisualUtilsResponse (VisualUtilsResponsePtr &_msg)
 Callback function for VisualUtils response. More...
 
void onWorldUtilsResponse (WorldUtilsResponsePtr &_msg)
 Callback function for WorldUtils response. More...
 
void onCameraUtilsResponse (CameraUtilsResponsePtr &_msg)
 Callback function for CameraUtils response. More...
 
void setPhysics (gazebo::transport::PublisherPtr pub, bool enable)
 Enables/disables physics engine. More...
 
void storeAnnotations (const std::string &path, const int iteration)
 Store current scene annotations. More...
 

Variables

ObjectGrid g_grid (3, 3, 3, 3, 1)
 
const int g_obj_min {2}
 
const int g_obj_max {7}
 
const bool g_move_light {true}
 
const ignition::math::Vector3d g_light_pos {1.5, 1.5, 5.5}
 
const ignition::math::Vector3d g_camera_pos {1.5, 1.5, 3.2}
 
const int g_viewpoint {FIXED_VIEW}
 
bool g_moved {false}
 
std::mutex g_moved_mutex
 
bool g_camera_ready {false}
 
std::mutex g_camera_ready_mutex
 
bool g_points_ready {false}
 
std::mutex g_points_ready_mutex
 
bool g_visuals_ready {false}
 
std::mutex g_visuals_ready_mutex
 
std::set< std::string > g_names
 
ignition::math::Pose3d g_camera_pose
 

Detailed Description

Random scene generation example implementation.

Generates a scene with up to 10 objects in a 4x4 grid.

Author
João Borrego : jsbruglie
Rui Figueiredo : ruipimentelfigueiredo

Function Documentation

void addDynamicModels ( gap::msgs::WorldUtilsRequest &  msg)

Add objects in global grid to WorldUtils spawn request.

Parameters
msgWorldUtils request message
void addModelFromFile ( gap::msgs::WorldUtilsRequest &  msg,
const std::string &  file 
)

Function prototypes.

Adds an SDF model to a WorldUtils request

Parameters
msgWorldUtils request message
fileSDF 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.

Parameters
msgWordlUtils request
nameObject name
is_lightWhether object is a light
poseNew 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.

Parameters
pubPublisher for CameraUtils request topic
iterationCurrent iteration
void createNameSet ( )

Create set with names of existing objects.

std::regex g_regex_model ( REGEX_XML_MODEL  )
std::regex g_regex_uid ( REGEX_XML_UID  )
ignition::math::Pose3d getRandomCameraPose ( )

Obtain random camera pose in dome.

Returns
New random camera pose
ignition::math::Pose3d getRandomLightPose ( )

Obtain random light pose in dome.

Returns
New random light pose
int main ( int  argc,
char **  argv 
)
void moveCamera ( gazebo::transport::PublisherPtr  pub)

Move camera to global camera pose.

void onCameraUtilsResponse ( CameraUtilsResponsePtr _msg)

Callback function for CameraUtils response.

Parameters
_msgIncoming message
void onVisualUtilsResponse ( VisualUtilsResponsePtr _msg)

Callback function for VisualUtils response.

Parameters
_msgIncoming message
void onWorldUtilsResponse ( WorldUtilsResponsePtr _msg)

Callback function for WorldUtils response.

Parameters
_msgIncoming message
void setPhysics ( gazebo::transport::PublisherPtr  pub,
bool  enable 
)

Enables/disables physics engine.

Parameters
pubWorldUtils publisher ptr
enableDesired physics engine status
void storeAnnotations ( const std::string &  path,
const int  iteration 
)

Store current scene annotations.

Parameters
pathPath to dataset folder
iterationCurrent iteration
void updateObjects ( gap::msgs::VisualUtilsRequest &  msg)

Add objects in global grid to VisualUtils update request.

bool waitForCamera ( )

Wait for camera to save frame to disk.

Returns
True if process should wait
bool waitForMove ( )

Wait for camera to move to new pose.

Returns
True if process should wait
bool waitForProjections ( )

Wait for projected points.

bool waitForVisuals ( )

Wait for visuals to update.

Returns
True if process should wait

Variable Documentation

const ignition::math::Vector3d g_camera_pos {1.5, 1.5, 3.2}
ignition::math::Pose3d g_camera_pose
bool g_camera_ready {false}
std::mutex g_camera_ready_mutex
ObjectGrid g_grid(3, 3, 3, 3, 1)
const ignition::math::Vector3d g_light_pos {1.5, 1.5, 5.5}
const bool g_move_light {true}
bool g_moved {false}
std::mutex g_moved_mutex
std::set<std::string> g_names
const int g_obj_max {7}
const int g_obj_min {2}
bool g_points_ready {false}
std::mutex g_points_ready_mutex
const int g_viewpoint {FIXED_VIEW}
bool g_visuals_ready {false}
std::mutex g_visuals_ready_mutex