Klamp't  0.8.1
SimulationGUI.h
1 #ifndef SIMULATION_GUI_H
2 #define SIMULATION_GUI_H
3 
4 #include "Simulation/WorldSimulation.h"
5 #include "WorldGUI.h"
6 #include <set>
7 
37 {
38 public:
39  typedef GLNavigationBackend BaseT;
40  int simulate;
41  WorldSimulation sim;
42  string initialState;
43 
45  set<pair<int,int> > inContact;
46 
48  :WorldGUIBackend(world),simulate(0)
49  {}
50 
51  virtual bool OnCommand(const string& cmd,const string& args);
52 
54  bool LoadAndInitSim(const char* xmlFile);
55 
57  bool LoadAndInitSim(int argc,const char** argv);
58 
60  bool LoadFile(const char* fn);
61 
63  bool LoadPath(const char* fn);
64 
66  virtual void InitSim();
68  virtual void InitController(int robot);
70  virtual void InitContactFeedbackAll();
71 
73  void ConnectSerialController(int robot,int port=3456,Real writeRate=10);
74 
76  void ResetSim();
77 
79  virtual void RenderWorld();
80 
82  void SetForceColors();
83 
85  void SetTorqueColors();
86 
88  void DrawClock(int x,int y);
89 
93  void DrawSensor(int robot=-1,int sensor=-1);
94 
96  void DrawContacts(Real pointSize = 5.0, Real fscale = 0.01, Real nscale=0.05);
97 
99  void DrawWrenches(Real fscale=-1);
100 
102  bool LoadMilestones(const char* fn);
103 
105  bool LoadLinearPath(const char* fn);
106 
108  bool LoadState(const char* fn);
109 
111  bool LoadMultiPath(const char* fn,bool constrainedInterpolate=true,Real interpolateTolerance=1e-2,Real durationScale=1.0);
112 
115  bool SendLinearPath(const vector<Real>& times,const vector<Config>& milestones,Real pathDelay=0.1);
116 
118  bool OutputROS(const char* prefix="klampt");
119 
121  void DoLogging(const char* fn="simtest_log.csv");
122 
124  void DoCommandLogging_LinearPath(int robot,const char* fn="simtest_command_log.path");
125 
127  void DoSensorLogging_LinearPath(int robot,const char* fn="simtest_sensed_log.path");
128 
130  void DoStateLogging_LinearPath(int robot,const char* fn="simtest_state_log.path");
131 
133  void DoContactStateLogging(const char* fn="simtest_contact_log.csv");
134 
136  void DoContactWrenchLogging(const char* fn="simtest_wrench_log.csv");
137 };
138 
139 #endif
void SetTorqueColors()
Sets the colors of robots to indicate torque magnitudes.
set< pair< int, int > > inContact
the contact state on the last DoContactStateLogging call
Definition: SimulationGUI.h:45
void SetForceColors()
Sets the colors of robots to indicate force magnitudes.
bool LoadAndInitSim(const char *xmlFile)
Loads from a world XML file.
virtual void InitSim()
Initializes simulation default controllers, sensors, and contact feedback.
void DoSensorLogging_LinearPath(int robot, const char *fn="simtest_sensed_log.path")
Logs the robot&#39;s sensed configuration to the given linear path file.
void DoLogging(const char *fn="simtest_log.csv")
Logs the state of all objects in the world to the given CSV file.
void DoContactStateLogging(const char *fn="simtest_contact_log.csv")
Logs contact changes to the given CSV file.
The main world class containing multiple robots, objects, and static geometries (terrains). Lights and other viewport information may also be stored here.
Definition: World.h:20
void DrawSensor(int robot=-1, int sensor=-1)
bool LoadLinearPath(const char *fn)
Loads and sends a linear path file.
void DoCommandLogging_LinearPath(int robot, const char *fn="simtest_command_log.path")
Logs the robot&#39;s commands to the given linear path file.
bool OutputROS(const char *prefix="klampt")
Outputs simulation data to ROS with the given prefix.
A generic gui with a RobotWorld which allows clicking on entities and loading files.
Definition: WorldGUI.h:21
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...
Generic simulation program.
Definition: SimulationGUI.h:36
bool LoadMilestones(const char *fn)
Loads and sends a milestone path file.
bool LoadFile(const char *fn)
Loads some file, figuring out the type from the extension.
void DoStateLogging_LinearPath(int robot, const char *fn="simtest_state_log.path")
Logs the robot&#39;s simulation state to the given linear path file.
void DrawContacts(Real pointSize=5.0, Real fscale=0.01, Real nscale=0.05)
Draws contact points.
void DoContactWrenchLogging(const char *fn="simtest_wrench_log.csv")
Logs contact wrenches to the given CSV file.
void DrawWrenches(Real fscale=-1)
Draws wrenches.
A backend that processes mouse motion calls into dragging callbacks. Makes it a bit easier to determi...
Definition: NavigationGUI.h:13
bool LoadPath(const char *fn)
Loads some file, figuring out the type from the extension.
void DrawClock(int x, int y)
Renders the simulation clock (when in screen mode)
virtual void RenderWorld()
Renders the state of the simulation.
bool LoadState(const char *fn)
Loads a simulation state file.
bool SendLinearPath(const vector< Real > &times, const vector< Config > &milestones, Real pathDelay=0.1)
void ResetSim()
Returns the simulation to its initial state.
A physical simulator for a RobotWorld.
Definition: WorldSimulation.h:67
virtual void InitController(int robot)
Initializes default controllers and sensors for the indicated robot.
A backend that manages a camera and performs OpenGL scene management.
Definition: NavigationGUI.h:49
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...