MRPT  2.0.4
List of all members | Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
mrpt::hwdrivers::CRovio Class Reference

Detailed Description

A class to interface a Rovio robot (manufactured by WowWee).

Supports: Simple motion commands, video streaming.

Definition at line 25 of file CRovio.h.

#include <mrpt/hwdrivers/CRovio.h>

Classes

struct  TEncoders
 
struct  TOptions
 
struct  TRovioState
 

Public Types

enum  status {
  idle, driving_home, docking, executing_path,
  recording_path
}
 

Public Member Functions

void initialize ()
 Establish Connection with Rovio and log in its system: Important, fill out "options" members BEFORE calling this method. More...
 
bool move (char direction, int speed=5)
 move send Rovio the command to move in the specified direcction More...
 
bool rotate (char direction, int speed=5)
 rotate send Rovio the command to rotate in the specified direcction 'r'->right, 'l'->left More...
 
bool takeHeadUp ()
 Head positions. More...
 
bool takeHeadMiddle ()
 
bool takeHeadDown ()
 
bool pathRecord ()
 
bool pathRecordAbort ()
 
bool pathRecordSave (const std::string &path_name)
 
bool pathDelete (const std::string &path_name)
 
bool pathGetList (std::string &path_list)
 Get list of saved paths. More...
 
bool pathRunForward ()
 
bool pathRunBackward ()
 
bool pathRunStop ()
 
bool pathRunPause ()
 
bool pathRename (const std::string &old_name, const std::string &new_name)
 
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, otherwise it also docks More...
 
void loadConfig (const mrpt::config::CConfigFileBase &configSource, const std::string &section)
 Loads the rovio camera calibration parameters (of leave the default ones if not found) (See CGenericSensor), then call to "loadConfig_sensorSpecific". More...
 
bool retrieve_video ()
 This function launchs a thread with the function "thread_video()" which gets frames into a buffer. More...
 
bool stop_video ()
 This function stops and joins the thread launched by "retrieve_video()". More...
 
bool getNextImageSync (mrpt::obs::CObservationImage::Ptr &lastImage)
 Returns the next frame from Rovio's live video stream, after starting the live streaming with retrieve_video() More...
 
bool captureImageAsync (mrpt::img::CImage &out_img, bool recttified)
 Returns a snapshot from Rovio, if rectified is set true, the returned image is rectified with the parameters of intrinsic_matrix and distortion_matrix. More...
 
bool isVideoStreamming () const
 Return true if video is streaming correctly. More...
 
bool getRovioState (TRovioState &state)
 Returns a TRovioState with internal information of Rovio (State, Navigation Signal Strength, Wifi Signal Strength) More...
 
bool getEncoders (TEncoders &encoders)
 Returns a TEncoders with information of Rovio encoders (since last read, it seems Rovio is continuously reading with unknown sample time) More...
 
bool getPosition (mrpt::math::TPose2D &out_pose)
 Returns the Rovio's pose. More...
 
 CRovio ()
 
virtual ~CRovio ()
 

Public Attributes

struct mrpt::hwdrivers::CRovio::TOptions options
 
struct mrpt::hwdrivers::CRovio::TEncoders encoders
 

Private Member Functions

void thread_video ()
 This function takes a frame and waits until getLastImage ask for it, and so on. More...
 
bool send_cmd_action (int act, int speed)
 
bool path_management (int act)
 
bool path_management (int act, const std::string &path_name)
 
bool general_command (int act, std::string &response, std::string &errormsg)
 

Private Attributes

std::thread m_videoThread
 
bool m_videothread_must_exit
 
bool m_videothread_initialized_done
 
bool m_videothread_initialized_error
 
bool m_videothread_finished
 
mrpt::obs::CObservationImage::Ptr buffer_img
 
std::mutex buffer_img_cs
 

Member Enumeration Documentation

◆ status

Enumerator
idle 
driving_home 
docking 
executing_path 
recording_path 

Definition at line 62 of file CRovio.h.

Constructor & Destructor Documentation

◆ CRovio()

CRovio::CRovio ( )
default

