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