Klamp't  0.8.1
Functions
IO

Functions

bool ROSInit (const char *nodename="klampt")
 
bool ROSShutdown ()
 Must call this after all other ROS[X] calls to cleanly shut down ROS.
 
bool ROSInitialized ()
 Returns true if ROS is initialized.
 
bool ROSSubscribeUpdate ()
 
bool ROSDetach (const char *topic)
 Deletes a topics. [TODO] To remove the subscribed TF topics, call ...
 
int ROSNumSubscribedTopics ()
 Returns the number of subscribed topics.
 
int ROSNumPublishedTopics ()
 Returns the number of advertised topics.
 
bool ROSIsConnected (const char *topic)
 
std::string ROSFrame (const char *topic)
 Returns the ROS frame ID that the data is attached to, if any.
 
bool ROSWaitForUpdate (const char *topic, double timeout=0)
 
bool ROSHadUpdate (const char *topic)
 Returns true if the ROS topic had an update on the past ROSSubscribeUpdate step.
 
bool ROSSetQueueSize (int size)
 Sets the global queue size.
 
bool ROSPublishPose (const Math3D::RigidTransform &T, const char *topic="klampt/transform")
 
bool ROSPublishJointState (const Robot &robot, const char *topic="klampt/joint_state")
 
bool ROSPublishPointCloud (const Meshing::PointCloud3D &pc, const char *topic="klampt/point_cloud")
 
bool ROSPublishTrajectory (const LinearPath &path, const char *topic="klampt/trajectory")
 publishes a Trajectory message with default joint names
 
bool ROSPublishTrajectory (const Robot &robot, const LinearPath &path, const char *topic="klampt/trajectory")
 publishes a Trajectory with the robot's links as joint names
 
bool ROSPublishTrajectory (const Robot &robot, const std::vector< int > &indices, const LinearPath &path, const char *topic="klampt/trajectory")
 publishes a Trajectory along the specified robot indices
 
bool ROSPublishCommandedJointState (ControlledRobotSimulator &robot, const char *topic="klampt/joint_state_commanded")
 publishes a JointState about the robot's current commanded joint state
 
bool ROSPublishSensedJointState (ControlledRobotSimulator &robot, const char *topic="klampt/joint_state_sensed")
 publishes a JointState about the robot's current sensed joint state
 
bool ROSPublishSensorMeasurement (const SensorBase *sensor, const char *topic="klampt/sensor")
 
bool ROSPublishSensorMeasurement (const SensorBase *sensor, const Robot &robot, const char *topic="klampt/sensor", const char *frameprefix="klampt")
 
bool ROSSubscribePose (Math3D::RigidTransform &T, const char *topic="klampt/joint_state")
 
bool ROSSubscribeJointState (Robot &robot, const char *topic="klampt/joint_state")
 
bool ROSSubscribePointCloud (Meshing::PointCloud3D &pc, const char *topic="klampt/point_cloud")
 
bool ROSSubscribeTrajectory (LinearPath &path, const char *topic="klampt/trajectory")
 
bool ROSSubscribeTrajectory (Robot &robot, LinearPath &path, const char *topic="klampt/trajectory")
 
bool ROSPublishTransforms (const RobotWorld &world, const char *frameprefix="klampt")
 
bool ROSPublishTransforms (const WorldSimulation &sim, const char *frameprefix="klampt")
 
bool ROSPublishTransforms (const Robot &robot, const char *frameprefix="klampt")
 
bool ROSPublishTransform (const Math3D::RigidTransform &T, const char *frame="klampt_transform")
 Publishes the transform to the transform server under the given name.
 
bool ROSSubscribeTransforms (RobotWorld &world, const char *frameprefix="klampt")
 
bool ROSSubscribeTransforms (Robot &robot, const char *frameprefix="klampt")
 
bool ROSSubscribeTransform (Math3D::RigidTransform &T, const char *frameprefix="klampt_transform")
 
void ThreeJSExport (const RobotWorld &world, AnyCollection &out)
 
void ThreeJSExportTransforms (const RobotWorld &world, AnyCollection &out)
 
void ThreeJSExport (WorldSimulation &sim, AnyCollection &out)
 
void ThreeJSExportTransforms (WorldSimulation &sim, AnyCollection &out)
 
void ThreeJSExport (const Robot &robot, AnyCollection &out)
 
void ThreeJSExportTransforms (const Robot &robot, AnyCollection &out)
 
void ThreeJSExport (const RigidObject &object, AnyCollection &out)
 
void ThreeJSExportTransforms (const RigidObject &object, AnyCollection &out)
 
void ThreeJSExport (const Terrain &terrain, AnyCollection &out)
 
void ThreeJSExportTransforms (const Terrain &terrain, AnyCollection &out)
 
void ThreeJSExportGeometry (const ManagedGeometry &geom, AnyCollection &out)
 
void ThreeJSExportAppearance (const ManagedGeometry &geom, AnyCollection &out)
 
void ThreeJSExport (const Geometry::AnyCollisionGeometry3D &geom, AnyCollection &out)
 Exports to a three.js scene Geometry instance.
 
void ThreeJSExport (const GLDraw::GeometryAppearance &app, AnyCollection &out)
 Exports to a three.js scene Material instance.
 

Detailed Description

I/O routines. Most of these will be transparent to the user, and you should just use the Robot.Load and World.ReadFile routines. ROS.h and three.js.h might be useful.

Function Documentation

bool ROSInit ( const char *  nodename = "klampt")

Must call this before all other ROS[X] calls. An optional node name can be provided, otherwise it is just "klampt". This can safely be called many times

