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