Regilo
A simple C++ library for controlling the Neato XV robot and the Hokuyo scanner.
regilo::NeatoController< ProtocolController > Class Template Reference

The NeatoController class is used to communicate with the Neato robot. More...

#include <neatocontroller.hpp>

Inheritance diagram for regilo::NeatoController< ProtocolController >:
regilo::INeatoController regilo::ScanController< ProtocolController > regilo::IScanController regilo::IScanController regilo::IController regilo::IController

Public Member Functions

 NeatoController ()
 Default constructor.
 
 NeatoController (const std::string &logPath)
 Constructor with a log file specified by a path. More...
 
 NeatoController (std::iostream &logStream)
 Constructor with a log specified by a stream. More...
 
virtual ~NeatoController ()=default
 Default destructor.
 
virtual bool getTestMode () const override
 Get whether the Neato is in the test mode. More...
 
virtual void setTestMode (bool testMode) override
 Set or unset the test mode. More...
 
virtual bool getLdsRotation () const override
 Get whether the Neato has LDS rotation on or off. More...
 
virtual void setLdsRotation (bool ldsRotation) override
 Set LDS rotation on or off. More...
 
virtual void setMotor (int left, int right, int speed) override
 Set the specified motor to run in a direction at a requested speed. More...
 
virtual std::string getTime () override
 Get the current scheduler time. More...
 
- Public Member Functions inherited from regilo::INeatoController
virtual ~INeatoController ()=default
 Default destructor.
 
- Public Member Functions inherited from regilo::IScanController
virtual ~IScanController ()=default
 Default destructor.
 
- Public Member Functions inherited from regilo::IController
virtual ~IController ()=default
 Default destructor.
 
virtual void connect (const std::string &endpoint)=0
 Connect the controller to a device. More...
 
virtual bool isConnected () const =0
 Test if the controller is connected. More...
 
virtual std::string getEndpoint () const =0
 Get the endpoint of device. More...
 
virtual std::shared_ptr< ILoggetLog ()=0
 Get the current Log. More...
 
virtual std::shared_ptr< const ILoggetLog () const =0
 Get the current Log (a const variant). More...
 
virtual void setLog (std::shared_ptr< ILog > log)=0
 Set a Log (it can be shared between more controllers). More...
 
virtual std::string sendCommand (const std::string &command)=0
 Send a command to the device. More...
 
- Public Member Functions inherited from regilo::ScanController< ProtocolController >
virtual ~ScanController ()=default
 Default destructor.
 
virtual ScanData getScan (bool fromDevice=true) override final
 Get a scan from the device. More...
 

Static Public Attributes

static std::string ON = "on"
 A string that represents the ON value.
 
static std::string OFF = "off"
 A string that represents the OFF value.
 
static std::string LDS_SCAN_HEADER = "AngleInDegrees,DistInMM,Intensity,ErrorCodeHEX"
 A header of the LDS scan output.
 
static std::string LDS_SCAN_FOOTER = "ROTATION_SPEED,"
 A footer of the LDS scan output.
 
static std::string CMD_TEST_MODE = "testmode %s"
 A template for the testmode command.
 
static std::string CMD_SET_LDS_ROTATION = "setldsrotation %s"
 A template for the setldsrotation command.
 
static std::string CMD_SET_MOTOR = "setmotor %d %d %d"
 A template for the setmotor command.
 
static std::string CMD_GET_TIME = "gettime"
 A template for the gettime command.
 
static std::string CMD_GET_LDS_SCAN = "getldsscan"
 A template for the getldsscan command.
 

Protected Member Functions

virtual std::string getScanCommand () const override
 Get a string that can be used for getting a scan. More...
 
virtual bool parseScanData (std::istream &in, ScanData &data) override
 Parse the raw scan data. More...
 

Additional Inherited Members

- Protected Attributes inherited from regilo::ScanController< ProtocolController >
std::size_t lastScanId = 0
 A scan id (starting from zero) that is used for new scans.
 

Detailed Description

template<typename ProtocolController>
class regilo::NeatoController< ProtocolController >

The NeatoController class is used to communicate with the Neato robot.

Constructor & Destructor Documentation

template<typename ProtocolController >
regilo::NeatoController< ProtocolController >::NeatoController ( const std::string &  logPath)

Constructor with a log file specified by a path.

Parameters
logPathPath to the log file.
template<typename ProtocolController >
regilo::NeatoController< ProtocolController >::NeatoController ( std::iostream &  logStream)

Constructor with a log specified by a stream.

Parameters
logStreamThe log stream.

Member Function Documentation

template<typename ProtocolController >
virtual bool regilo::NeatoController< ProtocolController >::getLdsRotation ( ) const
inlineoverridevirtual

Get whether the Neato has LDS rotation on or off.

Returns
True if the LIDAR is rotating.

Implements regilo::INeatoController.

template<typename ProtocolController >
virtual std::string regilo::NeatoController< ProtocolController >::getScanCommand ( ) const
inlineoverrideprotectedvirtual

Get a string that can be used for getting a scan.

Returns
A command for getting a scan.

Implements regilo::ScanController< ProtocolController >.

template<typename ProtocolController >
virtual bool regilo::NeatoController< ProtocolController >::getTestMode ( ) const
inlineoverridevirtual

Get whether the Neato is in the test mode.

Returns
True if the Neato is in the test mode.

Implements regilo::INeatoController.

template<typename ProtocolController >
std::string regilo::NeatoController< ProtocolController >::getTime ( )
overridevirtual

Get the current scheduler time.

Returns
"DayOfWeek HourOf24:Min:Sec" (example: "Sunday 13:57:09").

Implements regilo::INeatoController.

template<typename ProtocolController >
bool regilo::NeatoController< ProtocolController >::parseScanData ( std::istream &  in,
ScanData data 
)
overrideprotectedvirtual

Parse the raw scan data.

Parameters
inThe input stream that stores the raw scan data.
dataOutput for the scanned data.
Returns
True if the parsing ends without an error.

Implements regilo::ScanController< ProtocolController >.

template<typename ProtocolController >
void regilo::NeatoController< ProtocolController >::setLdsRotation ( bool  ldsRotation)
overridevirtual

Set LDS rotation on or off.

Parameters
ldsRotationTrue for starting the LIDAR rotation.

Implements regilo::INeatoController.

template<typename ProtocolController >
void regilo::NeatoController< ProtocolController >::setMotor ( int  left,
int  right,
int  speed 
)
overridevirtual

Set the specified motor to run in a direction at a requested speed.

Parameters
leftDistance in millimeters to drive the left wheel (pos = forward, neg = backward).
rightDistance in millimeters to drive the right wheel (pos = forward, neg = backward).
speedSpeed in millimeters/second.

Implements regilo::INeatoController.

template<typename ProtocolController >
void regilo::NeatoController< ProtocolController >::setTestMode ( bool  testMode)
overridevirtual

Set or unset the test mode.

Parameters
testModeTrue for setting the test mode.

Implements regilo::INeatoController.


The documentation for this class was generated from the following file: