ChirpSim
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ChirpNetworkController Class Reference

The ChirpNetworkController class handles the controller messages the Chirp robot accepts. More...

#include <chirpnetworkcontroller.h>

Inheritance diagram for ChirpNetworkController:
Inheritance graph

Public Member Functions

 ChirpNetworkController (Chirp *robot)
 Constructs a ChirpNetworkController object and sets its assigned robot. More...
 
virtual QByteArray handleMessage (QTextStream &stream)
 Main entry point for the controller. Handles setspeed and getsensor messages. More...
 
- Public Member Functions inherited from Controller
 Controller (QObject *parent=0)
 
virtual ~Controller ()
 

Private Member Functions

QByteArray handleSetSpeedMessage (QTextStream &stream)
 
QByteArray handleGetSensorsMessage ()
 

Private Attributes

quint32 _id
 
Chirp_robot
 
QVector< QString > _acceptedMessages
 

Detailed Description

The ChirpNetworkController class handles the controller messages the Chirp robot accepts.

The ChirpNetworkController class handles the controller messages the Chirp robot accepts. The two current messages allowed are the "setspeed"-message and the "getsensors"-message. The former lets controllers set the speed of each wheel on the robot, effectively controlling the robot's movement. The latter lets controllers read the distance sensors on the robot.

Constructor & Destructor Documentation

ChirpNetworkController::ChirpNetworkController ( Chirp robot)

Constructs a ChirpNetworkController object and sets its assigned robot.

Parameters
robotRobot this controller is assigned to.

References _acceptedMessages, _robot, GETSENSORS, and SETSPEED.

Member Function Documentation

QByteArray ChirpNetworkController::handleGetSensorsMessage ( )
private

References _robot, and Chirp::sensors().

Referenced by handleMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

QByteArray ChirpNetworkController::handleMessage ( QTextStream &  stream)
virtual

Main entry point for the controller. Handles setspeed and getsensor messages.

Parameters
streamQTextStream wrapping the message sent over UDP. Allows for partial consumation of message.
Returns
Utf8 string with either the expected response from the message handler, or a utf8 string containing "error" to mark that a failure occured.

The full setspeed message as sent over UDP follows this template:

<id> setspeed <left wheel speed> <right wheel speed>

return

ok


The full getsensors message as sent over UDP follows this template:

<id> getsensors

return

ok <sensor 1> <sensor 2> ... <sensor 8>

Implements Controller.

References _acceptedMessages, GETSENSORS, handleGetSensorsMessage(), handleSetSpeedMessage(), and SETSPEED.

Here is the call graph for this function:

QByteArray ChirpNetworkController::handleSetSpeedMessage ( QTextStream &  stream)
private

References _robot, and Chirp::setSpeed().

Referenced by handleMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QVector<QString> ChirpNetworkController::_acceptedMessages
private
quint32 ChirpNetworkController::_id
private
Chirp* ChirpNetworkController::_robot
private

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