◆ ~CRovio()

CRovio::~CRovio ( )
virtual

Definition at line 509 of file CRovio.cpp.

References isVideoStreamming(), and stop_video().

Here is the call graph for this function:

Member Function Documentation

◆ captureImageAsync()

bool CRovio::captureImageAsync ( mrpt::img::CImage out_img,
bool  recttified 
)

Returns a snapshot from Rovio, if rectified is set true, the returned image is rectified with the parameters of intrinsic_matrix and distortion_matrix.

This function works asynchronously and does not need to have enabled the live video streaming.

Returns
False on error
See also
captureImageSync

Definition at line 344 of file CRovio.cpp.

References mrpt::hwdrivers::CRovio::TOptions::cameraParams, mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, mrpt::img::CImage::loadFromStreamAsJPEG(), options, mrpt::hwdrivers::CRovio::TOptions::password, mrpt::img::CImage::undistort(), and mrpt::hwdrivers::CRovio::TOptions::user.

Here is the call graph for this function:

◆ general_command()

bool CRovio::general_command ( int  act,
std::string &  response,
std::string &  errormsg 
)
private

Definition at line 106 of file CRovio.cpp.

References mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, options, mrpt::hwdrivers::CRovio::TOptions::password, and mrpt::hwdrivers::CRovio::TOptions::user.

Referenced by getEncoders(), getPosition(), getRovioState(), and pathGetList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEncoders()

bool CRovio::getEncoders ( TEncoders encoders)

Returns a TEncoders with information of Rovio encoders (since last read, it seems Rovio is continuously reading with unknown sample time)

Returns
False on error

Definition at line 403 of file CRovio.cpp.

References convertToLong(), encoders, mrpt::obs::gnss::error, general_command(), mrpt::hwdrivers::CRovio::TEncoders::left, and mrpt::system::os::strcpy().

Here is the call graph for this function:

◆ getNextImageSync()

bool CRovio::getNextImageSync ( mrpt::obs::CObservationImage::Ptr lastImage)

Returns the next frame from Rovio's live video stream, after starting the live streaming with retrieve_video()

Returns
False on error
See also
retrieve_video, captureImageAsync

Definition at line 325 of file CRovio.cpp.

References buffer_img, buffer_img_cs, and isVideoStreamming().

Here is the call graph for this function:

◆ getPosition()

bool CRovio::getPosition ( mrpt::math::TPose2D out_pose)

Returns the Rovio's pose.

Returns
False on error

Definition at line 471 of file CRovio.cpp.

References general_command(), mrpt::math::TPose2D::phi, mrpt::system::os::strcpy(), mrpt::math::TPose2D::x, and mrpt::math::TPose2D::y.

Here is the call graph for this function:

◆ getRovioState()

bool CRovio::getRovioState ( TRovioState state)

Returns a TRovioState with internal information of Rovio (State, Navigation Signal Strength, Wifi Signal Strength)

Returns
False on error

Definition at line 369 of file CRovio.cpp.

References mrpt::obs::gnss::error, general_command(), mrpt::system::os::strcpy(), and mrpt::math::TPose2D::x.

Here is the call graph for this function:

◆ goHome()

bool CRovio::goHome ( bool  dock,
int  speed = 5 
)

goHome(bool dock) drives Rovio in front of charging station if the paremeter dock is set to false, otherwise it also docks

Returns
False on error

Definition at line 191 of file CRovio.cpp.

References send_cmd_action().

Here is the call graph for this function:

◆ initialize()

void CRovio::initialize ( )

Establish Connection with Rovio and log in its system: Important, fill out "options" members BEFORE calling this method.

Exceptions
std::runtimeOn errors

Definition at line 51 of file CRovio.cpp.

References mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, options, mrpt::hwdrivers::CRovio::TOptions::password, THROW_EXCEPTION_FMT, and mrpt::hwdrivers::CRovio::TOptions::user.

Here is the call graph for this function:

◆ isVideoStreamming()

bool CRovio::isVideoStreamming ( ) const

Return true if video is streaming correctly.

