Klamp't  0.9.0
UserInterface.h
1 #ifndef USER_INTERFACE_H
2 #define USER_INTERFACE_H
3 
5 #include <Klampt/Modeling/DynamicPath.h>
6 #include <KrisLibrary/camera/viewport.h>
7 #include <Klampt/Planning/RobotCSpace.h>
8 #include <Klampt/Planning/PlannerSettings.h>
9 #include <Klampt/Planning/RealTimePlanner.h>
10 #include "RobotInterface.h"
11 #include "InputProcessor.h"
12 #include <KrisLibrary/utils/threadutils.h>
13 
14 namespace Klampt {
15 
16 
23 {
24  public:
26  virtual ~RobotUserInterface() { }
27  RobotModel* GetRobot() const { return world->robots[0].get(); }
28  void GetClickRay(int mx,int my,Ray3D& ray) const;
29 
30  //Subclasses overload these functions
31  //
32  virtual string Name() const { return "Unnamed"; }
33  virtual string Description() const { return "Unnamed"; }
34  virtual string Instructions() const { return ""; }
35  virtual void DrawGL() { }
36  //
37  //The following callbacks are called respectively upon
38  //activation/deactivation;
39  //mouse input;
40  //spaceball input;
41  //keyboard input;
42  //and idle update (here is where motions should be sent).
43  //The return value is a string that gets logged to disk.
44  virtual string ActivateEvent(bool enable) { return ""; }
45  virtual string MouseInputEvent(int mx,int my,bool drag) { return ""; }
46  virtual string SpaceballEvent(const RigidTransform& T) { return ""; }
47  virtual string KeypressEvent(unsigned char c,int mx,int my) { return ""; }
48  virtual string UpdateEvent() { return ""; }
49 
50  //settings
51  WorldModel* world;
52  Camera::Viewport* viewport;
53  //if set, the planner will plan in this world
54  WorldModel* planningWorld;
55  WorldPlannerSettings* settings;
56  MotionQueueInterface* robotInterface;
57 };
58 
63 {
64  public:
65  virtual string Name() const { return "JointPoser"; }
66  virtual string Description() const { return "Joint poser"; }
67  virtual string Instructions() const { return "Click and drag to pose individual joints"; }
68  virtual string ActivateEvent(bool enabled);
69  virtual string MouseInputEvent(int mx,int my,bool drag);
70  virtual string UpdateEvent();
71 
72  int currentLink;
73  Config command;
74  bool sendCommand;
75 };
76 
83 {
84  public:
86  virtual ~InputProcessingInterface();
87  void SetProcessor(shared_ptr<InputProcessorBase>& newProcessor);
88  bool ObjectiveChanged();
89  shared_ptr<PlannerObjectiveBase> GetObjective();
90  CartesianObjective* GetCartesianObjective();
91 
92  virtual string Instructions() const { if(inputProcessor) return inputProcessor->Instructions(); else return ""; }
93  virtual string ActivateEvent(bool enabled);
94  virtual void DrawGL();
95  virtual string MouseInputEvent(int mx,int my,bool drag);
96  virtual string SpaceballEvent(const RigidTransform& T);
97  virtual string UpdateEvent();
98 
99  shared_ptr<InputProcessorBase> inputProcessor;
100  shared_ptr<PlannerObjectiveBase> currentObjective;
101 };
102 
108 {
109  public:
110  virtual string Name() const { return "PointPoser"; }
111  virtual string Description() const { return "Point poser"; }
112  virtual string UpdateEvent();
113 };
114 
120 {
121  public:
123  virtual ~PlannerCommandInterface();
124  virtual string Name() const { return "UnnamedPlanner"; }
125  virtual string Description() const { return "Unnamed planner interface"; }
126 
127  virtual string ActivateEvent(bool enabled);
128  virtual string UpdateEvent();
129  virtual string Instructions() const;
130 
131  shared_ptr<RealTimePlanner> planner;
132  shared_ptr<PlannerObjectiveBase> plannerObjective;
133  double lastPlanTime;
134  double nextPlanTime;
135 
140  bool started;
141 };
142 
147 {
148  public:
149  virtual string Name() const { return "IKPointPoser"; }
150  virtual string Description() const { return "Smart point poser"; }
151  virtual string ActivateEvent(bool enabled);
152 
153  shared_ptr<SingleRobotCSpace> cspace;
154 };
155 
160 {
161  public:
162  virtual string Name() const { return "RRTPointPoser"; }
163  virtual string Description() const { return "Goal-based point poser"; }
164  virtual string ActivateEvent(bool enabled);
165 
166  //TODO: draw the plan feedback?
167  //GLuint planDisplayList;
168 
169  shared_ptr<SingleRobotCSpace> cspace;
170 };
171 
172 
173 
174 
180 {
181 public:
182  RealTimePlanningThread planningThread;
183  shared_ptr<PlannerObjectiveBase> plannerObjective;
184 
189  bool started;
190 
192  virtual ~MTPlannerCommandInterface();
193  virtual string Name() const { return "UnnamedPlanner"; }
194  virtual string Description() const { return "Unnamed planner interface"; }
195 
196  string Instructions() const;
197  virtual string ActivateEvent(bool enabled);
198  virtual string UpdateEvent();
199 };
200 
202 {
203  public:
204  virtual string Name() const { return "IKPointPoser"; }
205  virtual string Description() const { return "Safety Filter"; }
206  virtual string ActivateEvent(bool enabled);
207 
208  shared_ptr<SingleRobotCSpace> cspace;
209 
210 };
211 
213 {
214  public:
215  virtual string Name() const { return "RRTPointPoser"; }
216  virtual string Description() const { return "Sampling-Based Planner"; }
217  //sets up the planner
218  virtual string ActivateEvent(bool enabled);
219 
220  shared_ptr<SingleRobotCSpace> cspace;
221 };
222 
223 } // namespace Klampt
224 
225 #endif
Definition: RobotInterface.h:29
double startObjectiveThreshold
Definition: UserInterface.h:139
A goal that measures point-to-point distance.
Definition: PlannerObjective.h:177
An interface that uses an InputProcessorBase subclass to process input. By default, it uses a StandardInputProcessor which lets the user to pose points on the robot in Cartesian space by pointing and dragging.
Definition: UserInterface.h:82
A structure containing settings that should be used for collision detection, contact solving...
Definition: PlannerSettings.h:43
An interface that uses the real-time RRT motion planner to achieve the user&#39;s objective.
Definition: UserInterface.h:159
An interface to a planning thread.
Definition: RealTimePlanner.h:287
An abstract base class for a user interface.
Definition: UserInterface.h:22
Defines the WorldModel class.
An interface that uses numerical IK to solve for a Cartesian objective function. Assumes that IK is f...
Definition: UserInterface.h:107
Definition: UserInterface.h:201
shared_ptr< PlannerObjectiveBase > plannerObjective
this is needed to maintain object pointed to by planner&#39;s objective
Definition: UserInterface.h:183
An interface that uses a real-time planner to solve for an arbitrary objective function. Subclasses must choose which type of planner to use.
Definition: UserInterface.h:119
A base class for a multithreaded planning robot UI. Subclasses must call planningThread.SetStartConfig(), SetCSpace(), and SetPlanner().
Definition: UserInterface.h:179
Definition: UserInterface.h:212
The main robot type used in RobotSim.
Definition: Robot.h:83
An interface uses safe IK as the real-time planner class to achieve the user&#39;s objective.
Definition: UserInterface.h:146
An interface that allows the user to pose individual joints using mouse dragging. ...
Definition: UserInterface.h:62
Definition: ContactDistance.h:6
double startObjectiveThreshold
Definition: UserInterface.h:188
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