Klamp't  0.9.0
Functions
IO

Functions

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

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

bool Klampt::ROSSubscribeJointState ( RobotModel 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 Klampt::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 Klampt::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 Klampt::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 Klampt::ROSSubscribeTrajectory ( RobotModel 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 Klampt::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 Klampt::ROSSubscribeTransforms ( WorldModel 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 Klampt::ROSSubscribeTransforms ( RobotModel 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 Klampt::ROSSubscribeUpdate ( )

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

bool Klampt::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 Klampt::ThreeJSExport ( const WorldModel 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 Klampt::ThreeJSExport ( Simulator 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 Klampt::ThreeJSExport ( const RobotModel 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 Klampt::ThreeJSExport ( const RigidObjectModel 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 Klampt::ThreeJSExport ( const TerrainModel 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 Klampt::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 Klampt::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