Main MRPT website > C++ reference
MRPT logo
CRovio.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef CROVIO_H
30 #define CROVIO_H
31 
32 #include <mrpt/utils/utils_defs.h>
33 #include <mrpt/utils/TCamera.h>
38 
40 
41 
42 namespace mrpt
43 {
44  namespace hwdrivers
45  {
46  using namespace std;
47  using namespace mrpt::slam;
48 
49  /** A class to interface a Rovio robot (manufactured by WowWee).
50  * Supports: Simple motion commands, video streaming.
51  * \ingroup mrpt_hwdrivers_grp
52  */
54  {
55  private:
61 
64 
65 
66  /** This function takes a frame and waits until getLastImage ask for it, and so on.
67  */
68  void thread_video();
69 
70  bool send_cmd_action(int act, int speed);
71 
72  bool path_management(int act);
73 
74  bool path_management(int act, const string &path_name);
75 
76  bool general_command(int act, string &response, string &errormsg);
77 
78 
79  public:
80  struct TOptions
81  {
82  string IP;
83  string user;
84  string password;
85 
86  mrpt::utils::TCamera cameraParams; // Mat. cam. preguntar paco
87 
88  TOptions();
89  } options;
90 
91  enum status {idle, driving_home, docking, executing_path, recording_path};
92 
93  struct TRovioState{
95  unsigned int nss; //Navigation Signal Strength
96  unsigned int wss; //Wifi Signal Strength
97  };
98 
99  struct TEncoders{
100  int left;
101  int right;
102  int rear;
104  {
105  left = 0;
106  right = 0;
107  rear = 0;
108  }
109  }encoders;
110 
111 
112  /** Establish conection with Rovio and log in its system: Important, fill out "options" members *BEFORE* calling this method.
113  * \exception std::runtime On errors
114  */
115  void initialize(); //string &errormsg_out, string url_out="150.214.109.134", string user_out="admin", string password_out="investigacion");
116 
117  /** move send Rovio the command to move in the specified direcction
118  * \param direction 'f'->forward, 'b'->backward, 'r'->right, 'l'->left
119  * \return False on error
120  */
121  bool move(char direction, int speed=5 );
122 
123  /** rotate send Rovio the command to rotate in the specified direcction
124  * 'r'->right, 'l'->left
125  * \return False on error
126  */
127  bool rotate(char direction, int speed=5 );
128 
129  /** Head positions
130  * \return False on error
131  */
132  bool takeHeadUp();
133  bool takeHeadMiddle();
134  bool takeHeadDown();
135 
136 
137  /* Path commands */
138  bool pathRecord();
139  bool pathRecordAbort();
140  bool pathRecordSave(const string &path_name);//Repasar const
141  bool pathDelete(const string &path_name);
142  /** Get list of saved paths
143  */
144  bool pathGetList(string &path_list);
145  bool pathRunForward();
146  bool pathRunBackward();
147  bool pathRunStop();
148  bool pathRunPause();
149  bool pathRename(const string &old_name, const string &new_name);
150 
151 
152  /** goHome(bool dock) drives Rovio in front of charging station if the paremeter dock is set to false, otherwise it also docks
153  * \return False on error
154  */
155  bool goHome(bool dock, int speed = 5);
156 
157  /** Loads the rovio camera calibration parameters (of leave the default ones if not found) (See CGenericSensor), then call to "loadConfig_sensorSpecific"
158  * \exception This method throws an exception with a descriptive message if some critical parameter is missing or has an invalid value.
159  */
160  void loadConfig(
161  const mrpt::utils::CConfigFileBase &configSource,
162  const std::string &section );
163 
164  /** This function launchs a thread with the function "thread_video()" which gets frames into a buffer.
165  * After calling this method, images can be obtained with getNextImageSync()
166  * \return False on error
167  * \sa getNextImageSync
168  */
169  bool retrieve_video();//como la protejo para que no se llame dos veces??????????????????????????????????????????????
170 
171  /** This function stops and joins the thread launched by "retrieve_video()".
172  * \return False on error
173  */
174  bool stop_video();
175 
176  /** Returns the next frame from Rovio's live video stream, after starting the live streaming with retrieve_video()
177  * \return False on error
178  * \sa retrieve_video, captureImageAsync
179  */
180  bool getNextImageSync(CObservationImagePtr& lastImage );
181 
182  /** Returns a snapshot from Rovio, if rectified is set true, the returned image is rectified with the parameters of intrinsic_matrix and distortion_matrix.
183  * This function works asynchronously and does not need to have enabled the live video streaming.
184  * \return False on error
185  * \sa captureImageSync
186  */
187  bool captureImageAsync( CImage&out_img, bool recttified);//string pict_name,
188 
189  bool isVideoStreamming() const; //!< Return true if video is streaming correctly \sa retrieve_video
190 
191 
192 //Rovio State
193  /** Returns a TRovioState with internal information of Rovio (State, Navigation Signal Strength, Wifi Signal Strength)
194  * \return False on error
195  */
196  bool getRovioState(TRovioState &state);
197 
198  /** Returns a TEncoders with information of Rovio encoders (since last read, it seems Rovio is continuously reading with unknown sample time)
199  * \return False on error
200  */
201  bool getEncoders(TEncoders &encoders);
202 
203  /** Returns the Rovio's pose
204  * \return False on error
205  */
206  bool getPosition(mrpt::math::TPose2D &out_pose);
207 
208 
209 
210  CRovio();
211  virtual ~CRovio();
212 
213  }; // End of class
214 
215  } // End of namespace
216 
217 } // End of namespace
218 
219 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013