bool ROSIsConnected ( const char *  topic)

Returns true if anyone is sending data to a topic Klampt is subscribing to if anyone is listening to a topic Klamp't is publishing to

bool ROSPublishSensorMeasurement ( const SensorBase sensor,
const char *  topic = "klampt/sensor" 
)

Pubhlishes a sensor reading to a topic of the appropriate type.

  • Generically, a FloatArray is published.
  • CameraSensor publishes two topics if color is available: [topic]/rgb/camera_info and [topic]/rgb/image_color_rect. If depth is available, publishes to [topic]/depth_registered/camera_info and [topic]/depth_registered/image_rect.
bool ROSPublishSensorMeasurement ( const SensorBase sensor,
const Robot robot,
const char *  topic = "klampt/sensor",
const char *  frameprefix = "klampt" 
)

Same as above, but with the proper tf frame name. robot is the robot to which the sensor is attached and frameprefix is the tf frame prefix.

bool ROSPublishTransforms ( const RobotWorld world,
const char *  frameprefix = "klampt" 
)

Publishes the world to the transform server, under frames named by [frameprefix]/[rigid object name] for rigid objects and [frameprefix]/[robot name]/[link name] for robot links

bool ROSPublishTransforms ( const WorldSimulation sim,
const char *  frameprefix = "klampt" 
)

Publishes the simulation to the transform server, under frames named by [frameprefix]/[rigid object name] for rigid objects and [frameprefix]/[robot name]/[link name] for robot links

bool ROSPublishTransforms ( const Robot robot,
const char *  frameprefix = "klampt" 
)

Publishes the robot link transforms to the transform server under frames named by [frameprefix]/[link name]

bool ROSSubscribeJointState ( Robot robot,
const char *  topic = "klampt/joint_state" 
)

Subscribes to JointState updates from the given topic. Note: the robot object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach([topic]);

bool ROSSubscribePointCloud ( Meshing::PointCloud3D &  pc,
const char *  topic = "klampt/point_cloud" 
)

Subscribes to PointCloud2 updates from the given topic. Note: the object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach([topic]);

bool ROSSubscribePose ( Math3D::RigidTransform &  T,
const char *  topic = "klampt/joint_state" 
)

Subscribes to Pose updates from the given topic. Note: the T object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach([topic]);

bool ROSSubscribeTrajectory ( LinearPath path,
const char *  topic = "klampt/trajectory" 
)

Subscribes to Trajectory updates from the given topic. Note: the object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach([topic]);

bool ROSSubscribeTrajectory ( Robot robot,
LinearPath path,
const char *  topic = "klampt/trajectory" 
)

Subscribes to Trajectory updates from the given topic, with the given robot as reference (Trajectories can specify a subset of robot joints). Note: the robot and path must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach([topic]);

bool ROSSubscribeTransform ( Math3D::RigidTransform &  T,
const char *  frameprefix = "klampt_transform" 
)

Subscribes to transform updates from the transform server. Note: the T object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach("tf");

bool ROSSubscribeTransforms ( RobotWorld world,
const char *  frameprefix = "klampt" 
)

Subscribes to world updates from the transform server. Note: the world object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach("tf"); Note: does NOT set robot configurations.

bool ROSSubscribeTransforms ( Robot robot,
const char *  frameprefix = "klampt" 
)

Subscribes to robot updates from the transform server. Note: the robot object must not be destroyed while ROSSubscribeUpdate is being called. If you want to detach it from future updates, call RosDetach("tf"); Note: does NOT set robot configurations.

bool ROSSubscribeUpdate ( )

Updates subscribed topics. Returns true if any topic was updated. Note: if only "tf" is updated, this will still return false...

bool ROSWaitForUpdate ( const char *  topic,
double  timeout = 0 
)

Blocks until the subscriber on the given topic receives a new update. Returns true if an update was found. If this is not subscribed to, it returns false immediately. Note: does not work for the "tf" topic yet.

void ThreeJSExport ( const RobotWorld world,
AnyCollection &  out 
)

Exports a world to a JSON object that can be used in the three.js editor. Contains metadata, geometries, materials, and object items.

Note: export the AnyCollection to a string via the ostream << operator.

void ThreeJSExport ( WorldSimulation sim,
AnyCollection &  out 
)

Exports a simulation to a JSON object that can be used in the three.js editor. Contains metadata, geometries, materials, and object items. Draws the simulation world in natural color and the commanded world in transparent green.

void ThreeJSExport ( const Robot robot,
AnyCollection &  out 
)

Exports a robot to a JSON object that can be used in the three.js editor. The result is a hierarchical set of Mesh or Group objects.

void ThreeJSExport ( const RigidObject object,
AnyCollection &  out 
)

Exports a rigid object to a JSON object that can be used in the three.js editor. The result is a Mesh object (or Group if the geometry is empty).

void ThreeJSExport ( const Terrain terrain,
AnyCollection &  out 
)

Exports a rigid object to a JSON object that can be used in the three.js editor. The result is a Mesh object (or Group if the geometry is empty).

void ThreeJSExportAppearance ( const ManagedGeometry geom,
AnyCollection &  out 
)

Exports appearance to a three.js scene Material instance. The "uuid" element of the output gives the unique ID number that can be used elsewhere

void ThreeJSExportGeometry ( const ManagedGeometry geom,
AnyCollection &  out 
)

Exports geometry to a three.js scene Geometry instance. The "uuid" element of the output gives the unique ID number that can be used elsewhere