gusimplewhiteboard
guWhiteboard::NXT_Interface Class Reference

Class for interacting with and reading the values of NXT sensors and motors. More...

#include <NXT_Interface.hpp>

Inheritance diagram for guWhiteboard::NXT_Interface:
Collaboration diagram for guWhiteboard::NXT_Interface:

Public Member Functions

 NXT_Interface ()
 default constructor More...
 
bool operator== (const NXT_Interface &s)
 comparison operator More...
 
bool operator!= (const NXT_Interface &s)
 return false if the two interfaces are the same More...
 
 NXT_Interface (const std::string &str)
 string constructor (see from_string() below) More...
 
void from_string (const std::string &str)
 parse class properties from a string More...
 
std::string description () const
 pretty print method for showing the current property values More...
 
- Public Member Functions inherited from wb_nxt_interface
 ARRAY_PROPERTY (struct nxt_port_object, objects, NUMBER_OF_NXT_PORTS) wb_nxt_interface()
 An array of sensors and motors plugged into the nxt ports. More...
 

Detailed Description

Class for interacting with and reading the values of NXT sensors and motors.

Examples

Get the state of a touch sensor plugged into port 2 of the NXT

NXT_Interface i = NXT_Status_t.get();
fprintf(stderr, "Button state: %d", i.objects(Port2).data().pressed());

Tell motor B to go 75 percent of its maximum speed forwards

NXT_Interface i;
i.set_objects(MotorB);  !!TODO: Fix this example
fprintf(stderr, "Number of button presses: %d", i.but0());

Definition at line 38 of file NXT_Interface.hpp.

Constructor & Destructor Documentation

◆ NXT_Interface() [1/2]

guWhiteboard::NXT_Interface::NXT_Interface ( )
inline

default constructor

Definition at line 44 of file NXT_Interface.hpp.

◆ NXT_Interface() [2/2]

guWhiteboard::NXT_Interface::NXT_Interface ( const std::string &  str)
inline

string constructor (see from_string() below)

Parameters
[in]stra serialised string containing properties to set in this class

Definition at line 100 of file NXT_Interface.hpp.

References from_string().

Member Function Documentation

◆ description()

std::string guWhiteboard::NXT_Interface::description ( ) const
inline

pretty print method for showing the current property values

Returns
pretty printed string

Definition at line 114 of file NXT_Interface.hpp.

References Active_Light_Sensor, Motor, NUMBER_OF_NXT_PORTS, Passive_Light_Sensor, PORT, Port1, Sonar_Sensor, and Touch_Sensor.

◆ from_string()

void guWhiteboard::NXT_Interface::from_string ( const std::string &  str)
inline

parse class properties from a string

Parameters
[in]stra serialised string containing properties to set in this class

Definition at line 105 of file NXT_Interface.hpp.

Referenced by NXT_Interface().

◆ operator!=()

bool guWhiteboard::NXT_Interface::operator!= ( const NXT_Interface s)
inline

return false if the two interfaces are the same

Definition at line 91 of file NXT_Interface.hpp.

◆ operator==()

bool guWhiteboard::NXT_Interface::operator== ( const NXT_Interface s)
inline

comparison operator

Definition at line 48 of file NXT_Interface.hpp.

References Active_Light_Sensor, Motor, NUMBER_OF_NXT_PORTS, Passive_Light_Sensor, Port1, Sonar_Sensor, and Touch_Sensor.


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