See also
retrieve_video

Definition at line 307 of file CRovio.cpp.

References m_videoThread, and m_videothread_finished.

Referenced by getNextImageSync(), stop_video(), and ~CRovio().

Here is the caller graph for this function:

◆ loadConfig()

void CRovio::loadConfig ( const mrpt::config::CConfigFileBase configSource,
const std::string &  section 
)

Loads the rovio camera calibration parameters (of leave the default ones if not found) (See CGenericSensor), then call to "loadConfig_sensorSpecific".

Exceptions
Thismethod throws an exception with a descriptive message if some critical parameter is missing or has an invalid value.

Definition at line 202 of file CRovio.cpp.

References mrpt::hwdrivers::CRovio::TOptions::cameraParams, mrpt::img::TCamera::loadFromConfigFile(), and options.

Here is the call graph for this function:

◆ move()

bool CRovio::move ( char  direction,
int  speed = 5 
)

move send Rovio the command to move in the specified direcction

Parameters
direction'f'->forward, 'b'->backward, 'r'->right, 'l'->left
Returns
False on error

Definition at line 118 of file CRovio.cpp.

References send_cmd_action().

Here is the call graph for this function:

◆ path_management() [1/2]

bool CRovio::path_management ( int  act)
private

Definition at line 82 of file CRovio.cpp.

References mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, options, mrpt::hwdrivers::CRovio::TOptions::password, and mrpt::hwdrivers::CRovio::TOptions::user.

Referenced by pathDelete(), pathRecord(), pathRecordAbort(), pathRecordSave(), pathRunBackward(), pathRunForward(), pathRunPause(), and pathRunStop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_management() [2/2]

bool CRovio::path_management ( int  act,
const std::string &  path_name 
)
private

Definition at line 92 of file CRovio.cpp.

References mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, options, mrpt::hwdrivers::CRovio::TOptions::password, and mrpt::hwdrivers::CRovio::TOptions::user.

Here is the call graph for this function:

◆ pathDelete()

bool CRovio::pathDelete ( const std::string &  path_name)

Definition at line 164 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathGetList()

bool CRovio::pathGetList ( std::string &  path_list)

Get list of saved paths.

Definition at line 168 of file CRovio.cpp.

References mrpt::obs::gnss::error, and general_command().

Here is the call graph for this function:

◆ pathRecord()

bool CRovio::pathRecord ( )

Definition at line 158 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathRecordAbort()

bool CRovio::pathRecordAbort ( )

Definition at line 159 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathRecordSave()

bool CRovio::pathRecordSave ( const std::string &  path_name)

Definition at line 160 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathRename()

bool CRovio::pathRename ( const std::string &  old_name,
const std::string &  new_name 
)

Definition at line 178 of file CRovio.cpp.

References mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, options, mrpt::hwdrivers::CRovio::TOptions::password, and mrpt::hwdrivers::CRovio::TOptions::user.

Here is the call graph for this function:

◆ pathRunBackward()

bool CRovio::pathRunBackward ( )

Definition at line 175 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathRunForward()

bool CRovio::pathRunForward ( )

Definition at line 174 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathRunPause()

bool CRovio::pathRunPause ( )

Definition at line 177 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ pathRunStop()

bool CRovio::pathRunStop ( )

Definition at line 176 of file CRovio.cpp.

References path_management().

Here is the call graph for this function:

◆ retrieve_video()

bool CRovio::retrieve_video ( )

This function launchs a thread with the function "thread_video()" which gets frames into a buffer.

After calling this method, images can be obtained with getNextImageSync()

Returns
False on error
See also
getNextImageSync

Definition at line 278 of file CRovio.cpp.

References m_videoThread, m_videothread_finished, m_videothread_initialized_done, m_videothread_initialized_error, m_videothread_must_exit, and thread_video().

Here is the call graph for this function:

◆ rotate()

bool CRovio::rotate ( char  direction,
int  speed = 5 
)

rotate send Rovio the command to rotate in the specified direcction 'r'->right, 'l'->left

Returns
False on error

Definition at line 136 of file CRovio.cpp.

