9#ifndef NXT_Interface_DEFINED
10#define NXT_Interface_DEFINED
14#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
54 if(o.type() != n.type())
56#define PORT "(" << p << ")"
58#pragma clang diagnostic push
59#pragma clang diagnostic ignored "-Wswitch-enum"
63 if(o.data().touch_sensor.pressed() != n.data().touch_sensor.pressed())
67 if(o.data().sonar_sensor.distance() != n.data().sonar_sensor.distance())
71 if(o.data().active_light_sensor.value() != n.data().active_light_sensor.value())
75 if(o.data().passive_light_sensor.value() != n.data().passive_light_sensor.value())
79 if(o.data().motor.speed() != n.data().motor.speed() || o.data().motor.enc_ticks() != n.data().motor.enc_ticks() || o.data().motor.speed_mask() != n.data().motor.speed_mask() || o.data().motor.enc_ticks_mask() != n.data().motor.enc_ticks_mask())
85#pragma clang diagnostic pop
96#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
108 fprintf(stderr,
"NXT_Interface doesn't implement from_string yet, have it back %s\n", str.c_str());
116 std::stringstream ss;
120#define PORT "(" << p << ")"
122#pragma clang diagnostic push
123#pragma clang diagnostic ignored "-Wswitch-enum"
127 ss <<
PORT <<
"Touch: " << o.data().touch_sensor.pressed() <<
", ";
130 ss <<
PORT <<
"Sonar: " <<
static_cast<int>(o.data().sonar_sensor.distance()) <<
", ";
133 ss <<
PORT <<
"Active Light: " << o.data().active_light_sensor.value() <<
", ";
136 ss <<
PORT <<
"Passive Light: " << o.data().passive_light_sensor.value() <<
", ";
139 ss <<
PORT <<
"Motor: (s: " << o.data().motor.speed() <<
", enc: " << o.data().motor.enc_ticks() <<
"), ";
144#pragma clang diagnostic pop
Class for interacting with and reading the values of NXT sensors and motors.
void from_string(const std::string &str)
parse class properties from a string
NXT_Interface(const std::string &str)
string constructor (see from_string() below)
std::string description() const
pretty print method for showing the current property values
bool operator!=(const NXT_Interface &s)
return false if the two interfaces are the same
bool operator==(const NXT_Interface &s)
comparison operator
NXT_Interface()
default constructor
An object that contains the type and data of an nxt sensor.
Interface for talking with an NXT.