The ChirpNetworkController class handles the controller messages the Chirp robot accepts. More...
#include <chirpnetworkcontroller.h>
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... | |
![]() | |
Controller (QObject *parent=0) | |
virtual | ~Controller () |
Private Member Functions | |
QByteArray | handleSetSpeedMessage (QTextStream &stream) |
QByteArray | handleGetSensorsMessage () |
Private Attributes | |
quint32 | _id |
Chirp * | _robot |
QVector< QString > | _acceptedMessages |
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.
ChirpNetworkController::ChirpNetworkController | ( | Chirp * | robot) |
Constructs a ChirpNetworkController object and sets its assigned robot.
robot | Robot this controller is assigned to. |
References _acceptedMessages, _robot, GETSENSORS, and SETSPEED.
|
private |
References _robot, and Chirp::sensors().
Referenced by handleMessage().
|
virtual |
Main entry point for the controller. Handles setspeed and getsensor messages.
stream | QTextStream wrapping the message sent over UDP. Allows for partial consumation of message. |
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.
|
private |
References _robot, and Chirp::setSpeed().
Referenced by handleMessage().
|
private |
Referenced by ChirpNetworkController(), and handleMessage().
|
private |
|
private |
Referenced by ChirpNetworkController(), handleGetSensorsMessage(), and handleSetSpeedMessage().