First udp communcation is working
This commit is contained in:
parent
7344fa676b
commit
cf31f2099a
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
bool StartWifi(const char *wifiSsid, const char *wifiPassword,
|
bool StartWifi(const char *wifiSsid, const char *wifiPassword,
|
||||||
bool hotspotFallback);
|
bool hotspotFallback = false);
|
||||||
|
|
||||||
void CheckFirmware(String url, String FIRMWARE_NAME, int FIRMWARE_VERSION);
|
void CheckFirmware(String url, String FIRMWARE_NAME, int FIRMWARE_VERSION);
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ bool Participant::Send(RemoteParticipant* remoteParticipant, int bufferSize) {
|
|||||||
udp.write((unsigned char*)buffer, bufferSize);
|
udp.write((unsigned char*)buffer, bufferSize);
|
||||||
udp.endPacket();
|
udp.endPacket();
|
||||||
|
|
||||||
// std::cout << "Sent to " << this->remoteIpAddress << ":"
|
std::cout << "Sent to " << remoteParticipant->ipAddress << ":"
|
||||||
// << this->remotePort << "\n";
|
<< remoteParticipant->port << "\n";
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,12 @@ protected:
|
|||||||
using DirectionSingle = DirectionOf<float>;
|
using DirectionSingle = DirectionOf<float>;
|
||||||
using Direction16 = DirectionOf<signed short>;
|
using Direction16 = DirectionOf<signed short>;
|
||||||
|
|
||||||
|
#if defined(ARDUINO)
|
||||||
|
using Direction = Direction16;
|
||||||
|
#else
|
||||||
|
using Direction = DirectionSingle;
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace LinearAlgebra
|
} // namespace LinearAlgebra
|
||||||
} // namespace Passer
|
} // namespace Passer
|
||||||
using namespace Passer::LinearAlgebra;
|
using namespace Passer::LinearAlgebra;
|
||||||
|
@ -180,6 +180,12 @@ using SphericalSingle = SphericalOf<float>;
|
|||||||
/// hardware
|
/// hardware
|
||||||
using Spherical16 = SphericalOf<signed short>;
|
using Spherical16 = SphericalOf<signed short>;
|
||||||
|
|
||||||
|
#if defined(ARDUINO)
|
||||||
|
using Spherical = Spherical16;
|
||||||
|
#else
|
||||||
|
using Spherical = SphericalSingle;
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace LinearAlgebra
|
} // namespace LinearAlgebra
|
||||||
} // namespace Passer
|
} // namespace Passer
|
||||||
using namespace Passer::LinearAlgebra;
|
using namespace Passer::LinearAlgebra;
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#include "NetworkIdMsg.h"
|
|
||||||
|
|
||||||
namespace RoboidControl {
|
|
||||||
|
|
||||||
NetworkIdMsg::NetworkIdMsg(const char* buffer) {
|
|
||||||
this->networkId = buffer[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkIdMsg::NetworkIdMsg(unsigned char networkId) {
|
|
||||||
this->networkId = networkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkIdMsg::~NetworkIdMsg() {}
|
|
||||||
|
|
||||||
unsigned char NetworkIdMsg::Serialize(char* buffer) {
|
|
||||||
unsigned char ix = 0;
|
|
||||||
buffer[ix++] = this->id;
|
|
||||||
buffer[ix++] = this->networkId;
|
|
||||||
return NetworkIdMsg::length;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace RoboidControl
|
|
22
Messages/SiteMsg.cpp
Normal file
22
Messages/SiteMsg.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "SiteMsg.h"
|
||||||
|
|
||||||
|
namespace RoboidControl {
|
||||||
|
|
||||||
|
SiteMsg::SiteMsg(const char* buffer) {
|
||||||
|
this->networkId = buffer[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
SiteMsg::SiteMsg(unsigned char networkId) {
|
||||||
|
this->networkId = networkId;
|
||||||
|
}
|
||||||
|
|
||||||
|
SiteMsg::~SiteMsg() {}
|
||||||
|
|
||||||
|
unsigned char SiteMsg::Serialize(char* buffer) {
|
||||||
|
unsigned char ix = 0;
|
||||||
|
buffer[ix++] = this->id;
|
||||||
|
buffer[ix++] = this->networkId;
|
||||||
|
return SiteMsg::length;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace RoboidControl
|
@ -3,7 +3,7 @@
|
|||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A message communicating the network ID for that participant
|
/// @brief A message communicating the network ID for that participant
|
||||||
class NetworkIdMsg : public IMessage {
|
class SiteMsg : public IMessage {
|
||||||
public:
|
public:
|
||||||
/// @brief The message ID
|
/// @brief The message ID
|
||||||
static const unsigned char id = 0xA1;
|
static const unsigned char id = 0xA1;
|
||||||
@ -14,11 +14,11 @@ public:
|
|||||||
|
|
||||||
/// @brief Create a new message for sending
|
/// @brief Create a new message for sending
|
||||||
/// @param networkId The network ID for the participant
|
/// @param networkId The network ID for the participant
|
||||||
NetworkIdMsg(unsigned char networkId);
|
SiteMsg(unsigned char networkId);
|
||||||
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
NetworkIdMsg(const char *buffer);
|
SiteMsg(const char *buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~NetworkIdMsg();
|
virtual ~SiteMsg();
|
||||||
|
|
||||||
/// @copydoc RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char *buffer) override;
|
virtual unsigned char Serialize(char *buffer) override;
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
Participant::Participant() {}
|
//Participant::Participant() {}
|
||||||
|
|
||||||
Participant::Participant(int port) {
|
Participant::Participant(int port) {
|
||||||
this->ipAddress = "0.0.0.0";
|
this->ipAddress = "0.0.0.0";
|
||||||
@ -82,7 +82,7 @@ void Participant::Update(unsigned long currentTimeMs) {
|
|||||||
ParticipantMsg* msg = new ParticipantMsg(this->networkId);
|
ParticipantMsg* msg = new ParticipantMsg(this->networkId);
|
||||||
this->Publish(msg);
|
this->Publish(msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
std::cout << this->name << " published ParticipantMsg\n";
|
//std::cout << this->name << " published ParticipantMsg\n";
|
||||||
this->nextPublishMe = currentTimeMs + this->publishInterval;
|
this->nextPublishMe = currentTimeMs + this->publishInterval;
|
||||||
}
|
}
|
||||||
this->ReceiveUDP();
|
this->ReceiveUDP();
|
||||||
@ -129,12 +129,12 @@ void Participant::SendThingInfo(RemoteParticipant* remoteParticipant, Thing* thi
|
|||||||
ThingMsg* thingMsg = new ThingMsg(this->networkId, thing);
|
ThingMsg* thingMsg = new ThingMsg(this->networkId, thing);
|
||||||
this->Send(remoteParticipant, thingMsg);
|
this->Send(remoteParticipant, thingMsg);
|
||||||
delete thingMsg;
|
delete thingMsg;
|
||||||
NameMsg* nameMsg = new NameMsg(this->networkId, thing);
|
// NameMsg* nameMsg = new NameMsg(this->networkId, thing);
|
||||||
this->Send(remoteParticipant, nameMsg);
|
// this->Send(remoteParticipant, nameMsg);
|
||||||
delete nameMsg;
|
// delete nameMsg;
|
||||||
ModelUrlMsg* modelMsg = new ModelUrlMsg(this->networkId, thing);
|
// ModelUrlMsg* modelMsg = new ModelUrlMsg(this->networkId, thing);
|
||||||
this->Send(remoteParticipant, modelMsg);
|
// this->Send(remoteParticipant, modelMsg);
|
||||||
delete modelMsg;
|
// delete modelMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Participant::PublishThingInfo(Thing* thing) {
|
void Participant::PublishThingInfo(Thing* thing) {
|
||||||
@ -199,8 +199,8 @@ void Participant::ReceiveData(unsigned char bufferSize, RemoteParticipant* remot
|
|||||||
Process(remoteParticipant, msg);
|
Process(remoteParticipant, msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
} break;
|
} break;
|
||||||
case NetworkIdMsg::id: {
|
case SiteMsg::id: {
|
||||||
NetworkIdMsg* msg = new NetworkIdMsg(this->buffer);
|
SiteMsg* msg = new SiteMsg(this->buffer);
|
||||||
Process(remoteParticipant, msg);
|
Process(remoteParticipant, msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
} break;
|
} break;
|
||||||
@ -234,7 +234,7 @@ void Participant::ReceiveData(unsigned char bufferSize, RemoteParticipant* remot
|
|||||||
|
|
||||||
void Participant::Process(RemoteParticipant* sender, ParticipantMsg* msg) {}
|
void Participant::Process(RemoteParticipant* sender, ParticipantMsg* msg) {}
|
||||||
|
|
||||||
void Participant::Process(RemoteParticipant* sender, NetworkIdMsg* msg) {
|
void Participant::Process(RemoteParticipant* sender, SiteMsg* msg) {
|
||||||
std::cout << this->name << ": process NetworkId [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
|
std::cout << this->name << ": process NetworkId [" << (int)this->networkId << "/" << (int)msg->networkId << "]\n";
|
||||||
if (this->networkId != msg->networkId) {
|
if (this->networkId != msg->networkId) {
|
||||||
this->networkId = msg->networkId;
|
this->networkId = msg->networkId;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "Messages/InvestigateMsg.h"
|
#include "Messages/InvestigateMsg.h"
|
||||||
#include "Messages/ModelUrlMsg.h"
|
#include "Messages/ModelUrlMsg.h"
|
||||||
#include "Messages/NameMsg.h"
|
#include "Messages/NameMsg.h"
|
||||||
#include "Messages/NetworkIdMsg.h"
|
#include "Messages/SiteMsg.h"
|
||||||
#include "Messages/ParticipantMsg.h"
|
#include "Messages/ParticipantMsg.h"
|
||||||
#include "Messages/PoseMsg.h"
|
#include "Messages/PoseMsg.h"
|
||||||
#include "Messages/ThingMsg.h"
|
#include "Messages/ThingMsg.h"
|
||||||
@ -30,12 +30,9 @@ class Participant : public RemoteParticipant {
|
|||||||
public:
|
public:
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
long publishInterval = 3000; // 3 seconds
|
long publishInterval = 3000; // 3 seconds
|
||||||
// unsigned char networkId = 0;
|
|
||||||
|
|
||||||
const char* name = "Participant";
|
const char* name = "Participant";
|
||||||
|
|
||||||
// const char *ipAddress = "0.0.0.0";
|
|
||||||
// int port = 0;
|
|
||||||
int localPort = 0;
|
int localPort = 0;
|
||||||
|
|
||||||
#if defined(ARDUINO)
|
#if defined(ARDUINO)
|
||||||
@ -57,8 +54,7 @@ class Participant : public RemoteParticipant {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Participant();
|
Participant(int port = 7681);
|
||||||
Participant(int port);
|
|
||||||
Participant(const char* ipAddress, int port);
|
Participant(const char* ipAddress, int port);
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
@ -66,12 +62,6 @@ class Participant : public RemoteParticipant {
|
|||||||
|
|
||||||
virtual void Update(unsigned long currentTimeMs = 0);
|
virtual void Update(unsigned long currentTimeMs = 0);
|
||||||
|
|
||||||
// std::list<Thing *> things;
|
|
||||||
// Thing *Get(unsigned char networkId, unsigned char thingId);
|
|
||||||
// int Add(Thing *thing);
|
|
||||||
// void Remove(Thing *thing);
|
|
||||||
// void UpdateAll(unsigned long currentTimeMs);
|
|
||||||
|
|
||||||
void SendThingInfo(RemoteParticipant* remoteParticipant, Thing* thing);
|
void SendThingInfo(RemoteParticipant* remoteParticipant, Thing* thing);
|
||||||
void PublishThingInfo(Thing* thing);
|
void PublishThingInfo(Thing* thing);
|
||||||
|
|
||||||
@ -93,7 +83,7 @@ class Participant : public RemoteParticipant {
|
|||||||
void ReceiveUDP();
|
void ReceiveUDP();
|
||||||
|
|
||||||
virtual void Process(RemoteParticipant* sender, ParticipantMsg* msg);
|
virtual void Process(RemoteParticipant* sender, ParticipantMsg* msg);
|
||||||
virtual void Process(RemoteParticipant* sender, NetworkIdMsg* msg);
|
virtual void Process(RemoteParticipant* sender, SiteMsg* msg);
|
||||||
virtual void Process(RemoteParticipant* sender, InvestigateMsg* msg);
|
virtual void Process(RemoteParticipant* sender, InvestigateMsg* msg);
|
||||||
virtual void Process(RemoteParticipant* sender, ThingMsg* msg);
|
virtual void Process(RemoteParticipant* sender, ThingMsg* msg);
|
||||||
virtual void Process(RemoteParticipant* sender, NameMsg* msg);
|
virtual void Process(RemoteParticipant* sender, NameMsg* msg);
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
DigitalSensor::DigitalSensor() {}
|
//DigitalSensor::DigitalSensor() {}
|
||||||
|
|
||||||
DigitalSensor::DigitalSensor(unsigned char networkId, unsigned char thingId) {}
|
DigitalSensor::DigitalSensor(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId) : Thing(participant) {}
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
|
@ -11,11 +11,11 @@ class DigitalSensor : public Thing {
|
|||||||
bool state = 0;
|
bool state = 0;
|
||||||
|
|
||||||
/// @brief The default constructor
|
/// @brief The default constructor
|
||||||
DigitalSensor();
|
//DigitalSensor();
|
||||||
/// @brief Create a temperature sensor with the given ID
|
/// @brief Create a temperature sensor with the given ID
|
||||||
/// @param networkId The network ID of the sensor
|
/// @param networkId The network ID of the sensor
|
||||||
/// @param thingId The ID of the thing
|
/// @param thingId The ID of the thing
|
||||||
DigitalSensor(unsigned char networkId, unsigned char thingId);
|
DigitalSensor(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
|
@ -6,10 +6,10 @@ namespace RoboidControl {
|
|||||||
|
|
||||||
// TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {}
|
// TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {}
|
||||||
|
|
||||||
TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {}
|
//TemperatureSensor::TemperatureSensor() : Thing(Type::TemperatureSensor) {}
|
||||||
|
|
||||||
TemperatureSensor::TemperatureSensor(unsigned char networkId, unsigned char thingId)
|
TemperatureSensor::TemperatureSensor(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId)
|
||||||
: Thing(nullptr, networkId, thingId, Type::TemperatureSensor) {}
|
: Thing(participant, networkId, thingId, Type::TemperatureSensor) {}
|
||||||
|
|
||||||
void TemperatureSensor::SetTemperature(float temp) {
|
void TemperatureSensor::SetTemperature(float temp) {
|
||||||
this->temperature = temp;
|
this->temperature = temp;
|
||||||
|
@ -11,11 +11,11 @@ class TemperatureSensor : public Thing {
|
|||||||
float temperature = 0;
|
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
|
||||||
/// @param networkId The network ID of the sensor
|
/// @param networkId The network ID of the sensor
|
||||||
/// @param thingId The ID of the thing
|
/// @param thingId The ID of the thing
|
||||||
TemperatureSensor(unsigned char networkId, unsigned char thingId);
|
TemperatureSensor(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId);
|
||||||
|
|
||||||
/// @brief Manually override the measured temperature
|
/// @brief Manually override the measured temperature
|
||||||
/// @param temperature The new temperature
|
/// @param temperature The new temperature
|
||||||
|
15
Sensors/TouchSensor.cpp
Normal file
15
Sensors/TouchSensor.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "TouchSensor.h"
|
||||||
|
|
||||||
|
namespace RoboidControl {
|
||||||
|
|
||||||
|
TouchSensor::TouchSensor(RemoteParticipant* participant) : Thing(participant) {
|
||||||
|
this->touchedSomething = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TouchSensor::TouchSensor(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId) : Thing(participant, networkId, thingId) {
|
||||||
|
// this->touchedSomething = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
void TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) {}
|
||||||
|
void TouchSensor::ProcessBinary(char* bytes) {}
|
||||||
|
} // namespace RoboidControl
|
29
Sensors/TouchSensor.h
Normal file
29
Sensors/TouchSensor.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Thing.h"
|
||||||
|
|
||||||
|
namespace RoboidControl {
|
||||||
|
|
||||||
|
/// @brief A sensor which can detect touches
|
||||||
|
class TouchSensor : public Thing {
|
||||||
|
public:
|
||||||
|
/// @brief Value which is true when the sensor is touching something, false otherwise
|
||||||
|
bool touchedSomething = false;
|
||||||
|
|
||||||
|
/// @brief Create a touch sensor
|
||||||
|
TouchSensor(RemoteParticipant* 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(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId);
|
||||||
|
|
||||||
|
/// @brief Function to create a binary message with the temperature
|
||||||
|
/// @param buffer The byte array for thw binary data
|
||||||
|
/// @param ix The starting position for writing the binary data
|
||||||
|
void GenerateBinary(char* bytes, unsigned char* ix) override;
|
||||||
|
/// @brief Function to extract the temperature received in the binary message
|
||||||
|
/// @param bytes The binary data
|
||||||
|
virtual void ProcessBinary(char* bytes) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace RoboidControl
|
@ -25,14 +25,14 @@ void SiteServer::Process(RemoteParticipant *sender, ParticipantMsg *msg) {
|
|||||||
if (msg->networkId == 0) {
|
if (msg->networkId == 0) {
|
||||||
std::cout << this->name << " received New Client -> " << sender->ipAddress
|
std::cout << this->name << " received New Client -> " << sender->ipAddress
|
||||||
<< " " << (int)sender->networkId << "\n";
|
<< " " << (int)sender->networkId << "\n";
|
||||||
NetworkIdMsg *msg = new NetworkIdMsg(sender->networkId);
|
SiteMsg *msg = new SiteMsg(sender->networkId);
|
||||||
//sender->Send(msg);
|
//sender->Send(msg);
|
||||||
this->Send(sender, msg);
|
this->Send(sender, msg);
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SiteServer::Process(RemoteParticipant *sender, NetworkIdMsg *msg) {}
|
void SiteServer::Process(RemoteParticipant *sender, SiteMsg *msg) {}
|
||||||
|
|
||||||
void SiteServer::Process(RemoteParticipant *sender, ThingMsg *msg) {
|
void SiteServer::Process(RemoteParticipant *sender, ThingMsg *msg) {
|
||||||
Thing *thing = sender->Get(msg->networkId, msg->thingId);
|
Thing *thing = sender->Get(msg->networkId, msg->thingId);
|
||||||
@ -40,11 +40,11 @@ void SiteServer::Process(RemoteParticipant *sender, ThingMsg *msg) {
|
|||||||
auto thingMsgProcessor = thingMsgProcessors.find(msg->thingType);
|
auto thingMsgProcessor = thingMsgProcessors.find(msg->thingType);
|
||||||
Thing *newThing;
|
Thing *newThing;
|
||||||
if (thingMsgProcessor != thingMsgProcessors.end()) // found item
|
if (thingMsgProcessor != thingMsgProcessors.end()) // found item
|
||||||
newThing = thingMsgProcessor->second(msg->networkId, msg->thingId);
|
newThing = thingMsgProcessor->second(sender, msg->networkId, msg->thingId);
|
||||||
else
|
else
|
||||||
newThing = new Thing(sender, msg->networkId, msg->thingId,
|
newThing = new Thing(sender, msg->networkId, msg->thingId,
|
||||||
(Thing::Type)msg->thingType);
|
(Thing::Type)msg->thingType);
|
||||||
sender->Add(newThing);
|
//sender->Add(newThing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ class SiteServer : public Participant {
|
|||||||
|
|
||||||
template <typename ThingClass>
|
template <typename ThingClass>
|
||||||
void Register(unsigned char thingType) {
|
void Register(unsigned char thingType) {
|
||||||
thingMsgProcessors[thingType] = [](unsigned char networkId, unsigned char thingId) {
|
thingMsgProcessors[thingType] = [](RemoteParticipant* participant, unsigned char networkId, unsigned char thingId) {
|
||||||
return new ThingClass(networkId, thingId);
|
return new ThingClass(participant, networkId, thingId);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -26,10 +26,10 @@ class SiteServer : public Participant {
|
|||||||
unsigned long nextPublishMe = 0;
|
unsigned long nextPublishMe = 0;
|
||||||
|
|
||||||
virtual void Process(RemoteParticipant* sender, ParticipantMsg* msg) override;
|
virtual void Process(RemoteParticipant* sender, ParticipantMsg* msg) override;
|
||||||
virtual void Process(RemoteParticipant* sender, NetworkIdMsg* msg) override;
|
virtual void Process(RemoteParticipant* sender, SiteMsg* msg) override;
|
||||||
virtual void Process(RemoteParticipant* sender, ThingMsg* msg) override;
|
virtual void Process(RemoteParticipant* sender, ThingMsg* msg) override;
|
||||||
|
|
||||||
using ThingConstructor = std::function<Thing*(unsigned char networkId, unsigned char thingId)>;
|
using ThingConstructor = std::function<Thing*(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId)>;
|
||||||
std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
|
std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
13
Thing.cpp
13
Thing.cpp
@ -8,18 +8,21 @@
|
|||||||
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
Thing::Thing(Type thingType) : Thing((unsigned char)thingType) {}
|
Thing::Thing(RemoteParticipant* participant, Type thingType) : Thing(participant, (unsigned char)thingType) {}
|
||||||
|
|
||||||
Thing::Thing(unsigned char thingType) {
|
|
||||||
// this->position = Spherical16::zero;
|
|
||||||
// this->orientation = SwingTwist16::identity;
|
|
||||||
|
|
||||||
|
Thing::Thing(RemoteParticipant* participant, unsigned char thingType) {
|
||||||
|
this->participant = participant;
|
||||||
this->id = 0;
|
this->id = 0;
|
||||||
this->type = thingType;
|
this->type = thingType;
|
||||||
this->networkId = 0;
|
this->networkId = 0;
|
||||||
|
|
||||||
|
this->position = Spherical16::zero;
|
||||||
|
this->orientation = SwingTwist16::identity;
|
||||||
|
|
||||||
this->linearVelocity = Spherical16::zero;
|
this->linearVelocity = Spherical16::zero;
|
||||||
this->angularVelocity = Spherical16::zero;
|
this->angularVelocity = Spherical16::zero;
|
||||||
|
|
||||||
|
participant->Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing::Thing(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId, Type thingType) {
|
Thing::Thing(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId, Type thingType) {
|
||||||
|
4
Thing.h
4
Thing.h
@ -42,10 +42,10 @@ class Thing {
|
|||||||
|
|
||||||
/// @brief Create a new thing of the given type
|
/// @brief Create a new thing of the given type
|
||||||
/// @param thingType The predefined type of thing
|
/// @param thingType The predefined type of thing
|
||||||
Thing(Type thingType = Type::Undetermined);
|
Thing(RemoteParticipant* participant, Type thingType = Type::Undetermined);
|
||||||
/// @brief Create a new thing of the give type
|
/// @brief Create a new thing of the give type
|
||||||
/// @param thingType The custom type of the thing
|
/// @param thingType The custom type of the thing
|
||||||
Thing(unsigned char thingType);
|
Thing(RemoteParticipant* participant, unsigned char thingType);
|
||||||
/// @brief Create a new thing for the given participant
|
/// @brief Create a new thing for the given participant
|
||||||
/// @param participant The participant for which this thing is created
|
/// @param participant The participant for which this thing is created
|
||||||
/// @param networkId The network ID of the thing
|
/// @param networkId The network ID of the thing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user