Klamp't
0.8.1
|
Generic simulation program. More...
#include <SimulationGUI.h>
Public Types | |
typedef GLNavigationBackend | BaseT |
Public Types inherited from GLNavigationBackend | |
typedef MouseDragBackend | BaseT |
Public Member Functions | |
SimGUIBackend (RobotWorld *world) | |
virtual bool | OnCommand (const string &cmd, const string &args) |
bool | LoadAndInitSim (const char *xmlFile) |
Loads from a world XML file. | |
bool | LoadAndInitSim (int argc, const char **argv) |
Loads from a command line. | |
bool | LoadFile (const char *fn) |
Loads some file, figuring out the type from the extension. | |
bool | LoadPath (const char *fn) |
Loads some file, figuring out the type from the extension. | |
virtual void | InitSim () |
Initializes simulation default controllers, sensors, and contact feedback. | |
virtual void | InitController (int robot) |
Initializes default controllers and sensors for the indicated robot. | |
virtual void | InitContactFeedbackAll () |
Initializes all contact feedback. | |
void | ConnectSerialController (int robot, int port=3456, Real writeRate=10) |
Connects a robot to a SerialController listening for new connections on the given port. | |
void | ResetSim () |
Returns the simulation to its initial state. | |
virtual void | RenderWorld () |
Renders the state of the simulation. | |
void | SetForceColors () |
Sets the colors of robots to indicate force magnitudes. | |
void | SetTorqueColors () |
Sets the colors of robots to indicate torque magnitudes. | |
void | DrawClock (int x, int y) |
Renders the simulation clock (when in screen mode) | |
void | DrawSensor (int robot=-1, int sensor=-1) |
void | DrawContacts (Real pointSize=5.0, Real fscale=0.01, Real nscale=0.05) |
Draws contact points. | |
void | DrawWrenches (Real fscale=-1) |
Draws wrenches. | |
bool | LoadMilestones (const char *fn) |
Loads and sends a milestone path file. | |
bool | LoadLinearPath (const char *fn) |
Loads and sends a linear path file. | |
bool | LoadState (const char *fn) |
Loads a simulation state file. | |
bool | LoadMultiPath (const char *fn, bool constrainedInterpolate=true, Real interpolateTolerance=1e-2, Real durationScale=1.0) |
Loads a multipath file and possibly discretizes it into a fine-grained linear path before sending. | |
bool | SendLinearPath (const vector< Real > ×, const vector< Config > &milestones, Real pathDelay=0.1) |
bool | OutputROS (const char *prefix="klampt") |
Outputs simulation data to ROS with the given prefix. | |
void | DoLogging (const char *fn="simtest_log.csv") |
Logs the state of all objects in the world to the given CSV file. | |
void | DoCommandLogging_LinearPath (int robot, const char *fn="simtest_command_log.path") |
Logs the robot's commands to the given linear path file. | |
void | DoSensorLogging_LinearPath (int robot, const char *fn="simtest_sensed_log.path") |
Logs the robot's sensed configuration to the given linear path file. | |
void | DoStateLogging_LinearPath (int robot, const char *fn="simtest_state_log.path") |
Logs the robot's simulation state to the given linear path file. | |
void | DoContactStateLogging (const char *fn="simtest_contact_log.csv") |
Logs contact changes to the given CSV file. | |
void | DoContactWrenchLogging (const char *fn="simtest_wrench_log.csv") |
Logs contact wrenches to the given CSV file. | |
Public Member Functions inherited from WorldGUIBackend | |
WorldGUIBackend (RobotWorld *world) | |
bool | LoadCommandLine (int argc, const char **argv) |
bool | LoadFile (const char *fn) |
bool | ReloadFile (const char *fn) |
bool | SaveWorld (const char *fn, const char *elementPath=NULL) |
virtual void | Start () |
Default implementation of following do nothing. | |
virtual bool | OnIdle () |
virtual void | SetWorldLights () |
Robot * | ClickRobot (int x, int y, int &body, Vector3 &localpt) const |
Robot * | ClickRobot (const Ray3D &r, int &body, Vector3 &localpt) const |
RigidObject * | ClickObject (int x, int y, Vector3 &localpt) const |
RigidObject * | ClickObject (const Ray3D &r, Vector3 &localpt) const |
virtual void | RefreshIdle () |
virtual void | DoFreeDrag (int dx, int dy, int button) |
Overload this for regular (non-modified) dragging. | |
virtual void | DoCtrlDrag (int dx, int dy, int button) |
Overload this for control-dragging. | |
virtual void | DoAltDrag (int dx, int dy, int button) |
Overload this for alt-dragging. | |
virtual void | DoShiftDrag (int dx, int dy, int button) |
Overload this for shift-dragging. | |
virtual bool | OnMouseWheel (int dwheel) |
Public Member Functions inherited from GLNavigationBackend | |
virtual void | RenderScreen () |
virtual bool | OnGLRender () |
virtual bool | OnGLViewport (int x, int y, int w, int h) |
virtual void | BeginDrag (int x, int y, int button, int modifiers) |
void | DragPan (int dx, int dy) |
void | DragRotate (int dx, int dy) |
void | DragZoom (int dx, int dy) |
void | DragTruck (int dx, int dy) |
void | Set2DMode (bool mode=true) |
void | DisplayCameraTarget () |
void | CenterCameraOn (const Math3D::AABB3D &bbox) |
void | ClickRay (int x, int y, Math3D::Vector3 &src, Math3D::Vector3 &dir) const |
void | WriteDisplaySettings (std::ostream &out) const |
void | ReadDisplaySettings (std::istream &in) |
Public Member Functions inherited from MouseDragBackend | |
virtual bool | OnMouseClick (int button, int state, int mx, int my) |
virtual bool | OnMouseMove (int mx, int my) |
virtual bool | OnKeyDown (const string &key) |
virtual bool | OnKeyUp (const string &key) |
virtual void | DoDrag (int dx, int dy, int button, int modifiers) |
virtual void | EndDrag (int x, int y, int button, int modifiers) |
virtual void | DoPassiveMouseMove (int x, int y) |
Overload this to handle plain, non-dragging mouse motion events. | |
Public Member Functions inherited from GenericBackendBase | |
virtual void | Stop () |
virtual bool | ProcessMessage (const AnyCollection &msg) |
virtual bool | SendMessage (const AnyCollection &msg) |
Send a message to the gui. | |
void | MapButtonPress (const string &button, int *var) |
void | MapButtonToggle (const string &button, int *var) |
void | MapWidgetValue (const string &button, string *var) |
void | MapKeyToggle (const string &key, int *var) |
virtual bool | OnButtonPress (const string &button) |
virtual bool | OnButtonToggle (const string &button, int checked) |
virtual bool | OnWidgetValue (const string &widget, const string &value) |
virtual bool | OnScroll (int dy) |
virtual bool | OnSpaceball (const Math3D::RigidTransform &T) |
virtual bool | OnDevice (const string &name, const string &data) |
bool | SendQuit () |
bool | SendCommand (const string &cmd, const string &args) |
bool | SendNotify (const string &text, const string &msglevel="") |
bool | SendError (const string &text) |
bool | SendWarning (const string &text) |
bool | SendPauseIdle (double secs=1e300) |
bool | SendRefresh () |
bool | SendResize (int w, int h) |
bool | SendDrawText (double x, double y, double z, const std::string &text, int height=10) |
bool | SendDrawText (int x, int y, const std::string &text, int height=10) |
Public Attributes | |
int | simulate |
WorldSimulation | sim |
string | initialState |
set< pair< int, int > > | inContact |
the contact state on the last DoContactStateLogging call | |
Public Attributes inherited from WorldGUIBackend | |
RobotWorld * | world |
Public Attributes inherited from GLNavigationBackend | |
Camera::Viewport | viewport |
Camera::CameraController_Orbit | camera |
bool | stereo_mode |
float | stereo_offset |
Timer | timer |
int | show_view_target |
float | t_hide_view_target |
float | frames_per_second |
bool | show_frames_per_second |
int | frames_rendered |
bool | mode_2d |
Public Attributes inherited from MouseDragBackend | |
int | oldmousex |
int | oldmousey |
int | clickButton |
int | clickModifiers |
Public Attributes inherited from GenericBackendBase | |
GenericGUIBase * | gui |
map< string, int * > | liveButtonPresses |
map< string, int * > | liveButtonToggles |
map< string, string * > | liveWidgetValues |
map< string, int * > | liveKeys |
Generic simulation program.
To set up the world and simulation from a command line, call LoadAndInitSim(). To set up the simulation from a world, just InitSim(). To change the default controller, override the InitController(int i) method.
Messages are defined as follows.
command:
In the current format, elements in the world should not be added/deleted after initialization.
void SimGUIBackend::DrawSensor | ( | int | robot = -1 , |
int | sensor = -1 |
||
) |
Draws sensor readings on the world visualization. If robot < 0, draws all the robots/sensors. If sensor < 0, draws all the sensors on the given robot.
bool SimGUIBackend::SendLinearPath | ( | const vector< Real > & | times, |
const vector< Config > & | milestones, | ||
Real | pathDelay = 0.1 |
||
) |
Sends a linear path to the controller. The path starts pathDelay seconds after the current time