Klamp't  0.9.0
InputProcessor.h
1 #ifndef INPUT_PROCESSOR_H
2 #define INPUT_PROCESSOR_H
3 
5 #include <Klampt/Planning/PlannerObjective.h>
6 #include <KrisLibrary/utils/AsyncIO.h>
7 #include <KrisLibrary/Timer.h>
8 
9 namespace Klampt {
10 
18 {
19  public:
21  virtual ~InputProcessorBase() {}
22  virtual string Instructions() const { return ""; }
23  virtual void Activate(bool enabled) {}
24  virtual bool HasUpdate() { return true; }
25  virtual void Hover(int mx,int my) {}
26  virtual void Drag(float dx,float dy) {}
27  virtual void Spaceball(const RigidTransform& T) {}
28  virtual void SetGlobalTime(Real time) { currentTime = time; }
29  virtual void SetPredictionTime(Real splitTime) {}
30  virtual PlannerObjectiveBase* MakeObjective(RobotModel* robot) { return NULL; }
31  virtual void DrawGL() {}
32 
33  //helpers
34  RobotModel* GetRobot() const;
35  void GetClickRay(int mx, int my, Ray3D& ray) const;
36 
37  WorldModel* world;
38  Camera::Viewport* viewport;
39  Real currentTime;
40 };
41 
45 {
46  public:
48  virtual ~StandardInputProcessor() {}
49  virtual string Instructions() const { return "Click and drag to pose points on the robot"; }
50  virtual void Activate(bool enabled);
51  virtual bool HasUpdate() { return changed; }
52  virtual void Hover(int mx,int my);
53  virtual void Drag(float dx,float dy);
54  virtual void Spaceball(const RigidTransform& T);
55  virtual PlannerObjectiveBase* MakeObjective(RobotModel* robot);
56  virtual void DrawGL();
57 
58  bool move, changed;
59  int currentLink;
60  Vector3 currentPoint;
61  Vector3 currentDestination;
62  bool useSpaceball;
63  RigidTransform currentDesiredTransform;
64  IKGoal goal;
65  Real pathCost;
66 };
67 
72 {
73  public:
75  virtual void Activate(bool enabled);
76  virtual bool HasUpdate() { return true; }
77  virtual void Hover(int mx,int my);
78  virtual void Drag(float mx,float my);
79  virtual void SetPredictionTime(Real splitTime);
80  virtual PlannerObjectiveBase* MakeObjective(RobotModel* robot);
81  virtual void DrawGL();
82 
83  Real currentInputTime;
84  int numInputs;
85  Vector3 sumVelocity;
86  Real alpha; //decay term for velocity estimator
87  Real weightDecay,speedDecay;
88  Real predictionOffset;
89  bool tracking;
90  PlannerObjectiveBase* lastObjective;
91 };
92 
93 
94 
101 {
102  public:
103  SerializedObjectiveProcessor(AsyncReaderThread* reader=NULL);
104  virtual ~SerializedObjectiveProcessor() {}
105  virtual void Activate(bool enabled);
106  virtual bool HasUpdate();
107  virtual PlannerObjectiveBase* MakeObjective(RobotModel* robot);
108 
109  AsyncReaderThread* reader;
110 };
111 
118 {
119  public:
120  SocketObjectiveProcessor(const char* addr)
121  :SerializedObjectiveProcessor(&socketReader),socketReader(addr)
122  {}
123  virtual ~SocketObjectiveProcessor() {}
124  virtual string Instructions() { return "Reading objectives over socket..."; }
125  SocketReadWorker socketReader;
126 };
127 
128 } // namespace Klampt
129 
130 #endif
Defines the WorldModel class.
Translates click-and-drag input into an IKObjective.
Definition: InputProcessor.h:44
A base class for objective functionals in time/config/velocity space.
Definition: PlannerObjective.h:17
Translates input and extrapolated velocity into a CartesianTrackingObjective.
Definition: InputProcessor.h:71
The main robot type used in RobotSim.
Definition: Robot.h:83
Reads an objective function from a reader thread.
Definition: InputProcessor.h:100
Reads an objective function from a socket.
Definition: InputProcessor.h:117
Definition: ContactDistance.h:6
An abstract base class for processing user input through a 2D mouse driven gui into PlannerObjectives...
Definition: InputProcessor.h:17
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