Completed things docs
This commit is contained in:
parent
75a0cf350d
commit
4db9164f2a
1
Thing.h
1
Thing.h
@ -36,6 +36,7 @@ class Thing {
|
||||
Roboid,
|
||||
Humanoid,
|
||||
ExternalSensor,
|
||||
DifferentialDrive
|
||||
};
|
||||
|
||||
#pragma region Init
|
||||
|
@ -1,10 +1,13 @@
|
||||
#include "DifferentialDrive.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
DifferentialDrive::DifferentialDrive() : Thing() {}
|
||||
|
||||
RoboidControl::DifferentialDrive::DifferentialDrive(Participant* participant)
|
||||
: Thing(participant) {}
|
||||
DifferentialDrive::DifferentialDrive() : Thing(Thing::Type::DifferentialDrive) {}
|
||||
|
||||
DifferentialDrive::DifferentialDrive(Participant* participant, unsigned char thingId)
|
||||
: Thing(participant, Thing::Type::DifferentialDrive, thingId) {}
|
||||
|
||||
DifferentialDrive::DifferentialDrive(Thing* parent, unsigned char thingId) : Thing(parent, Thing::Type::DifferentialDrive, thingId) {}
|
||||
|
||||
void DifferentialDrive::SetDriveDimensions(float wheelDiameter,
|
||||
float wheelSeparation) {
|
||||
|
@ -13,7 +13,14 @@ class DifferentialDrive : public Thing {
|
||||
DifferentialDrive();
|
||||
/// @brief Create a differential drive with networking support
|
||||
/// @param participant The local participant
|
||||
DifferentialDrive(Participant* participant);
|
||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||
/// an ID
|
||||
DifferentialDrive(Participant* participant, unsigned char thingId = 0);
|
||||
/// @brief Create a new child differential drive
|
||||
/// @param parent The parent thing
|
||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||
/// an ID
|
||||
DifferentialDrive(Thing* parent, unsigned char thingId = 0);
|
||||
|
||||
/// @brief Configures the dimensions of the drive
|
||||
/// @param wheelDiameter The diameter of the wheels in meters
|
||||
@ -33,7 +40,6 @@ class DifferentialDrive : public Thing {
|
||||
/// Positive moves the robot in the forward direction.
|
||||
/// @param speedRight The speed of the right wheel in degrees per second.
|
||||
/// Positive moves the robot in the forward direction.
|
||||
|
||||
void SetWheelVelocity(float speedLeft, float speedRight);
|
||||
|
||||
/// @copydoc RoboidControl::Thing::Update(unsigned long)
|
||||
|
@ -2,8 +2,21 @@
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
//DigitalSensor::DigitalSensor() {}
|
||||
DigitalSensor::DigitalSensor() : Thing(Type::Switch) {}
|
||||
|
||||
DigitalSensor::DigitalSensor(Participant* participant, unsigned char networkId, unsigned char thingId) : Thing(participant) {}
|
||||
DigitalSensor::DigitalSensor(Participant* owner, unsigned char thingId)
|
||||
: Thing(owner, Type::Switch, thingId) {}
|
||||
|
||||
DigitalSensor::DigitalSensor(Thing* parent, unsigned char thingId)
|
||||
: Thing(parent, Type::Switch) {}
|
||||
|
||||
int DigitalSensor::GenerateBinary(char* bytes, unsigned char* ix) {
|
||||
bytes[(*ix)++] = state ? 1 : 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void DigitalSensor::ProcessBinary(char* bytes) {
|
||||
this->state |= (bytes[0] == 1);
|
||||
}
|
||||
|
||||
} // namespace RoboidControl
|
||||
|
@ -7,15 +7,30 @@ namespace RoboidControl {
|
||||
/// @brief A digital (on/off, 1/0, true/false) sensor
|
||||
class DigitalSensor : public Thing {
|
||||
public:
|
||||
/// @brief Create a digital sensor without communication abilities
|
||||
DigitalSensor();
|
||||
/// @brief Create a digital sensor for a participant
|
||||
/// @param owner The owning participant
|
||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||
/// an ID
|
||||
DigitalSensor(Participant* owner, unsigned char thingId = 0);
|
||||
/// @brief Create a new child digital sensor
|
||||
/// @param parent The parent thing
|
||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||
/// an ID
|
||||
DigitalSensor(Thing* parent, unsigned char thingId = 0);
|
||||
|
||||
/// @brief The sigital state
|
||||
bool state = 0;
|
||||
|
||||
/// @brief The default constructor
|
||||
//DigitalSensor();
|
||||
/// @brief Create a temperature sensor with the given ID
|
||||
/// @param networkId The network ID of the sensor
|
||||
/// @param thingId The ID of the thing
|
||||
DigitalSensor(Participant* participant, unsigned char networkId, unsigned char thingId);
|
||||
/// @brief Function used to generate binary data for this digital sensor
|
||||
/// @param buffer The byte array for thw binary data
|
||||
/// @param ix The starting position for writing the binary data
|
||||
int GenerateBinary(char* bytes, unsigned char* ix) override;
|
||||
/// @brief Function used to process binary data received for this digital
|
||||
/// sensor
|
||||
/// @param bytes The binary data to process
|
||||
virtual void ProcessBinary(char* bytes) override;
|
||||
};
|
||||
|
||||
} // namespace RoboidControl
|
||||
|
@ -7,9 +7,6 @@ namespace RoboidControl {
|
||||
/// @brief A temperature sensor
|
||||
class TemperatureSensor : public Thing {
|
||||
public:
|
||||
/// @brief The measured temperature
|
||||
float temperature = 0;
|
||||
|
||||
/// @brief The default constructor
|
||||
//TemperatureSensor();
|
||||
/// @brief Create a temperature sensor with the given ID
|
||||
@ -17,6 +14,9 @@ class TemperatureSensor : public Thing {
|
||||
/// @param thingId The ID of the thing
|
||||
TemperatureSensor(Participant* participant, unsigned char thingId);
|
||||
|
||||
/// @brief The measured temperature
|
||||
float temperature = 0;
|
||||
|
||||
/// @brief Manually override the measured temperature
|
||||
/// @param temperature The new temperature
|
||||
virtual void SetTemperature(float temperature);
|
||||
|
@ -1,22 +1,22 @@
|
||||
#include "TouchSensor.h"
|
||||
|
||||
namespace RoboidControl {
|
||||
|
||||
TouchSensor::TouchSensor() : Thing(Thing::Type::TouchSensor) {}
|
||||
|
||||
TouchSensor::TouchSensor(Participant* participant)
|
||||
: Thing(participant, Thing::Type::TouchSensor) {}
|
||||
TouchSensor::TouchSensor(Participant* owner, unsigned char thingId)
|
||||
: Thing(owner, Thing::Type::TouchSensor, thingId) {}
|
||||
|
||||
TouchSensor::TouchSensor(Thing* parent) : Thing(parent->owner) {
|
||||
TouchSensor::TouchSensor(Thing* parent, unsigned char thingId) : Thing(parent->owner, Thing::Type::TouchSensor, thingId) {
|
||||
this->SetParent(parent);
|
||||
}
|
||||
|
||||
int TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) {
|
||||
return 0;
|
||||
bytes[(*ix)++] = touchedSomething ? 1 : 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void TouchSensor::ProcessBinary(char* bytes) {
|
||||
if (bytes[0] == 1)
|
||||
std::cout << this->GetName() << " is Touching something!\n";
|
||||
this->touchedSomething |= (bytes[0] == 1);
|
||||
}
|
||||
|
||||
|
@ -6,31 +6,31 @@ namespace RoboidControl {
|
||||
|
||||
/// @brief A sensor which can detect touches
|
||||
class TouchSensor : public Thing {
|
||||
// Why finishing this release (0.3), I notice that this is equivalent to a digital sensor
|
||||
public:
|
||||
// Inherit all constructors
|
||||
using Thing::Thing;
|
||||
|
||||
/// @brief Create a touch sensor with isolated participant
|
||||
/// @brief Create a touch sensor without communication abilities
|
||||
TouchSensor();
|
||||
/// @brief Create a touch sensor
|
||||
TouchSensor(Participant* participant);
|
||||
/// @brief Create a temperature sensor with the given ID
|
||||
/// @param networkId The network ID of the sensor
|
||||
/// @param thingId The ID of the thing
|
||||
TouchSensor(Thing* parent);
|
||||
// TouchSensor(RemoteParticipant* participant, unsigned char networkId,
|
||||
// unsigned char thingId);
|
||||
/// @brief Create a touch sensor for a participant
|
||||
/// @param owner The owning participant
|
||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||
/// an ID
|
||||
TouchSensor(Participant* owner, unsigned char thingId = 0);
|
||||
/// @brief Create a new child touch sensor
|
||||
/// @param parent The parent thing
|
||||
/// @param thingId The ID of the thing, leave out or set to zero to generate
|
||||
/// an ID
|
||||
TouchSensor(Thing* parent, unsigned char thingId = 0);
|
||||
|
||||
/// @brief Value which is true when the sensor is touching something, false
|
||||
/// otherwise
|
||||
bool touchedSomething = false;
|
||||
|
||||
/// @brief Function to create a binary message with the temperature
|
||||
/// @brief Function used to generate binary data for this touch sensor
|
||||
/// @param buffer The byte array for thw binary data
|
||||
/// @param ix The starting position for writing the binary data
|
||||
int GenerateBinary(char* bytes, unsigned char* ix) override;
|
||||
/// @brief Function to extract the temperature received in the binary message
|
||||
/// @param bytes The binary data
|
||||
/// @brief Function used to process binary data received for this touch sensor
|
||||
/// @param bytes The binary data to process
|
||||
virtual void ProcessBinary(char* bytes) override;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user