Main MRPT website > C++ reference for MRPT 1.4.0
CRovio.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9
10#ifndef CROVIO_H
11#define CROVIO_H
12
13#include <mrpt/utils/TCamera.h>
18
20
21
22namespace mrpt
23{
24 namespace hwdrivers
25 {
26 /** A class to interface a Rovio robot (manufactured by WowWee).
27 * Supports: Simple motion commands, video streaming.
28 * \ingroup mrpt_hwdrivers_grp
29 */
31 {
32 private:
38
41
42
43 /** This function takes a frame and waits until getLastImage ask for it, and so on.
44 */
46
47 bool send_cmd_action(int act, int speed);
48
49 bool path_management(int act);
50
51 bool path_management(int act, const std::string &path_name);
52
53 bool general_command(int act, std::string &response, std::string &errormsg);
54
55
56 public:
57 struct TOptions
58 {
59 std::string IP;
60 std::string user;
61 std::string password;
62
63 mrpt::utils::TCamera cameraParams; // Mat. cam. preguntar paco
64
66 } options;
67
68 enum status {idle, driving_home, docking, executing_path, recording_path};
69
72 unsigned int nss; //Navigation Signal Strength
73 unsigned int wss; //Wifi Signal Strength
74 };
75
76 struct TEncoders{
77 int left;
78 int right;
79 int rear;
81 {
82 left = 0;
83 right = 0;
84 rear = 0;
85 }
86 }encoders;
87
88
89 /** Establish conection with Rovio and log in its system: Important, fill out "options" members *BEFORE* calling this method.
90 * \exception std::runtime On errors
91 */
92 void initialize(); //string &errormsg_out, std::string url_out="150.214.109.134", std::string user_out="admin", std::string password_out="investigacion");
93
94 /** move send Rovio the command to move in the specified direcction
95 * \param direction 'f'->forward, 'b'->backward, 'r'->right, 'l'->left
96 * \return False on error
97 */
98 bool move(char direction, int speed=5 );
99
100 /** rotate send Rovio the command to rotate in the specified direcction
101 * 'r'->right, 'l'->left
102 * \return False on error
103 */
104 bool rotate(char direction, int speed=5 );
105
106 /** Head positions
107 * \return False on error
108 */
112
113
114 /* Path commands */
117 bool pathRecordSave(const std::string &path_name);//Repasar const
118 bool pathDelete(const std::string &path_name);
119 /** Get list of saved paths
120 */
121 bool pathGetList(std::string &path_list);
126 bool pathRename(const std::string &old_name, const std::string &new_name);
127
128
129 /** goHome(bool dock) drives Rovio in front of charging station if the paremeter dock is set to false, otherwise it also docks
130 * \return False on error
131 */
132 bool goHome(bool dock, int speed = 5);
133
134 /** Loads the rovio camera calibration parameters (of leave the default ones if not found) (See CGenericSensor), then call to "loadConfig_sensorSpecific"
135 * \exception This method throws an exception with a descriptive message if some critical parameter is missing or has an invalid value.
136 */
138 const mrpt::utils::CConfigFileBase &configSource,
139 const std::string &section );
140
141 /** This function launchs a thread with the function "thread_video()" which gets frames into a buffer.
142 * After calling this method, images can be obtained with getNextImageSync()
143 * \return False on error
144 * \sa getNextImageSync
145 */
146 bool retrieve_video();//como la protejo para que no se llame dos veces??????????????????????????????????????????????
147
148 /** This function stops and joins the thread launched by "retrieve_video()".
149 * \return False on error
150 */
152
153 /** Returns the next frame from Rovio's live video stream, after starting the live streaming with retrieve_video()
154 * \return False on error
155 * \sa retrieve_video, captureImageAsync
156 */
158
159 /** Returns a snapshot from Rovio, if rectified is set true, the returned image is rectified with the parameters of intrinsic_matrix and distortion_matrix.
160 * This function works asynchronously and does not need to have enabled the live video streaming.
161 * \return False on error
162 * \sa captureImageSync
163 */
164 bool captureImageAsync( mrpt::utils::CImage&out_img, bool recttified);//string pict_name,
165
166 bool isVideoStreamming() const; //!< Return true if video is streaming correctly \sa retrieve_video
167
168
169//Rovio State
170 /** Returns a TRovioState with internal information of Rovio (State, Navigation Signal Strength, Wifi Signal Strength)
171 * \return False on error
172 */
174
175 /** Returns a TEncoders with information of Rovio encoders (since last read, it seems Rovio is continuously reading with unknown sample time)
176 * \return False on error
177 */
178 bool getEncoders(TEncoders &encoders);
179
180 /** Returns the Rovio's pose
181 * \return False on error
182 */
184
185
186
188 virtual ~CRovio();
189
190 }; // End of class
191
192 } // End of namespace
193
194} // End of namespace
195
196#endif
A class to interface a Rovio robot (manufactured by WowWee).
Definition: CRovio.h:31
bool pathGetList(std::string &path_list)
Get list of saved paths.
bool goHome(bool dock, int speed=5)
goHome(bool dock) drives Rovio in front of charging station if the paremeter dock is set to false,...
bool rotate(char direction, int speed=5)
rotate send Rovio the command to rotate in the specified direcction 'r'->right, 'l'->left
bool pathDelete(const std::string &path_name)
bool getNextImageSync(mrpt::obs::CObservationImagePtr &lastImage)
Returns the next frame from Rovio's live video stream, after starting the live streaming with retriev...
bool pathRename(const std::string &old_name, const std::string &new_name)
mrpt::synch::CCriticalSection buffer_img_cs
Definition: CRovio.h:40
bool takeHeadUp()
Head positions.
bool m_videothread_must_exit
Definition: CRovio.h:34
bool pathRecordSave(const std::string &path_name)
bool general_command(int act, std::string &response, std::string &errormsg)
bool getRovioState(TRovioState &state)
Returns a TRovioState with internal information of Rovio (State, Navigation Signal Strength,...
bool getEncoders(TEncoders &encoders)
Returns a TEncoders with information of Rovio encoders (since last read, it seems Rovio is continuous...
void initialize()
Establish conection with Rovio and log in its system: Important, fill out "options" members BEFORE ca...
bool stop_video()
This function stops and joins the thread launched by "retrieve_video()".
bool retrieve_video()
This function launchs a thread with the function "thread_video()" which gets frames into a buffer.
bool m_videothread_finished
Definition: CRovio.h:37
mrpt::obs::CObservationImagePtr buffer_img
Definition: CRovio.h:39
bool isVideoStreamming() const
Return true if video is streaming correctly.
bool send_cmd_action(int act, int speed)
bool path_management(int act)
bool m_videothread_initialized_done
Definition: CRovio.h:35
bool m_videothread_initialized_error
Definition: CRovio.h:36
bool path_management(int act, const std::string &path_name)
mrpt::system::TThreadHandle m_videoThread
Definition: CRovio.h:33
bool captureImageAsync(mrpt::utils::CImage &out_img, bool recttified)
Returns a snapshot from Rovio, if rectified is set true, the returned image is rectified with the par...
void loadConfig(const mrpt::utils::CConfigFileBase &configSource, const std::string &section)
Loads the rovio camera calibration parameters (of leave the default ones if not found) (See CGenericS...
bool getPosition(mrpt::math::TPose2D &out_pose)
Returns the Rovio's pose.
void thread_video()
This function takes a frame and waits until getLastImage ask for it, and so on.
bool move(char direction, int speed=5)
move send Rovio the command to move in the specified direcction
This class provides simple critical sections functionality.
This class allows loading and storing values and vectors of different types from a configuration text...
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:102
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:32
#define HWDRIVERS_IMPEXP
struct OBS_IMPEXP CObservationImagePtr
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::TCamera cameraParams
Definition: CRovio.h:63
Lightweight 2D pose.
This structure contains the information needed to interface the threads API on each platform:
Definition: threads.h:26



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Mar 22 04:35:51 UTC 2023