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