orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
pathinput.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef ORCA_PATH_INPUT_H 00012 #define ORCA_PATH_INPUT_H 00013 00014 #include <QMatrix> 00015 #include <QVector> 00016 #include <QMouseEvent> 00017 #include <QTableWidget> 00018 #include <QSpinBox> 00019 00020 #include <orca/pathfollower2d.h> 00021 #include <orca/pathplanner2d.h> 00022 #include <orcaice/context.h> 00023 #include <hydroqgui/hydroqgui.h> 00024 00025 namespace orcaqgui2d { 00026 00027 class PathInput; 00028 class WpTable; 00029 00030 // internal Gui representation for waypoint and path 00031 struct GuiWaypoint 00032 { 00033 QPointF position; // in m 00034 int heading; // in 1/16 deg from 0 to 360*16 00035 float timeTarget; // number of seconds until arrival at waypoint 00036 float distanceTolerance; // distance tolerances in m 00037 int headingTolerance; // heading tolerances in 1/16 deg from 0 to 360*16 00038 float maxSpeed; // max speed in m/s 00039 int maxTurnrate; // max turnrate in deg/s 00040 }; 00041 00042 typedef QVector<GuiWaypoint> GuiPath; 00043 00044 // conversion functions 00045 void guiPathToOrcaPath( const GuiPath &in, 00046 orca::Path2d &out, 00047 int numLoops = 1, 00048 float timeOffset = 0.0 ); 00049 00050 void orcaPathToGuiPath( const orca::Path2d &in, 00051 GuiPath &out ); 00052 00053 00054 // all units are SI units 00055 class WaypointSettings 00056 { 00057 public: 00058 WaypointSettings(std::string a, float b, float c, int d, float e, int f): 00059 spacingProperty(a), 00060 spacingValue(b), 00061 distanceTolerance(c), 00062 headingTolerance(d), 00063 maxApproachSpeed(e), 00064 maxApproachTurnrate(f) 00065 {} 00066 std::string spacingProperty; 00067 float spacingValue; 00068 float distanceTolerance; 00069 int headingTolerance; 00070 float maxApproachSpeed; 00071 int maxApproachTurnrate; 00072 }; 00073 00074 class WpWidget : public QWidget 00075 { 00076 Q_OBJECT 00077 00078 public: 00079 WpWidget( PathInput *pathInput, 00080 GuiPath *guiPath, 00081 QVector<float> *waitingTimes ); 00082 ~WpWidget() {}; 00083 void refreshTable(); 00084 QString getBehaviour( int row ); 00085 int numberOfLoops() { return numLoopsSpin_->value(); }; 00086 00087 private: 00088 PathInput *pathInput_; 00089 WpTable *wpTable_; 00090 bool pathFileSet_; 00091 QString pathFileName_; 00092 QSpinBox *numLoopsSpin_; 00093 00094 private slots: 00095 void savePathAs(); 00096 void savePath(); 00097 void loadPath(); 00098 00099 }; 00100 00101 class WpTable : public QTableWidget 00102 { 00103 Q_OBJECT 00104 00105 public: 00106 WpTable( QWidget *parent, 00107 PathInput *pathInput, 00108 GuiPath *guiPath, 00109 QVector<float> *waitingTimes ); 00110 ~WpTable() {}; 00111 void refreshTable(); 00112 void computeVelocities(); 00113 QString getBehaviour( int row ); 00114 00115 private: 00116 PathInput *pathInput_; 00117 00118 // data which is shared with pathinput 00119 GuiPath *guiPath_; 00120 QVector<float> *waitingTimes_; 00121 00122 // this one is only local 00123 QVector<float> velocities_; 00124 00125 // lock up the cellUpdate signal: it should only be emitted if the user changes cell entries 00126 // not if we programmatically change them (as in refreshTable) 00127 bool isLocked_; 00128 00129 private slots: 00130 // called after user interaction 00131 void updateDataStorage(int row, int column); 00132 }; 00133 00134 class PathInput : public QObject 00135 { 00136 Q_OBJECT 00137 00138 public: 00139 PathInput( QObject *parent, 00140 WaypointSettings *wpSettings, 00141 hydroqguielementutil::IHumanManager &humanManager, 00142 QString lastSavedPathFile="" ); 00143 virtual ~PathInput(); 00144 00145 virtual void paint( QPainter *painter ); 00146 virtual void setUseTransparency( bool useTransparency ) { useTransparency_=useTransparency; }; 00147 00148 virtual void processPressEvent( QMouseEvent* e); 00149 virtual void processReleaseEvent( QMouseEvent* e ); 00150 virtual void processDoubleClickEvent( QMouseEvent* e); 00151 virtual void processMoveEvent( QMouseEvent* e); 00152 00153 virtual void updateWpSettings( WaypointSettings* wpSettings ); 00154 00155 virtual void savePath( const QString &fileName ); 00156 virtual void loadPath( const QString &fileName ); 00157 00158 protected: 00159 WaypointSettings *wpSettings_; 00160 hydroqguielementutil::IHumanManager &humanManager_; 00161 QMatrix wmInv_; // win2mm matrix 00162 00163 bool useTransparency_; 00164 00165 void addWaypoint( QPointF ); 00166 void removeWaypoint( QPointF ); 00167 void changeWpParameters( QPointF ); 00168 void resizeData( int index ); 00169 00170 // The path in Gui representation. Shared with wpWidget 00171 GuiPath guiPath_; 00172 // how long to wait at this waypoint, filled in by wpWidget 00173 QVector<float> waitingTimes_; 00174 00175 QPointF mouseDownPnt_; 00176 QPointF mouseUpPnt_; 00177 QPointF mouseMovePnt_; 00178 QPointF doubleClick_; 00179 00180 WpWidget *wpWidget_; 00181 int waypointInFocus_; 00182 00183 QString lastSavedPathFile_; 00184 00185 float secondsToCompleteLoop() const; 00186 00187 public slots: 00188 void setWaypointFocus(int row, int column); 00189 void generateFullPath(); 00190 void loadPreviousPath(); 00191 00192 signals: 00193 void sendPathClicked(); 00194 void cancelPathClicked(); 00195 00196 private: 00197 void expandPath( int index, int numInsert, int headingTolerance); 00198 int expandPathStationary( int index ); 00199 int expandPathLeftRight( int index ); 00200 int expandPathRightLeft( int index ); 00201 int expandPathTurn360( int index ); 00202 00203 }; 00204 00205 class PathFollowerInput : public PathInput 00206 { 00207 public: 00208 PathFollowerInput( QObject *parent, 00209 WaypointSettings *wpSettings, 00210 hydroqguielementutil::IHumanManager &humanManager, 00211 QString lastSavedPathFile ) 00212 : PathInput( parent, wpSettings, humanManager, lastSavedPathFile ) 00213 {}; 00214 virtual ~PathFollowerInput() {}; 00215 00216 bool getPath( orca::PathFollower2dData &pathData ) const; 00217 }; 00218 00219 class PathPlannerInput : public PathInput 00220 { 00221 public: 00222 PathPlannerInput( QObject *parent, 00223 WaypointSettings *wpSettings, 00224 hydroqguielementutil::IHumanManager &humanManager ) 00225 :PathInput( parent, wpSettings, humanManager ) 00226 {}; 00227 00228 virtual ~PathPlannerInput() {}; 00229 00230 orca::PathPlanner2dTask getTask() const; 00231 }; 00232 00233 WaypointSettings readWaypointSettings( const Ice::PropertiesPtr & props, const std::string & tag ); 00234 00235 bool readActivateImmediately( const Ice::PropertiesPtr & props, const std::string & tag ); 00236 00237 QString readDumpPath( const Ice::PropertiesPtr & props, const std::string & tag ); 00238 00239 } // namespace 00240 00241 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)