References send_cmd_action().

Here is the call graph for this function:

◆ send_cmd_action()

bool CRovio::send_cmd_action ( int  act,
int  speed 
)
private

Definition at line 69 of file CRovio.cpp.

References mrpt::format(), mrpt::comms::net::http_get(), mrpt::hwdrivers::CRovio::TOptions::IP, options, mrpt::hwdrivers::CRovio::TOptions::password, and mrpt::hwdrivers::CRovio::TOptions::user.

Referenced by goHome(), move(), rotate(), takeHeadDown(), takeHeadMiddle(), and takeHeadUp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_video()

bool CRovio::stop_video ( )

This function stops and joins the thread launched by "retrieve_video()".

Returns
False on error

Definition at line 312 of file CRovio.cpp.

References isVideoStreamming(), m_videoThread, and m_videothread_must_exit.

Referenced by ~CRovio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ takeHeadDown()

bool CRovio::takeHeadDown ( )

Definition at line 154 of file CRovio.cpp.

References send_cmd_action().

Here is the call graph for this function:

◆ takeHeadMiddle()

bool CRovio::takeHeadMiddle ( )

Definition at line 153 of file CRovio.cpp.

References send_cmd_action().

Here is the call graph for this function:

◆ takeHeadUp()

bool CRovio::takeHeadUp ( )

Head positions.

Returns
False on error

Definition at line 152 of file CRovio.cpp.

References send_cmd_action().

Here is the call graph for this function:

◆ thread_video()

void CRovio::thread_video ( )
private

This function takes a frame and waits until getLastImage ask for it, and so on.

Definition at line 213 of file CRovio.cpp.

References buffer_img, buffer_img_cs, mrpt::hwdrivers::CRovio::TOptions::cameraParams, mrpt::hwdrivers::CFFMPEG_InputStream::close(), mrpt::format(), mrpt::hwdrivers::CRovio::TOptions::IP, m_videothread_finished, m_videothread_initialized_done, m_videothread_initialized_error, m_videothread_must_exit, mrpt::hwdrivers::CFFMPEG_InputStream::openURL(), options, and mrpt::hwdrivers::CFFMPEG_InputStream::retrieveFrame().

Referenced by retrieve_video().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ buffer_img

mrpt::obs::CObservationImage::Ptr mrpt::hwdrivers::CRovio::buffer_img
private

Definition at line 34 of file CRovio.h.

Referenced by getNextImageSync(), and thread_video().

◆ buffer_img_cs

std::mutex mrpt::hwdrivers::CRovio::buffer_img_cs
private

Definition at line 35 of file CRovio.h.

Referenced by getNextImageSync(), and thread_video().

◆ encoders

struct mrpt::hwdrivers::CRovio::TEncoders mrpt::hwdrivers::CRovio::encoders

Referenced by getEncoders().

◆ m_videoThread

std::thread mrpt::hwdrivers::CRovio::m_videoThread
private

Definition at line 28 of file CRovio.h.

Referenced by isVideoStreamming(), retrieve_video(), and stop_video().

◆ m_videothread_finished

bool mrpt::hwdrivers::CRovio::m_videothread_finished
private

Definition at line 32 of file CRovio.h.

Referenced by isVideoStreamming(), retrieve_video(), and thread_video().

◆ m_videothread_initialized_done

bool mrpt::hwdrivers::CRovio::m_videothread_initialized_done
private

Definition at line 30 of file CRovio.h.

Referenced by retrieve_video(), and thread_video().

◆ m_videothread_initialized_error

bool mrpt::hwdrivers::CRovio::m_videothread_initialized_error
private

Definition at line 31 of file CRovio.h.

Referenced by retrieve_video(), and thread_video().

◆ m_videothread_must_exit

bool mrpt::hwdrivers::CRovio::m_videothread_must_exit
private

Definition at line 29 of file CRovio.h.

Referenced by retrieve_video(), stop_video(), and thread_video().

◆ options

struct mrpt::hwdrivers::CRovio::TOptions mrpt::hwdrivers::CRovio::options



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020