Klamp't  0.9.0
SimulationGUI.h
1 #ifndef SIMULATION_GUI_H
2 #define SIMULATION_GUI_H
3 
4 #include <Klampt/Simulation/Simulator.h>
5 #include "WorldGUI.h"
6 #include <set>
7 
8 namespace Klampt {
9 
39 {
40 public:
41  typedef GLNavigationBackend BaseT;
42  int simulate;
43  Simulator sim;
44  string initialState;
45 
47  set<pair<int,int> > inContact;
48 
50  :WorldGUIBackend(world),simulate(0)
51  {}
52 
53  virtual bool OnCommand(const string& cmd,const string& args);
54 
56  bool LoadAndInitSim(const char* xmlFile);
57 
59  bool LoadAndInitSim(int argc,const char** argv);
60 
62  bool LoadFile(const char* fn);
63 
65  bool LoadPath(const char* fn);
66 
68  virtual void InitSim();
70  virtual void InitController(int robot);
72  virtual void InitContactFeedbackAll();
73 
75  void ConnectSerialController(int robot,int port=3456,Real writeRate=10);
76 
78  void ResetSim();
79 
81  virtual void RenderWorld();
82 
84  void SetForceColors();
85 
87  void SetTorqueColors();
88 
90  void DrawClock(int x,int y);
91 
95  void DrawSensor(int robot=-1,int sensor=-1);
96 
98  void DrawContacts(Real pointSize = 5.0, Real fscale = 0.01, Real nscale=0.05);
99 
101  void DrawWrenches(Real fscale=-1);
102 
104  bool LoadMilestones(const char* fn);
105 
107  bool LoadLinearPath(const char* fn);
108 
110  bool LoadState(const char* fn);
111 
113  bool LoadMultiPath(const char* fn,bool constrainedInterpolate=true,Real interpolateTolerance=1e-2,Real durationScale=1.0);
114 
117  bool SendLinearPath(const vector<Real>& times,const vector<Config>& milestones,Real pathDelay=0.1);
118 
120  bool OutputROS(const char* prefix="klampt");
121 
123  void DoLogging(const char* fn="simtest_log.csv");
124 
126  void DoCommandLogging_LinearPath(int robot,const char* fn="simtest_command_log.path");
127 
129  void DoSensorLogging_LinearPath(int robot,const char* fn="simtest_sensed_log.path");
130 
132  void DoStateLogging_LinearPath(int robot,const char* fn="simtest_state_log.path");
133 
135  void DoContactStateLogging(const char* fn="simtest_contact_log.csv");
136 
138  void DoContactWrenchLogging(const char* fn="simtest_wrench_log.csv");
139 };
140 
141 } // namespace Klampt
142 
143 #endif
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...
void SetTorqueColors()
Sets the colors of robots to indicate torque magnitudes.
void DrawWrenches(Real fscale=-1)
Draws wrenches.
void DrawContacts(Real pointSize=5.0, Real fscale=0.01, Real nscale=0.05)
Draws contact points.
Generic simulation program.
Definition: SimulationGUI.h:38
virtual void RenderWorld()
Renders the state of the simulation.
A physical simulator for a WorldModel.
Definition: Simulator.h:69
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 DoStateLogging_LinearPath(int robot, const char *fn="simtest_state_log.path")
Logs the robot&#39;s simulation state to the given linear path file.
A backend that processes mouse motion calls into dragging callbacks. Makes it a bit easier to determi...
Definition: NavigationGUI.h:15
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 DoContactWrenchLogging(const char *fn="simtest_wrench_log.csv")
Logs contact wrenches to the given CSV file.
bool LoadFile(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)
void SetForceColors()
Sets the colors of robots to indicate force magnitudes.
bool LoadPath(const char *fn)
Loads some file, figuring out the type from the extension.
bool LoadState(const char *fn)
Loads a simulation state file.
bool SendLinearPath(const vector< Real > &times, const vector< Config > &milestones, Real pathDelay=0.1)
bool OutputROS(const char *prefix="klampt")
Outputs simulation data to ROS with the given prefix.
void DrawSensor(int robot=-1, int sensor=-1)
virtual void InitController(int robot)
Initializes default controllers and sensors for the indicated robot.
void DoContactStateLogging(const char *fn="simtest_contact_log.csv")
Logs contact changes to the given CSV file.
virtual void InitContactFeedbackAll()
Initializes all contact feedback.
set< pair< int, int > > inContact
the contact state on the last DoContactStateLogging call
Definition: SimulationGUI.h:47
bool LoadLinearPath(const char *fn)
Loads and sends a linear path file.
void ResetSim()
Returns the simulation to its initial state.
virtual void InitSim()
Initializes simulation default controllers, sensors, and contact feedback.
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 LoadAndInitSim(const char *xmlFile)
Loads from a world XML file.
A generic gui with a WorldModel which allows clicking on entities and loading files.
Definition: WorldGUI.h:23
A backend that manages a camera and performs OpenGL scene management.
Definition: NavigationGUI.h:51
Definition: ContactDistance.h:6
void DoLogging(const char *fn="simtest_log.csv")
Logs the state of all objects in the world to the given CSV file.
bool LoadMilestones(const char *fn)
Loads and sends a milestone path 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:24