removed namespace Passer
This commit is contained in:
parent
4342e3bbd0
commit
1916478494
@ -8,7 +8,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
namespace Arduino {
|
namespace Arduino {
|
||||||
|
|
||||||
@ -96,4 +95,3 @@ bool Participant::Publish(IMessage* msg) {
|
|||||||
|
|
||||||
} // namespace Arduino
|
} // namespace Arduino
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "../Participant.h"
|
#include "../Participant.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
namespace Arduino {
|
namespace Arduino {
|
||||||
|
|
||||||
@ -19,4 +18,3 @@ class Participant : public RoboidControl::Participant {
|
|||||||
|
|
||||||
} // namespace Arduino
|
} // namespace Arduino
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -23,17 +23,20 @@ else()
|
|||||||
FetchContent_MakeAvailable(googletest)
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
add_library(LinearAlgebra STATIC
|
file(GLOB srcs
|
||||||
"FloatSingle.cpp"
|
*.cpp
|
||||||
"Angle.cpp"
|
)
|
||||||
"Vector2.cpp"
|
add_library(LinearAlgebra STATIC ${srcs}
|
||||||
"Vector3.cpp"
|
# "FloatSingle.cpp"
|
||||||
"Quaternion.cpp"
|
# "Angle.cpp"
|
||||||
"Polar.cpp"
|
# "Vector2.cpp"
|
||||||
"Spherical.cpp"
|
# "Vector3.cpp"
|
||||||
"Matrix.cpp"
|
# "Quaternion.cpp"
|
||||||
"SwingTwist.cpp"
|
# "Polar.cpp"
|
||||||
"Direction.cpp"
|
# "Spherical.cpp"
|
||||||
|
# "Matrix.cpp"
|
||||||
|
# "SwingTwist.cpp"
|
||||||
|
# "Direction.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
#include "BinaryMsg.h"
|
#include "BinaryMsg.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
BinaryMsg::BinaryMsg(char *buffer) {
|
BinaryMsg::BinaryMsg(char* buffer) {
|
||||||
unsigned char ix = 1;
|
unsigned char ix = 1;
|
||||||
this->networkId = buffer[ix++];
|
this->networkId = buffer[ix++];
|
||||||
this->thingId = buffer[ix++];
|
this->thingId = buffer[ix++];
|
||||||
this->bytes =
|
this->bytes = buffer + ix; // This is only valid because the code ensures the the msg
|
||||||
buffer + ix; // This is only valid because the code ensures the the msg
|
// lifetime is shorter than the buffer lifetime...
|
||||||
// lifetime is shorter than the buffer lifetime...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryMsg::BinaryMsg(unsigned char networkId, Thing *thing) {
|
BinaryMsg::BinaryMsg(unsigned char networkId, Thing* thing) {
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
this->thingId = thing->id;
|
this->thingId = thing->id;
|
||||||
this->thing = thing;
|
this->thing = thing;
|
||||||
@ -20,10 +18,10 @@ BinaryMsg::BinaryMsg(unsigned char networkId, Thing *thing) {
|
|||||||
|
|
||||||
BinaryMsg::~BinaryMsg() {}
|
BinaryMsg::~BinaryMsg() {}
|
||||||
|
|
||||||
unsigned char BinaryMsg::Serialize(char *buffer) {
|
unsigned char BinaryMsg::Serialize(char* buffer) {
|
||||||
unsigned char ix = this->length;
|
unsigned char ix = this->length;
|
||||||
this->thing->GenerateBinary(buffer, &ix);
|
this->thing->GenerateBinary(buffer, &ix);
|
||||||
if (ix <= this->length) // in this case, no data is actually sent
|
if (ix <= this->length) // in this case, no data is actually sent
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
buffer[0] = this->id;
|
buffer[0] = this->id;
|
||||||
@ -32,10 +30,9 @@ unsigned char BinaryMsg::Serialize(char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryMsg BinaryMsg::Receive(char *buffer, unsigned char bufferSize) {
|
BinaryMsg BinaryMsg::Receive(char* buffer, unsigned char bufferSize) {
|
||||||
BinaryMsg msg = BinaryMsg(buffer);
|
BinaryMsg msg = BinaryMsg(buffer);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -2,29 +2,27 @@
|
|||||||
|
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
class BinaryMsg : public IMessage {
|
class BinaryMsg : public IMessage {
|
||||||
public:
|
public:
|
||||||
static const unsigned char id = 0xB1;
|
static const unsigned char id = 0xB1;
|
||||||
static const unsigned length = 3;
|
static const unsigned length = 3;
|
||||||
|
|
||||||
unsigned char networkId;
|
unsigned char networkId;
|
||||||
unsigned char thingId;
|
unsigned char thingId;
|
||||||
Thing *thing;
|
Thing* thing;
|
||||||
|
|
||||||
unsigned char bytesSize;
|
unsigned char bytesSize;
|
||||||
char *bytes = nullptr;
|
char* bytes = nullptr;
|
||||||
|
|
||||||
BinaryMsg(char *buffer);
|
BinaryMsg(char* buffer);
|
||||||
BinaryMsg(unsigned char networkId, Thing *thing);
|
BinaryMsg(unsigned char networkId, Thing* thing);
|
||||||
virtual ~BinaryMsg();
|
virtual ~BinaryMsg();
|
||||||
|
|
||||||
virtual unsigned char Serialize(char *buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
|
|
||||||
static BinaryMsg Receive(char *buffer, unsigned char bufferSize);
|
static BinaryMsg Receive(char* buffer, unsigned char bufferSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "DestroyMsg.h"
|
#include "DestroyMsg.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
DestroyMsg::DestroyMsg(unsigned char networkId, Thing *thing) {
|
DestroyMsg::DestroyMsg(unsigned char networkId, Thing *thing) {
|
||||||
@ -21,4 +20,3 @@ unsigned char DestroyMsg::Serialize(char *buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message notifiying that a Thing no longer exists
|
/// @brief Message notifiying that a Thing no longer exists
|
||||||
class DestroyMsg : public IMessage {
|
class DestroyMsg : public IMessage {
|
||||||
public:
|
public:
|
||||||
/// @brief The message ID
|
/// @brief The message ID
|
||||||
static const unsigned char id = 0x20;
|
static const unsigned char id = 0x20;
|
||||||
/// @brief The length of the message
|
/// @brief The length of the message
|
||||||
@ -17,15 +17,14 @@ public:
|
|||||||
/// @brief Create a message for sending
|
/// @brief Create a message for sending
|
||||||
/// @param networkId The network ID of the thing
|
/// @param networkId The network ID of the thing
|
||||||
/// @param thing The ID of the thing
|
/// @param thing The ID of the thing
|
||||||
DestroyMsg(unsigned char networkId, Thing *thing);
|
DestroyMsg(unsigned char networkId, Thing* thing);
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
DestroyMsg(char * buffer);
|
DestroyMsg(char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~DestroyMsg();
|
virtual ~DestroyMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char *buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#include "InvestigateMsg.h"
|
#include "InvestigateMsg.h"
|
||||||
#pragma region Investigate
|
|
||||||
|
|
||||||
InvestigateMsg::InvestigateMsg(char *buffer) {
|
namespace RoboidControl {
|
||||||
unsigned ix = 1; // first byte is msgId
|
|
||||||
|
InvestigateMsg::InvestigateMsg(char* buffer) {
|
||||||
|
unsigned ix = 1; // first byte is msgId
|
||||||
this->networkId = buffer[ix++];
|
this->networkId = buffer[ix++];
|
||||||
this->thingId = buffer[ix++];
|
this->thingId = buffer[ix++];
|
||||||
}
|
}
|
||||||
@ -12,7 +13,7 @@ InvestigateMsg::InvestigateMsg(unsigned char networkId, unsigned char thingId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InvestigateMsg::~InvestigateMsg() {}
|
InvestigateMsg::~InvestigateMsg() {}
|
||||||
unsigned char InvestigateMsg::Serialize(char *buffer) {
|
unsigned char InvestigateMsg::Serialize(char* buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = this->id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
@ -20,11 +21,4 @@ unsigned char InvestigateMsg::Serialize(char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool InvestigateMsg::Send(Participant *participant, unsigned char networkId,
|
} // namespace RoboidControl
|
||||||
// unsigned char thingId) {
|
|
||||||
// InvestigateMsg msg = InvestigateMsg(networkId, thingId);
|
|
||||||
// return msg.Send(participant);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Investigate
|
|
||||||
#pragma endregion
|
|
@ -1,6 +1,5 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message to request details for a Thing
|
/// @brief Message to request details for a Thing
|
||||||
@ -19,14 +18,13 @@ class InvestigateMsg : public IMessage {
|
|||||||
/// @param networkId The network ID for the thing
|
/// @param networkId The network ID for the thing
|
||||||
/// @param thingId The ID of the thing
|
/// @param thingId The ID of the thing
|
||||||
InvestigateMsg(unsigned char networkId, unsigned char thingId);
|
InvestigateMsg(unsigned char networkId, unsigned char thingId);
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
InvestigateMsg(char* buffer);
|
InvestigateMsg(char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~InvestigateMsg();
|
virtual ~InvestigateMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char* buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
#include "float16.h"
|
#include "float16.h"
|
||||||
|
|
||||||
void LowLevelMessages::SendAngle8(char *buffer, unsigned char *ix,
|
namespace RoboidControl {
|
||||||
const float angle) {
|
|
||||||
|
void LowLevelMessages::SendAngle8(char* buffer, unsigned char* ix, const float angle) {
|
||||||
Angle8 packedAngle2 = Angle8::Degrees(angle);
|
Angle8 packedAngle2 = Angle8::Degrees(angle);
|
||||||
buffer[(*ix)++] = packedAngle2.GetBinary();
|
buffer[(*ix)++] = packedAngle2.GetBinary();
|
||||||
}
|
}
|
||||||
Angle8 LowLevelMessages::ReceiveAngle8(const char *buffer,
|
Angle8 LowLevelMessages::ReceiveAngle8(const char* buffer, unsigned char* startIndex) {
|
||||||
unsigned char *startIndex) {
|
|
||||||
unsigned char binary = buffer[(*startIndex)++];
|
unsigned char binary = buffer[(*startIndex)++];
|
||||||
|
|
||||||
Angle8 angle = Angle8::Binary(binary);
|
Angle8 angle = Angle8::Binary(binary);
|
||||||
@ -16,16 +16,14 @@ Angle8 LowLevelMessages::ReceiveAngle8(const char *buffer,
|
|||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LowLevelMessages::SendFloat16(char *buffer, unsigned char *ix,
|
void LowLevelMessages::SendFloat16(char* buffer, unsigned char* ix, float value) {
|
||||||
float value) {
|
|
||||||
float16 value16 = float16(value);
|
float16 value16 = float16(value);
|
||||||
short binary = value16.getBinary();
|
short binary = value16.getBinary();
|
||||||
|
|
||||||
buffer[(*ix)++] = (binary >> 8) & 0xFF;
|
buffer[(*ix)++] = (binary >> 8) & 0xFF;
|
||||||
buffer[(*ix)++] = binary & 0xFF;
|
buffer[(*ix)++] = binary & 0xFF;
|
||||||
}
|
}
|
||||||
float LowLevelMessages::ReceiveFloat16(const char *buffer,
|
float LowLevelMessages::ReceiveFloat16(const char* buffer, unsigned char* startIndex) {
|
||||||
unsigned char *startIndex) {
|
|
||||||
unsigned char ix = *startIndex;
|
unsigned char ix = *startIndex;
|
||||||
unsigned char msb = buffer[ix++];
|
unsigned char msb = buffer[ix++];
|
||||||
unsigned char lsb = buffer[ix++];
|
unsigned char lsb = buffer[ix++];
|
||||||
@ -37,14 +35,12 @@ float LowLevelMessages::ReceiveFloat16(const char *buffer,
|
|||||||
return (float)f.toFloat();
|
return (float)f.toFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LowLevelMessages::SendSpherical16(char *buffer, unsigned char *ix,
|
void LowLevelMessages::SendSpherical16(char* buffer, unsigned char* ix, Spherical16 s) {
|
||||||
Spherical16 s) {
|
|
||||||
SendFloat16(buffer, ix, s.distance);
|
SendFloat16(buffer, ix, s.distance);
|
||||||
SendAngle8(buffer, ix, s.direction.horizontal.InDegrees());
|
SendAngle8(buffer, ix, s.direction.horizontal.InDegrees());
|
||||||
SendAngle8(buffer, ix, s.direction.vertical.InDegrees());
|
SendAngle8(buffer, ix, s.direction.vertical.InDegrees());
|
||||||
}
|
}
|
||||||
Spherical16 LowLevelMessages::ReceiveSpherical16(const char *buffer,
|
Spherical16 LowLevelMessages::ReceiveSpherical16(const char* buffer, unsigned char* startIndex) {
|
||||||
unsigned char *startIndex) {
|
|
||||||
float distance = ReceiveFloat16(buffer, startIndex);
|
float distance = ReceiveFloat16(buffer, startIndex);
|
||||||
|
|
||||||
Angle8 horizontal8 = ReceiveAngle8(buffer, startIndex);
|
Angle8 horizontal8 = ReceiveAngle8(buffer, startIndex);
|
||||||
@ -57,9 +53,7 @@ Spherical16 LowLevelMessages::ReceiveSpherical16(const char *buffer,
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Passer::RoboidControl::LowLevelMessages::SendQuat32(char *buffer,
|
void LowLevelMessages::SendQuat32(char* buffer, unsigned char* ix, SwingTwist16 rotation) {
|
||||||
unsigned char *ix,
|
|
||||||
SwingTwist16 rotation) {
|
|
||||||
Quaternion q = rotation.ToQuaternion();
|
Quaternion q = rotation.ToQuaternion();
|
||||||
unsigned char qx = (char)(q.x * 127 + 128);
|
unsigned char qx = (char)(q.x * 127 + 128);
|
||||||
unsigned char qy = (char)(q.y * 127 + 128);
|
unsigned char qy = (char)(q.y * 127 + 128);
|
||||||
@ -78,8 +72,7 @@ void Passer::RoboidControl::LowLevelMessages::SendQuat32(char *buffer,
|
|||||||
buffer[(*ix)++] = qw;
|
buffer[(*ix)++] = qw;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwingTwist16 LowLevelMessages::ReceiveQuat32(const char *buffer,
|
SwingTwist16 LowLevelMessages::ReceiveQuat32(const char* buffer, unsigned char* ix) {
|
||||||
unsigned char *ix) {
|
|
||||||
float qx = (buffer[(*ix)++] - 128.0F) / 127.0F;
|
float qx = (buffer[(*ix)++] - 128.0F) / 127.0F;
|
||||||
float qy = (buffer[(*ix)++] - 128.0F) / 127.0F;
|
float qy = (buffer[(*ix)++] - 128.0F) / 127.0F;
|
||||||
float qz = (buffer[(*ix)++] - 128.0F) / 127.0F;
|
float qz = (buffer[(*ix)++] - 128.0F) / 127.0F;
|
||||||
@ -87,4 +80,6 @@ SwingTwist16 LowLevelMessages::ReceiveQuat32(const char *buffer,
|
|||||||
Quaternion q = Quaternion(qx, qy, qz, qw);
|
Quaternion q = Quaternion(qx, qy, qz, qw);
|
||||||
SwingTwist16 s = SwingTwist16::FromQuaternion(q);
|
SwingTwist16 s = SwingTwist16::FromQuaternion(q);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace RoboidControl
|
@ -1,25 +1,21 @@
|
|||||||
#include "LinearAlgebra/Spherical.h"
|
#include "LinearAlgebra/Spherical.h"
|
||||||
#include "LinearAlgebra/SwingTwist.h"
|
#include "LinearAlgebra/SwingTwist.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
class LowLevelMessages {
|
class LowLevelMessages {
|
||||||
public:
|
public:
|
||||||
static void SendAngle8(char *buffer, unsigned char *ix, const float angle);
|
static void SendAngle8(char* buffer, unsigned char* ix, const float angle);
|
||||||
static Angle8 ReceiveAngle8(const char *buffer, unsigned char *startIndex);
|
static Angle8 ReceiveAngle8(const char* buffer, unsigned char* startIndex);
|
||||||
|
|
||||||
static void SendFloat16(char *buffer, unsigned char *ix, float value);
|
static void SendFloat16(char* buffer, unsigned char* ix, float value);
|
||||||
static float ReceiveFloat16(const char *buffer, unsigned char *startIndex);
|
static float ReceiveFloat16(const char* buffer, unsigned char* startIndex);
|
||||||
|
|
||||||
static void SendSpherical16(char *buffer, unsigned char *ix, Spherical16 s);
|
static void SendSpherical16(char* buffer, unsigned char* ix, Spherical16 s);
|
||||||
static Spherical16 ReceiveSpherical16(const char *buffer,
|
static Spherical16 ReceiveSpherical16(const char* buffer, unsigned char* startIndex);
|
||||||
unsigned char *startIndex);
|
|
||||||
|
|
||||||
static void SendQuat32(char *buffer, unsigned char *ix, SwingTwist16 q);
|
static void SendQuat32(char* buffer, unsigned char* ix, SwingTwist16 q);
|
||||||
static SwingTwist16 ReceiveQuat32(const char *buffer, unsigned char *ix);
|
static SwingTwist16 ReceiveQuat32(const char* buffer, unsigned char* ix);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
using namespace Passer::RoboidControl;
|
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include "Participant.h"
|
#include "Participant.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
namespace Passer {
|
namespace RoboidControl {
|
||||||
namespace RoboidControl {
|
|
||||||
|
|
||||||
#pragma region IMessage
|
#pragma region IMessage
|
||||||
|
|
||||||
@ -19,17 +18,11 @@ unsigned char IMessage::Serialize(char* buffer) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void IMessage::Deserialize(unsigned char *buffer) {}
|
|
||||||
|
|
||||||
// bool IMessage::SendMsg(Participant *client, IMessage msg) {
|
// bool IMessage::SendMsg(Participant *client, IMessage msg) {
|
||||||
// // return SendMsg(client, client.buffer, );nameLength
|
// // return SendMsg(client, client.buffer, );nameLength
|
||||||
// return client->SendBuffer(msg.Serialize(client->buffer));
|
// return client->SendBuffer(msg.Serialize(client->buffer));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// unsigned char *IMessage::ReceiveMsg(unsigned char packetSize) {
|
|
||||||
// return nullptr;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// bool IMessage::Publish(Participant *participant) {
|
// bool IMessage::Publish(Participant *participant) {
|
||||||
// return participant->PublishBuffer(Serialize(participant->buffer));
|
// return participant->PublishBuffer(Serialize(participant->buffer));
|
||||||
// }
|
// }
|
||||||
@ -40,4 +33,4 @@ unsigned char IMessage::Serialize(char* buffer) {
|
|||||||
// IMessage
|
// IMessage
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
}}
|
} // namespace RoboidControl
|
@ -5,23 +5,19 @@
|
|||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
#include "float16.h"
|
#include "float16.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
class Participant;
|
class Participant;
|
||||||
|
|
||||||
class IMessage {
|
class IMessage {
|
||||||
public:
|
public:
|
||||||
IMessage();
|
IMessage();
|
||||||
virtual unsigned char Serialize(char *buffer);
|
virtual unsigned char Serialize(char* buffer);
|
||||||
|
|
||||||
static unsigned char *ReceiveMsg(unsigned char packetSize);
|
static unsigned char* ReceiveMsg(unsigned char packetSize);
|
||||||
|
|
||||||
// bool Publish(Participant *participant);
|
// bool Publish(Participant *participant);
|
||||||
// bool SendTo(Participant *participant);
|
// bool SendTo(Participant *participant);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
|
||||||
using namespace Passer::RoboidControl;
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
// ModelUrlMsg::ModelUrlMsg(unsigned char networkId, unsigned char thingId,
|
// ModelUrlMsg::ModelUrlMsg(unsigned char networkId, unsigned char thingId,
|
||||||
@ -15,16 +14,16 @@ namespace RoboidControl {
|
|||||||
// this->scale = scale;
|
// this->scale = scale;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ModelUrlMsg::ModelUrlMsg(const char *buffer) {
|
ModelUrlMsg::ModelUrlMsg(const char* buffer) {
|
||||||
unsigned char ix = 1; // first byte is msg id
|
unsigned char ix = 1; // first byte is msg id
|
||||||
this->networkId = buffer[ix++];
|
this->networkId = buffer[ix++];
|
||||||
this->thingId = buffer[ix++];
|
this->thingId = buffer[ix++];
|
||||||
this->urlLength = buffer[ix++];
|
this->urlLength = buffer[ix++];
|
||||||
this->url = &buffer[ix]; // dangerous! name should not be used anymore after
|
this->url = &buffer[ix]; // dangerous! name should not be used anymore after
|
||||||
// buffer has been re-used...
|
// buffer has been re-used...
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing *thing) {
|
ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing* thing) {
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
this->thingId = thing->id;
|
this->thingId = thing->id;
|
||||||
if (thing->modelUrl == nullptr)
|
if (thing->modelUrl == nullptr)
|
||||||
@ -32,12 +31,12 @@ ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing *thing) {
|
|||||||
else
|
else
|
||||||
this->urlLength = (unsigned char)strlen(thing->modelUrl);
|
this->urlLength = (unsigned char)strlen(thing->modelUrl);
|
||||||
|
|
||||||
this->url = thing->modelUrl; // dangerous!
|
this->url = thing->modelUrl; // dangerous!
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelUrlMsg::~ModelUrlMsg() {}
|
ModelUrlMsg::~ModelUrlMsg() {}
|
||||||
|
|
||||||
unsigned char ModelUrlMsg::Serialize(char *buffer) {
|
unsigned char ModelUrlMsg::Serialize(char* buffer) {
|
||||||
if (this->urlLength == 0 || this->url == nullptr)
|
if (this->urlLength == 0 || this->url == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
@ -51,5 +50,4 @@ unsigned char ModelUrlMsg::Serialize(char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message for communicating the URL for a model of the thing
|
/// @brief Message for communicating the URL for a model of the thing
|
||||||
class ModelUrlMsg : public IMessage {
|
class ModelUrlMsg : public IMessage {
|
||||||
public:
|
public:
|
||||||
/// @brief The message ID
|
/// @brief The message ID
|
||||||
static const unsigned char id = 0x90;
|
static const unsigned char id = 0x90;
|
||||||
/// @brief The length of the message without the URL string itself
|
/// @brief The length of the message without the URL string itself
|
||||||
@ -15,27 +14,26 @@ public:
|
|||||||
unsigned char networkId;
|
unsigned char networkId;
|
||||||
/// @brief The ID of the thing
|
/// @brief The ID of the thing
|
||||||
unsigned char thingId;
|
unsigned char thingId;
|
||||||
|
|
||||||
/// @brief The length of the url st5ring, excluding the null terminator
|
/// @brief The length of the url st5ring, excluding the null terminator
|
||||||
unsigned char urlLength;
|
unsigned char urlLength;
|
||||||
/// @brief The url of the model, not terminated by a null character
|
/// @brief The url of the model, not terminated by a null character
|
||||||
const char *url;
|
const char* url;
|
||||||
|
|
||||||
/// @brief Create a new message for sending
|
/// @brief Create a new message for sending
|
||||||
/// @param networkId The network ID of the thing
|
/// @param networkId The network ID of the thing
|
||||||
/// @param thing The thing for which to send the mode URL
|
/// @param thing The thing for which to send the mode URL
|
||||||
ModelUrlMsg(unsigned char networkId, Thing *thing);
|
ModelUrlMsg(unsigned char networkId, Thing* thing);
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
ModelUrlMsg(const char *buffer);
|
ModelUrlMsg(const char* buffer);
|
||||||
// ModelUrlMsg(unsigned char networkId, unsigned char thingId,
|
// ModelUrlMsg(unsigned char networkId, unsigned char thingId,
|
||||||
// unsigned char urlLegth, const char *url, float scale = 1);
|
// unsigned char urlLegth, const char *url, float scale = 1);
|
||||||
|
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~ModelUrlMsg();
|
virtual ~ModelUrlMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char *buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -2,26 +2,25 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
NameMsg::NameMsg(unsigned char networkId, Thing *thing) {
|
NameMsg::NameMsg(unsigned char networkId, Thing* thing) {
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
this->thingId = thing->id;
|
this->thingId = thing->id;
|
||||||
if (thing->name == nullptr)
|
if (thing->name == nullptr)
|
||||||
this->nameLength = 0;
|
this->nameLength = 0;
|
||||||
else
|
else
|
||||||
this->nameLength = (unsigned char)strlen(thing->name);
|
this->nameLength = (unsigned char)strlen(thing->name);
|
||||||
this->name = thing->name; // dangerous!
|
this->name = thing->name; // dangerous!
|
||||||
}
|
}
|
||||||
|
|
||||||
NameMsg::NameMsg(const char *buffer) {
|
NameMsg::NameMsg(const char* buffer) {
|
||||||
unsigned char ix = 1; // first byte is msg id
|
unsigned char ix = 1; // first byte is msg id
|
||||||
this->networkId = buffer[ix++];
|
this->networkId = buffer[ix++];
|
||||||
this->thingId = buffer[ix++];
|
this->thingId = buffer[ix++];
|
||||||
this->nameLength = buffer[ix++];
|
this->nameLength = buffer[ix++];
|
||||||
// the name string in the buffer is not \0 terminated!
|
// the name string in the buffer is not \0 terminated!
|
||||||
char* name = new char[this->nameLength+1];
|
char* name = new char[this->nameLength + 1];
|
||||||
for (int i = 0; i < this->nameLength; i++)
|
for (int i = 0; i < this->nameLength; i++)
|
||||||
name[i] = buffer[ix++];
|
name[i] = buffer[ix++];
|
||||||
name[this->nameLength] = '\0';
|
name[this->nameLength] = '\0';
|
||||||
@ -32,7 +31,7 @@ NameMsg::~NameMsg() {
|
|||||||
delete[] this->name;
|
delete[] this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char NameMsg::Serialize(char *buffer) {
|
unsigned char NameMsg::Serialize(char* buffer) {
|
||||||
if (this->nameLength == 0 || this->name == nullptr)
|
if (this->nameLength == 0 || this->name == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -47,5 +46,4 @@ unsigned char NameMsg::Serialize(char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message for communicating the name of a thing
|
/// @brief Message for communicating the name of a thing
|
||||||
@ -26,14 +25,13 @@ class NameMsg : public IMessage {
|
|||||||
// NameMsg(unsigned char networkId, unsigned char thingId, const char *name,
|
// NameMsg(unsigned char networkId, unsigned char thingId, const char *name,
|
||||||
// unsigned char nameLength);
|
// unsigned char nameLength);
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
NameMsg(const char* buffer);
|
NameMsg(const char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~NameMsg();
|
virtual ~NameMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char* buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "NetworkIdMsg.h"
|
#include "NetworkIdMsg.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
NetworkIdMsg::NetworkIdMsg(const char *buffer) { this->networkId = buffer[1]; }
|
NetworkIdMsg::NetworkIdMsg(const char* buffer) {
|
||||||
|
this->networkId = buffer[1];
|
||||||
|
}
|
||||||
|
|
||||||
NetworkIdMsg::NetworkIdMsg(unsigned char networkId) {
|
NetworkIdMsg::NetworkIdMsg(unsigned char networkId) {
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
@ -11,17 +12,11 @@ NetworkIdMsg::NetworkIdMsg(unsigned char networkId) {
|
|||||||
|
|
||||||
NetworkIdMsg::~NetworkIdMsg() {}
|
NetworkIdMsg::~NetworkIdMsg() {}
|
||||||
|
|
||||||
unsigned char NetworkIdMsg::Serialize(char *buffer) {
|
unsigned char NetworkIdMsg::Serialize(char* buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = this->id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
return NetworkIdMsg::length;
|
return NetworkIdMsg::length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkIdMsg NetworkIdMsg::Receive(char *buffer, unsigned char bufferSize) {
|
} // namespace RoboidControl
|
||||||
// NetworkIdMsg msg = NetworkIdMsg(buffer);
|
|
||||||
// return msg;
|
|
||||||
// }
|
|
||||||
|
|
||||||
} // namespace Control
|
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A message communicating the network ID for that participant
|
/// @brief A message communicating the network ID for that participant
|
||||||
@ -16,14 +15,13 @@ 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);
|
NetworkIdMsg(unsigned char networkId);
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
NetworkIdMsg(const char *buffer);
|
NetworkIdMsg(const char *buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~NetworkIdMsg();
|
virtual ~NetworkIdMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char *buffer) override;
|
virtual unsigned char Serialize(char *buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace Control
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
#include "ParticipantMsg.h"
|
#include "ParticipantMsg.h"
|
||||||
|
|
||||||
namespace Passer::RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
ParticipantMsg::ParticipantMsg(char networkId) { this->networkId = networkId; }
|
ParticipantMsg::ParticipantMsg(char networkId) {
|
||||||
|
this->networkId = networkId;
|
||||||
|
}
|
||||||
|
|
||||||
ParticipantMsg::ParticipantMsg(const char *buffer) { this->networkId = buffer[1]; }
|
ParticipantMsg::ParticipantMsg(const char* buffer) {
|
||||||
|
this->networkId = buffer[1];
|
||||||
|
}
|
||||||
|
|
||||||
ParticipantMsg::~ParticipantMsg() {}
|
ParticipantMsg::~ParticipantMsg() {}
|
||||||
|
|
||||||
unsigned char ParticipantMsg::Serialize(char *buffer) {
|
unsigned char ParticipantMsg::Serialize(char* buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = this->id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
@ -20,4 +24,4 @@ unsigned char ParticipantMsg::Serialize(char *buffer) {
|
|||||||
// }
|
// }
|
||||||
// Client Msg
|
// Client Msg
|
||||||
|
|
||||||
} // namespace Passer::RoboidControl
|
} // namespace RoboidControl
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A participant messages notifies other participants of its presence
|
/// @brief A participant messages notifies other participants of its presence
|
||||||
@ -21,7 +20,7 @@ class ParticipantMsg : public IMessage {
|
|||||||
/// @param networkId The network ID known by the participant
|
/// @param networkId The network ID known by the participant
|
||||||
ParticipantMsg(char networkId);
|
ParticipantMsg(char networkId);
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
ParticipantMsg(const char* buffer);
|
ParticipantMsg(const char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~ParticipantMsg();
|
virtual ~ParticipantMsg();
|
||||||
@ -33,4 +32,3 @@ class ParticipantMsg : public IMessage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -1,9 +1,14 @@
|
|||||||
#include "PoseMsg.h"
|
#include "PoseMsg.h"
|
||||||
#include "LowLevelMessages.h"
|
#include "LowLevelMessages.h"
|
||||||
|
|
||||||
PoseMsg::PoseMsg(unsigned char networkId, unsigned char thingId,
|
namespace RoboidControl {
|
||||||
unsigned char poseType, Spherical16 position,
|
|
||||||
SwingTwist16 orientation, Spherical16 linearVelocity,
|
PoseMsg::PoseMsg(unsigned char networkId,
|
||||||
|
unsigned char thingId,
|
||||||
|
unsigned char poseType,
|
||||||
|
Spherical16 position,
|
||||||
|
SwingTwist16 orientation,
|
||||||
|
Spherical16 linearVelocity,
|
||||||
Spherical16 angularVelocity) {
|
Spherical16 angularVelocity) {
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
this->thingId = thingId;
|
this->thingId = thingId;
|
||||||
@ -14,8 +19,8 @@ PoseMsg::PoseMsg(unsigned char networkId, unsigned char thingId,
|
|||||||
this->linearVelocity = linearVelocity;
|
this->linearVelocity = linearVelocity;
|
||||||
this->angularVelocity = angularVelocity;
|
this->angularVelocity = angularVelocity;
|
||||||
}
|
}
|
||||||
PoseMsg::PoseMsg(const char *buffer) {
|
PoseMsg::PoseMsg(const char* buffer) {
|
||||||
unsigned char ix = 1; // First byte is msg id
|
unsigned char ix = 1; // First byte is msg id
|
||||||
this->networkId = buffer[ix++];
|
this->networkId = buffer[ix++];
|
||||||
this->thingId = buffer[ix++];
|
this->thingId = buffer[ix++];
|
||||||
this->poseType = buffer[ix++];
|
this->poseType = buffer[ix++];
|
||||||
@ -25,7 +30,7 @@ PoseMsg::PoseMsg(const char *buffer) {
|
|||||||
|
|
||||||
PoseMsg::~PoseMsg() {}
|
PoseMsg::~PoseMsg() {}
|
||||||
|
|
||||||
unsigned char PoseMsg::Serialize(char *buffer) {
|
unsigned char PoseMsg::Serialize(char* buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = PoseMsg::id;
|
buffer[ix++] = PoseMsg::id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
@ -41,3 +46,5 @@ unsigned char PoseMsg::Serialize(char *buffer) {
|
|||||||
LowLevelMessages::SendSpherical16(buffer, &ix, this->angularVelocity);
|
LowLevelMessages::SendSpherical16(buffer, &ix, this->angularVelocity);
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace RoboidControl
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message to communicate the pose of the thing
|
/// @brief Message to communicate the pose of the thing
|
||||||
@ -53,14 +52,13 @@ class PoseMsg : public IMessage {
|
|||||||
SwingTwist16 orientation,
|
SwingTwist16 orientation,
|
||||||
Spherical16 linearVelocity = Spherical16(),
|
Spherical16 linearVelocity = Spherical16(),
|
||||||
Spherical16 angularVelocity = Spherical16());
|
Spherical16 angularVelocity = Spherical16());
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
PoseMsg(const char* buffer);
|
PoseMsg(const char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~PoseMsg();
|
virtual ~PoseMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char* buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -1,6 +1,5 @@
|
|||||||
#include "TextMsg.h"
|
#include "TextMsg.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
TextMsg::TextMsg(const char* text, unsigned char textLength) {
|
TextMsg::TextMsg(const char* text, unsigned char textLength) {
|
||||||
@ -22,7 +21,7 @@ TextMsg::TextMsg(char* buffer) {
|
|||||||
TextMsg::~TextMsg() {}
|
TextMsg::~TextMsg() {}
|
||||||
|
|
||||||
unsigned char TextMsg::Serialize(char* buffer) {
|
unsigned char TextMsg::Serialize(char* buffer) {
|
||||||
if (this->textLength == 0 || this->text == nullptr)
|
if (this->textLength == 0 || this->text == nullptr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
@ -31,7 +30,7 @@ unsigned char TextMsg::Serialize(char* buffer) {
|
|||||||
for (int nameIx = 0; nameIx < this->textLength; nameIx++)
|
for (int nameIx = 0; nameIx < this->textLength; nameIx++)
|
||||||
buffer[ix++] = this->text[nameIx];
|
buffer[ix++] = this->text[nameIx];
|
||||||
|
|
||||||
return ix;}
|
return ix;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -1,6 +1,5 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message for sending generic text
|
/// @brief Message for sending generic text
|
||||||
@ -22,14 +21,13 @@ class TextMsg : public IMessage {
|
|||||||
/// @brief Create a new message for sending
|
/// @brief Create a new message for sending
|
||||||
/// @param text The text
|
/// @param text The text
|
||||||
TextMsg(const char* text, unsigned char textLength);
|
TextMsg(const char* text, unsigned char textLength);
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
TextMsg(char* buffer);
|
TextMsg(char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~TextMsg();
|
virtual ~TextMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char* buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -1,21 +1,20 @@
|
|||||||
#include "ThingMsg.h"
|
#include "ThingMsg.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
ThingMsg::ThingMsg(const char *buffer) {
|
ThingMsg::ThingMsg(const char* buffer) {
|
||||||
unsigned char ix = 1; // first byte is msg id
|
unsigned char ix = 1; // first byte is msg id
|
||||||
this->networkId = buffer[ix++];
|
this->networkId = buffer[ix++];
|
||||||
this->thingId = buffer[ix++];
|
this->thingId = buffer[ix++];
|
||||||
this->thingType = buffer[ix++];
|
this->thingType = buffer[ix++];
|
||||||
this->parentId = buffer[ix++];
|
this->parentId = buffer[ix++];
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingMsg::ThingMsg(unsigned char networkId, Thing *thing) {
|
ThingMsg::ThingMsg(unsigned char networkId, Thing* thing) {
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
this->thingId = thing->id;
|
this->thingId = thing->id;
|
||||||
this->thingType = thing->type;
|
this->thingType = thing->type;
|
||||||
Thing *parent = thing->GetParent();
|
Thing* parent = thing->GetParent();
|
||||||
if (parent != nullptr)
|
if (parent != nullptr)
|
||||||
this->parentId = parent->id;
|
this->parentId = parent->id;
|
||||||
else
|
else
|
||||||
@ -32,7 +31,7 @@ ThingMsg::ThingMsg(unsigned char networkId, Thing *thing) {
|
|||||||
|
|
||||||
ThingMsg::~ThingMsg() {}
|
ThingMsg::~ThingMsg() {}
|
||||||
|
|
||||||
unsigned char ThingMsg::Serialize(char *buffer) {
|
unsigned char ThingMsg::Serialize(char* buffer) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
buffer[ix++] = this->id;
|
buffer[ix++] = this->id;
|
||||||
buffer[ix++] = this->networkId;
|
buffer[ix++] = this->networkId;
|
||||||
@ -42,5 +41,4 @@ unsigned char ThingMsg::Serialize(char *buffer) {
|
|||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief Message providing generic information about a Thing
|
/// @brief Message providing generic information about a Thing
|
||||||
@ -26,14 +25,13 @@ class ThingMsg : public IMessage {
|
|||||||
// ThingMsg(unsigned char networkId, unsigned char thingId,
|
// ThingMsg(unsigned char networkId, unsigned char thingId,
|
||||||
// unsigned char thingType, unsigned char parentId);
|
// unsigned char thingType, unsigned char parentId);
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::IMessage(char*)
|
/// @copydoc RoboidControl::IMessage::IMessage(char*)
|
||||||
ThingMsg(const char* buffer);
|
ThingMsg(const char* buffer);
|
||||||
/// @brief Destructor for the message
|
/// @brief Destructor for the message
|
||||||
virtual ~ThingMsg();
|
virtual ~ThingMsg();
|
||||||
|
|
||||||
/// @copydoc Passer::RoboidControl::IMessage::Serialize
|
/// @copydoc RoboidControl::IMessage::Serialize
|
||||||
virtual unsigned char Serialize(char* buffer) override;
|
virtual unsigned char Serialize(char* buffer) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -19,7 +19,6 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
Participant::Participant() {}
|
Participant::Participant() {}
|
||||||
@ -138,7 +137,7 @@ void Participant::SendThingInfo(RemoteParticipant* remoteParticipant, Thing* thi
|
|||||||
delete modelMsg;
|
delete modelMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Passer::RoboidControl::Participant::PublishThingInfo(Thing* thing) {
|
void Participant::PublishThingInfo(Thing* thing) {
|
||||||
// std::cout << "Publish thing info" << thing->networkId << "\n";
|
// std::cout << "Publish thing info" << thing->networkId << "\n";
|
||||||
// Strange, when publishing, the network id is irrelevant, because it is
|
// Strange, when publishing, the network id is irrelevant, because it is
|
||||||
// connected to a specific site...
|
// connected to a specific site...
|
||||||
@ -277,4 +276,3 @@ void Participant::Process(RemoteParticipant* sender, BinaryMsg* msg) {
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Messages/ParticipantMsg.h"
|
|
||||||
#include "Messages/BinaryMsg.h"
|
#include "Messages/BinaryMsg.h"
|
||||||
#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/NetworkIdMsg.h"
|
||||||
|
#include "Messages/ParticipantMsg.h"
|
||||||
#include "Messages/PoseMsg.h"
|
#include "Messages/PoseMsg.h"
|
||||||
#include "Messages/ThingMsg.h"
|
#include "Messages/ThingMsg.h"
|
||||||
#include "RemoteParticipant.h"
|
#include "RemoteParticipant.h"
|
||||||
@ -23,26 +23,25 @@
|
|||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A participant is device which can communicate with other participants
|
/// @brief A participant is device which can communicate with other participants
|
||||||
class Participant : public RemoteParticipant {
|
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;
|
// unsigned char networkId = 0;
|
||||||
|
|
||||||
const char *name = "Participant";
|
const char* name = "Participant";
|
||||||
|
|
||||||
// const char *ipAddress = "0.0.0.0";
|
// const char *ipAddress = "0.0.0.0";
|
||||||
// int port = 0;
|
// int port = 0;
|
||||||
int localPort = 0;
|
int localPort = 0;
|
||||||
|
|
||||||
#if defined(ARDUINO)
|
#if defined(ARDUINO)
|
||||||
const char *remoteIpAddress = nullptr;
|
const char* remoteIpAddress = nullptr;
|
||||||
unsigned short remotePort = 0;
|
unsigned short remotePort = 0;
|
||||||
char *broadcastIpAddress = nullptr;
|
char* broadcastIpAddress = nullptr;
|
||||||
|
|
||||||
WiFiUDP udp;
|
WiFiUDP udp;
|
||||||
#else
|
#else
|
||||||
@ -60,7 +59,7 @@ public:
|
|||||||
|
|
||||||
Participant();
|
Participant();
|
||||||
Participant(int port);
|
Participant(int port);
|
||||||
Participant(const char *ipAddress, int port);
|
Participant(const char* ipAddress, int port);
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
@ -73,35 +72,33 @@ public:
|
|||||||
// void Remove(Thing *thing);
|
// void Remove(Thing *thing);
|
||||||
// void UpdateAll(unsigned long currentTimeMs);
|
// 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);
|
||||||
|
|
||||||
bool Send(RemoteParticipant* remoteParticipant, IMessage *msg);
|
bool Send(RemoteParticipant* remoteParticipant, IMessage* msg);
|
||||||
bool Publish(IMessage *msg);
|
bool Publish(IMessage* msg);
|
||||||
|
|
||||||
void ReceiveData(unsigned char bufferSize, RemoteParticipant *remoteParticipant);
|
void ReceiveData(unsigned char bufferSize, RemoteParticipant* remoteParticipant);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::list<Participant *> senders;
|
std::list<Participant*> senders;
|
||||||
|
|
||||||
unsigned long nextPublishMe = 0;
|
unsigned long nextPublishMe = 0;
|
||||||
|
|
||||||
void SetupUDP(int localPort, const char *remoteIpAddress, int remotePort);
|
void SetupUDP(int localPort, const char* remoteIpAddress, int remotePort);
|
||||||
|
|
||||||
Participant *GetParticipant(const char *ipAddress, int port);
|
Participant* GetParticipant(const char* ipAddress, int port);
|
||||||
Participant *AddParticipant(const char *ipAddress, int port);
|
Participant* AddParticipant(const char* ipAddress, int port);
|
||||||
|
|
||||||
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, NetworkIdMsg* 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);
|
||||||
virtual void Process(RemoteParticipant* sender, PoseMsg *msg);
|
virtual void Process(RemoteParticipant* sender, PoseMsg* msg);
|
||||||
virtual void Process(RemoteParticipant* sender, BinaryMsg *msg);
|
virtual void Process(RemoteParticipant* sender, BinaryMsg* msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
using namespace Passer::RoboidControl;
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
namespace Posix {
|
namespace Posix {
|
||||||
|
|
||||||
@ -135,4 +134,3 @@ bool Participant::Publish(IMessage* msg) {
|
|||||||
|
|
||||||
} // namespace Posix
|
} // namespace Posix
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "../Participant.h"
|
#include "../Participant.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
namespace Posix {
|
namespace Posix {
|
||||||
|
|
||||||
@ -16,4 +15,3 @@ class Participant : public RoboidControl::Participant {
|
|||||||
|
|
||||||
} // namespace Posix
|
} // namespace Posix
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -9,6 +9,6 @@ Supporting:
|
|||||||
|
|
||||||
# Basic components
|
# Basic components
|
||||||
|
|
||||||
- Passer::RoboidControl::Thing
|
- RoboidControl::Thing
|
||||||
- Passer::RoboidControl::Participant
|
- RoboidControl::Participant
|
||||||
- Passer::RoboidControl::SiteServer
|
- RoboidControl::SiteServer
|
@ -1,6 +1,5 @@
|
|||||||
#include "RemoteParticipant.h"
|
#include "RemoteParticipant.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
RemoteParticipant::RemoteParticipant() {}
|
RemoteParticipant::RemoteParticipant() {}
|
||||||
@ -51,4 +50,3 @@ void RemoteParticipant::UpdateAll(unsigned long currentTimeMs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace Control
|
||||||
} // namespace Passer
|
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
class RemoteParticipant {
|
class RemoteParticipant {
|
||||||
@ -25,4 +24,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace Control
|
||||||
} // namespace Passer
|
|
@ -1,6 +1,5 @@
|
|||||||
#include "DigitalSensor.h"
|
#include "DigitalSensor.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
DigitalSensor::DigitalSensor() {}
|
DigitalSensor::DigitalSensor() {}
|
||||||
@ -8,4 +7,3 @@ DigitalSensor::DigitalSensor() {}
|
|||||||
DigitalSensor::DigitalSensor(unsigned char networkId, unsigned char thingId) {}
|
DigitalSensor::DigitalSensor(unsigned char networkId, unsigned char thingId) {}
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A digital (on/off, 1/0, true/false) sensor
|
/// @brief A digital (on/off, 1/0, true/false) sensor
|
||||||
@ -20,4 +19,3 @@ class DigitalSensor : public Thing {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -2,28 +2,27 @@
|
|||||||
|
|
||||||
#include "Messages/LowLevelMessages.h"
|
#include "Messages/LowLevelMessages.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
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,
|
TemperatureSensor::TemperatureSensor(unsigned char networkId, unsigned char thingId)
|
||||||
unsigned char thingId)
|
|
||||||
: Thing(nullptr, networkId, thingId, Type::TemperatureSensor) {}
|
: Thing(nullptr, networkId, thingId, Type::TemperatureSensor) {}
|
||||||
|
|
||||||
void TemperatureSensor::SetTemperature(float temp) { this->temperature = temp; }
|
void TemperatureSensor::SetTemperature(float temp) {
|
||||||
|
this->temperature = temp;
|
||||||
|
}
|
||||||
|
|
||||||
void TemperatureSensor::GenerateBinary(char *buffer, unsigned char *ix) {
|
void TemperatureSensor::GenerateBinary(char* buffer, unsigned char* ix) {
|
||||||
std::cout << "Send temperature: " << this->temperature << "\n";
|
std::cout << "Send temperature: " << this->temperature << "\n";
|
||||||
LowLevelMessages::SendFloat16(buffer, ix, this->temperature);
|
LowLevelMessages::SendFloat16(buffer, ix, this->temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperatureSensor::ProcessBinary(char *bytes) {
|
void TemperatureSensor::ProcessBinary(char* bytes) {
|
||||||
unsigned char ix = 0;
|
unsigned char ix = 0;
|
||||||
this->temperature = LowLevelMessages::ReceiveFloat16(bytes, &ix);
|
this->temperature = LowLevelMessages::ReceiveFloat16(bytes, &ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A temperature sensor
|
/// @brief A temperature sensor
|
||||||
@ -32,4 +31,3 @@ class TemperatureSensor : public Thing {
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -5,7 +5,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
SiteServer::SiteServer(int port) {
|
SiteServer::SiteServer(int port) {
|
||||||
@ -50,4 +49,3 @@ void SiteServer::Process(RemoteParticipant *sender, ThingMsg *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace Control
|
||||||
} // namespace Passer
|
|
||||||
|
24
SiteServer.h
24
SiteServer.h
@ -6,35 +6,31 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief A participant is device which can communicate with other participants
|
/// @brief A participant is device which can communicate with other participants
|
||||||
class SiteServer : public Participant {
|
class SiteServer : public Participant {
|
||||||
public:
|
public:
|
||||||
SiteServer(int port = 7681);
|
SiteServer(int port = 7681);
|
||||||
|
|
||||||
// virtual void Update(unsigned long currentTimeMs = 0) override;
|
// virtual void Update(unsigned long currentTimeMs = 0) override;
|
||||||
|
|
||||||
template <typename ThingClass> void Register(unsigned char thingType) {
|
template <typename ThingClass>
|
||||||
thingMsgProcessors[thingType] = [](unsigned char networkId,
|
void Register(unsigned char thingType) {
|
||||||
unsigned char thingId) {
|
thingMsgProcessors[thingType] = [](unsigned char networkId, unsigned char thingId) {
|
||||||
return new ThingClass(networkId, thingId);
|
return new ThingClass(networkId, thingId);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
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, NetworkIdMsg* msg) override;
|
||||||
virtual void Process(RemoteParticipant* sender, ThingMsg *msg) override;
|
virtual void Process(RemoteParticipant* sender, ThingMsg* msg) override;
|
||||||
|
|
||||||
using ThingConstructor =
|
using ThingConstructor = std::function<Thing*(unsigned char networkId, unsigned char thingId)>;
|
||||||
std::function<Thing *(unsigned char networkId, unsigned char thingId)>;
|
|
||||||
std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
|
std::unordered_map<unsigned char, ThingConstructor> thingMsgProcessors;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
using namespace Passer::RoboidControl;
|
|
||||||
|
123
Thing.cpp
123
Thing.cpp
@ -1,13 +1,12 @@
|
|||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
#include "Participant.h"
|
#include <string.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string.h>
|
#include "Participant.h"
|
||||||
|
|
||||||
namespace Passer {
|
namespace RoboidControl {
|
||||||
namespace RoboidControl {
|
|
||||||
|
|
||||||
Thing::Thing(Type thingType) : Thing((unsigned char)thingType) {}
|
Thing::Thing(Type thingType) : Thing((unsigned char)thingType) {}
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ Thing::Thing(unsigned char thingType) {
|
|||||||
this->angularVelocity = Spherical16::zero;
|
this->angularVelocity = Spherical16::zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing::Thing(RemoteParticipant *participant, unsigned char networkId,
|
Thing::Thing(RemoteParticipant* participant, unsigned char networkId, unsigned char thingId, Type thingType) {
|
||||||
unsigned char thingId, Type thingType) {
|
|
||||||
// no participant reference yet..
|
// no participant reference yet..
|
||||||
this->participant = participant;
|
this->participant = participant;
|
||||||
this->networkId = networkId;
|
this->networkId = networkId;
|
||||||
@ -41,25 +39,25 @@ void Thing::Terminate() {
|
|||||||
// Thing::Remove(this);
|
// Thing::Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing *Thing::FindThing(const char *name) {
|
Thing* Thing::FindThing(const char* name) {
|
||||||
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
||||||
Thing *child = this->children[childIx];
|
Thing* child = this->children[childIx];
|
||||||
if (child == nullptr || child->name == nullptr)
|
if (child == nullptr || child->name == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(child->name, name) == 0)
|
if (strcmp(child->name, name) == 0)
|
||||||
return child;
|
return child;
|
||||||
|
|
||||||
Thing *foundChild = child->FindThing(name);
|
Thing* foundChild = child->FindThing(name);
|
||||||
if (foundChild != nullptr)
|
if (foundChild != nullptr)
|
||||||
return foundChild;
|
return foundChild;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thing::SetParent(Thing *parent) {
|
void Thing::SetParent(Thing* parent) {
|
||||||
if (parent == nullptr) {
|
if (parent == nullptr) {
|
||||||
Thing *parentThing = this->parent;
|
Thing* parentThing = this->parent;
|
||||||
if (parentThing != nullptr)
|
if (parentThing != nullptr)
|
||||||
parentThing->RemoveChild(this);
|
parentThing->RemoveChild(this);
|
||||||
this->parent = nullptr;
|
this->parent = nullptr;
|
||||||
@ -67,18 +65,19 @@ void Thing::SetParent(Thing *parent) {
|
|||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thing::SetParent(Thing *root, const char *name) {
|
void Thing::SetParent(Thing* root, const char* name) {
|
||||||
Thing *thing = root->FindThing(name);
|
Thing* thing = root->FindThing(name);
|
||||||
if (thing != nullptr)
|
if (thing != nullptr)
|
||||||
this->SetParent(thing);
|
this->SetParent(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing *Thing::GetParent() { return this->parent; }
|
Thing* Thing::GetParent() {
|
||||||
|
return this->parent;
|
||||||
void Thing::AddChild(Thing *child) {
|
}
|
||||||
|
|
||||||
|
void Thing::AddChild(Thing* child) {
|
||||||
unsigned char newChildCount = this->childCount + 1;
|
unsigned char newChildCount = this->childCount + 1;
|
||||||
Thing **newChildren = new Thing *[newChildCount];
|
Thing** newChildren = new Thing*[newChildCount];
|
||||||
|
|
||||||
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
||||||
newChildren[childIx] = this->children[childIx];
|
newChildren[childIx] = this->children[childIx];
|
||||||
@ -99,14 +98,14 @@ void Thing::AddChild(Thing *child) {
|
|||||||
this->childCount = newChildCount;
|
this->childCount = newChildCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing *Thing::RemoveChild(Thing *child) {
|
Thing* Thing::RemoveChild(Thing* child) {
|
||||||
unsigned char newChildCount = this->childCount - 1;
|
unsigned char newChildCount = this->childCount - 1;
|
||||||
Thing **newChildren = new Thing *[newChildCount];
|
Thing** newChildren = new Thing*[newChildCount];
|
||||||
|
|
||||||
unsigned char newChildIx = 0;
|
unsigned char newChildIx = 0;
|
||||||
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
||||||
if (this->children[childIx] != child) {
|
if (this->children[childIx] != child) {
|
||||||
if (newChildIx == newChildCount) { // We did not find the child
|
if (newChildIx == newChildCount) { // We did not find the child
|
||||||
// stop copying and return nothing
|
// stop copying and return nothing
|
||||||
delete[] newChildren;
|
delete[] newChildren;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -124,16 +123,16 @@ Thing *Thing::RemoveChild(Thing *child) {
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing *Thing::GetChild(unsigned char id, bool recursive) {
|
Thing* Thing::GetChild(unsigned char id, bool recursive) {
|
||||||
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
||||||
Thing *child = this->children[childIx];
|
Thing* child = this->children[childIx];
|
||||||
if (child == nullptr)
|
if (child == nullptr)
|
||||||
continue;
|
continue;
|
||||||
if (child->id == id)
|
if (child->id == id)
|
||||||
return child;
|
return child;
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
Thing *foundChild = child->GetChild(id, recursive);
|
Thing* foundChild = child->GetChild(id, recursive);
|
||||||
if (foundChild != nullptr)
|
if (foundChild != nullptr)
|
||||||
return foundChild;
|
return foundChild;
|
||||||
}
|
}
|
||||||
@ -141,9 +140,13 @@ Thing *Thing::GetChild(unsigned char id, bool recursive) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thing *Thing::GetChildByIndex(unsigned char ix) { return this->children[ix]; }
|
Thing* Thing::GetChildByIndex(unsigned char ix) {
|
||||||
|
return this->children[ix];
|
||||||
|
}
|
||||||
|
|
||||||
void Thing::SetModel(const char *url) { this->modelUrl = url; }
|
void Thing::SetModel(const char* url) {
|
||||||
|
this->modelUrl = url;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(ARDUINO)
|
#if defined(ARDUINO)
|
||||||
void Thing::Update() {
|
void Thing::Update() {
|
||||||
@ -151,73 +154,37 @@ void Thing::Update() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Thing::GenerateBinary(char *buffer, unsigned char *ix) {
|
void Thing::GenerateBinary(char* buffer, unsigned char* ix) {
|
||||||
(void)buffer;
|
(void)buffer;
|
||||||
(void)ix;
|
(void)ix;
|
||||||
}
|
}
|
||||||
void Thing::ProcessBinary(char *bytes) { (void)bytes; };
|
void Thing::ProcessBinary(char* bytes) {
|
||||||
|
(void)bytes;
|
||||||
|
};
|
||||||
|
|
||||||
void Thing::SetPosition(Spherical16 position) {
|
void Thing::SetPosition(Spherical16 position) {
|
||||||
this->position = position;
|
this->position = position;
|
||||||
this->positionUpdated = true;
|
this->positionUpdated = true;
|
||||||
}
|
}
|
||||||
Spherical16 Thing::GetPosition() { return this->position; }
|
Spherical16 Thing::GetPosition() {
|
||||||
|
return this->position;
|
||||||
|
}
|
||||||
|
|
||||||
void Thing::SetOrientation(SwingTwist16 orientation) {
|
void Thing::SetOrientation(SwingTwist16 orientation) {
|
||||||
this->orientation = orientation;
|
this->orientation = orientation;
|
||||||
this->orientationUpdated = true;
|
this->orientationUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwingTwist16 Thing::GetOrientation() { return this->orientation; }
|
SwingTwist16 Thing::GetOrientation() {
|
||||||
|
return this->orientation;
|
||||||
|
}
|
||||||
|
|
||||||
Spherical16 Thing::GetLinearVelocity() { return this->linearVelocity; }
|
Spherical16 Thing::GetLinearVelocity() {
|
||||||
|
return this->linearVelocity;
|
||||||
|
}
|
||||||
|
|
||||||
Spherical16 Thing::GetAngularVelocity() { return this->angularVelocity; }
|
Spherical16 Thing::GetAngularVelocity() {
|
||||||
|
return this->angularVelocity;
|
||||||
|
}
|
||||||
|
|
||||||
// All things
|
} // namespace RoboidControl
|
||||||
// std::list<Thing *> Thing::allThings;
|
|
||||||
|
|
||||||
// Thing *Thing::Get(unsigned char networkId, unsigned char thingId) {
|
|
||||||
// std::cout << "Get " << (int)networkId << "/" << (int)thingId << " from "
|
|
||||||
// << allThings.size() << " things\n";
|
|
||||||
// for (auto &thing : allThings) {
|
|
||||||
// std::cout << " ? " << (int)thing->networkId << "/" << (int)thing->id
|
|
||||||
// << "\n";
|
|
||||||
// if (thing->networkId == networkId && thing->id == thingId) {
|
|
||||||
// return thing;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return nullptr;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int Thing::Add(Thing *newThing) {
|
|
||||||
// for (Thing *thing : allThings) {
|
|
||||||
// if (thing == newThing)
|
|
||||||
// return thing->id;
|
|
||||||
// }
|
|
||||||
// std::cout << "Adding " << (int)newThing->networkId << "/" <<
|
|
||||||
// (int)newThing->id
|
|
||||||
// << "\n";
|
|
||||||
// allThings.push_back(newThing);
|
|
||||||
// return allThings.size();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void Thing::Remove(Thing *thing) {
|
|
||||||
// Thing::allThings.remove_if([thing](Thing *obj) { return obj == thing; });
|
|
||||||
// std::cout << "Removing " << thing->networkId << "/" << thing->id
|
|
||||||
// << " list size = " << allThings.size() << "\n";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void Thing::UpdateAll(unsigned long currentTimeMs) {
|
|
||||||
// // Not very efficient, but it works for now.
|
|
||||||
|
|
||||||
// for (Thing *thing : Thing::allThings) {
|
|
||||||
// if (thing != nullptr &&
|
|
||||||
// thing->parent == nullptr) { // update all root things
|
|
||||||
// // std::cout << " update " << (int)ix << " thingid " << (int)thing->id
|
|
||||||
// // << "\n";
|
|
||||||
// thing->Update(currentTimeMs);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}}
|
|
68
Thing.h
68
Thing.h
@ -1,10 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "LinearAlgebra/Spherical.h"
|
|
||||||
#include "LinearAlgebra/SwingTwist.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include "LinearAlgebra/Spherical.h"
|
||||||
|
#include "LinearAlgebra/SwingTwist.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
class RemoteParticipant;
|
class RemoteParticipant;
|
||||||
@ -15,8 +14,8 @@ class RemoteParticipant;
|
|||||||
|
|
||||||
/// @brief A thing is the primitive building block
|
/// @brief A thing is the primitive building block
|
||||||
class Thing {
|
class Thing {
|
||||||
public:
|
public:
|
||||||
RemoteParticipant *participant;
|
RemoteParticipant* participant;
|
||||||
unsigned char networkId = 0;
|
unsigned char networkId = 0;
|
||||||
/// @brief The ID of the thing
|
/// @brief The ID of the thing
|
||||||
unsigned char id = 0;
|
unsigned char id = 0;
|
||||||
@ -52,31 +51,33 @@ public:
|
|||||||
/// @param networkId The network ID of the thing
|
/// @param networkId The network ID of the thing
|
||||||
/// @param thingId The ID of the thing
|
/// @param thingId The ID of the thing
|
||||||
/// @param thingType The type of thing
|
/// @param thingType The type of thing
|
||||||
Thing(RemoteParticipant *participant, unsigned char networkId,
|
Thing(RemoteParticipant* participant,
|
||||||
unsigned char thingId, Type thingType = Type::Undetermined);
|
unsigned char networkId,
|
||||||
|
unsigned char thingId,
|
||||||
|
Type thingType = Type::Undetermined);
|
||||||
|
|
||||||
/// @brief Find a thing by name
|
/// @brief Find a thing by name
|
||||||
/// @param name Rhe name of the thing
|
/// @param name Rhe name of the thing
|
||||||
/// @return The found thing or nullptr when nothing is found
|
/// @return The found thing or nullptr when nothing is found
|
||||||
Thing *FindThing(const char *name);
|
Thing* FindThing(const char* name);
|
||||||
|
|
||||||
/// @brief Sets the parent Thing
|
/// @brief Sets the parent Thing
|
||||||
/// @param parent The Thing which should become the parnet
|
/// @param parent The Thing which should become the parnet
|
||||||
/// @remark This is equivalent to calling parent->AddChild(this);
|
/// @remark This is equivalent to calling parent->AddChild(this);
|
||||||
virtual void SetParent(Thing *parent);
|
virtual void SetParent(Thing* parent);
|
||||||
void SetParent(Thing *root, const char *name);
|
void SetParent(Thing* root, const char* name);
|
||||||
/// @brief Gets the parent Thing
|
/// @brief Gets the parent Thing
|
||||||
/// @return The parent Thing
|
/// @return The parent Thing
|
||||||
Thing *GetParent();
|
Thing* GetParent();
|
||||||
|
|
||||||
/// @brief Add a child Thing to this Thing
|
/// @brief Add a child Thing to this Thing
|
||||||
/// @param child The Thing which should become a child
|
/// @param child The Thing which should become a child
|
||||||
/// @remark When the Thing is already a child, it will not be added again
|
/// @remark When the Thing is already a child, it will not be added again
|
||||||
virtual void AddChild(Thing *child);
|
virtual void AddChild(Thing* child);
|
||||||
/// @brief Remove the given thing as a child of this thing
|
/// @brief Remove the given thing as a child of this thing
|
||||||
/// @param child The child to remove
|
/// @param child The child to remove
|
||||||
/// @return The removed child or nullptr if the child could not be found
|
/// @return The removed child or nullptr if the child could not be found
|
||||||
Thing *RemoveChild(Thing *child);
|
Thing* RemoveChild(Thing* child);
|
||||||
|
|
||||||
/// @brief The number of children
|
/// @brief The number of children
|
||||||
unsigned char childCount = 0;
|
unsigned char childCount = 0;
|
||||||
@ -84,21 +85,21 @@ public:
|
|||||||
/// @param id The thing ID to find
|
/// @param id The thing ID to find
|
||||||
/// @param recursive Look recursively through all descendants
|
/// @param recursive Look recursively through all descendants
|
||||||
/// @return The found thing of nullptr when nothing is found
|
/// @return The found thing of nullptr when nothing is found
|
||||||
Thing *GetChild(unsigned char id, bool recursive = false);
|
Thing* GetChild(unsigned char id, bool recursive = false);
|
||||||
/// @brief Get a child by index
|
/// @brief Get a child by index
|
||||||
/// @param ix The child index
|
/// @param ix The child index
|
||||||
/// @return The found thing of nullptr when nothing is found
|
/// @return The found thing of nullptr when nothing is found
|
||||||
Thing *GetChildByIndex(unsigned char ix);
|
Thing* GetChildByIndex(unsigned char ix);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Thing *parent = nullptr;
|
Thing* parent = nullptr;
|
||||||
Thing **children = nullptr;
|
Thing** children = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief The name of the thing
|
/// @brief The name of the thing
|
||||||
const char *name = nullptr;
|
const char* name = nullptr;
|
||||||
/// @brief An URL pointing to the location where a model of the thing can be found
|
/// @brief An URL pointing to the location where a model of the thing can be found
|
||||||
const char *modelUrl = nullptr;
|
const char* modelUrl = nullptr;
|
||||||
/// @brief The scale of the model (deprecated I think)
|
/// @brief The scale of the model (deprecated I think)
|
||||||
float modelScale = 1;
|
float modelScale = 1;
|
||||||
|
|
||||||
@ -115,14 +116,14 @@ public:
|
|||||||
/// @return The orienation in local space
|
/// @return The orienation in local space
|
||||||
SwingTwist16 GetOrientation();
|
SwingTwist16 GetOrientation();
|
||||||
/// @brief The scale of the thing (deprecated I think)
|
/// @brief The scale of the thing (deprecated I think)
|
||||||
float scale = 1; // assuming uniform scale
|
float scale = 1; // assuming uniform scale
|
||||||
|
|
||||||
/// @brief boolean indicating if the position was updated
|
/// @brief boolean indicating if the position was updated
|
||||||
bool positionUpdated = false;
|
bool positionUpdated = false;
|
||||||
/// @brief boolean indicating if the orientation was updated
|
/// @brief boolean indicating if the orientation was updated
|
||||||
bool orientationUpdated = false;
|
bool orientationUpdated = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @brief The position in local space
|
/// @brief The position in local space
|
||||||
/// @remark When this Thing has a parent, the position is relative to the
|
/// @remark When this Thing has a parent, the position is relative to the
|
||||||
/// parent's position and orientation
|
/// parent's position and orientation
|
||||||
@ -132,7 +133,7 @@ protected:
|
|||||||
/// parent's orientation
|
/// parent's orientation
|
||||||
SwingTwist16 orientation;
|
SwingTwist16 orientation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Spherical16 linearVelocity;
|
Spherical16 linearVelocity;
|
||||||
Spherical16 angularVelocity;
|
Spherical16 angularVelocity;
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ public:
|
|||||||
/// @return The angular velocity in local space
|
/// @return The angular velocity in local space
|
||||||
virtual Spherical16 GetAngularVelocity();
|
virtual Spherical16 GetAngularVelocity();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief Terminated things are no longer updated
|
/// @brief Terminated things are no longer updated
|
||||||
void Terminate();
|
void Terminate();
|
||||||
|
|
||||||
@ -152,12 +153,12 @@ public:
|
|||||||
/// @param url The url of the model
|
/// @param url The url of the model
|
||||||
/// @remark Although the roboid implementation is not dependent on the model,
|
/// @remark Although the roboid implementation is not dependent on the model,
|
||||||
/// the only official supported model format is .obj
|
/// the only official supported model format is .obj
|
||||||
void SetModel(const char *url);
|
void SetModel(const char* url);
|
||||||
|
|
||||||
#if defined(ARDUINO)
|
#if defined(ARDUINO)
|
||||||
void Update();
|
void Update();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// @brief Updates the state of the thing
|
/// @brief Updates the state of the thing
|
||||||
/// @param currentTimeMs The current clock time in milliseconds
|
/// @param currentTimeMs The current clock time in milliseconds
|
||||||
virtual void Update(unsigned long currentTimeMs) { (void)currentTimeMs; };
|
virtual void Update(unsigned long currentTimeMs) { (void)currentTimeMs; };
|
||||||
@ -165,13 +166,10 @@ public:
|
|||||||
/// @brief Function used to generate binary data for this thing
|
/// @brief Function used to generate binary data for this thing
|
||||||
/// @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
|
||||||
virtual void GenerateBinary(char *buffer, unsigned char *ix);
|
virtual void GenerateBinary(char* buffer, unsigned char* ix);
|
||||||
// /// @brief FUnction used to process binary data received for this thing
|
// /// @brief FUnction used to process binary data received for this thing
|
||||||
/// @param bytes The binary data
|
/// @param bytes The binary data
|
||||||
virtual void ProcessBinary(char *bytes);
|
virtual void ProcessBinary(char* bytes);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Control
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
||||||
using namespace Passer::RoboidControl;
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
namespace Windows {
|
namespace Windows {
|
||||||
|
|
||||||
@ -196,4 +195,3 @@ bool Participant::Publish(IMessage* msg) {
|
|||||||
|
|
||||||
} // namespace Windows
|
} // namespace Windows
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "../Participant.h"
|
#include "../Participant.h"
|
||||||
|
|
||||||
namespace Passer {
|
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
namespace Windows {
|
namespace Windows {
|
||||||
|
|
||||||
@ -16,4 +15,3 @@ class Participant : public RoboidControl::Participant {
|
|||||||
|
|
||||||
} // namespace Windows
|
} // namespace Windows
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
|
@ -4,12 +4,13 @@
|
|||||||
// not supported using Visual Studio 2022 compiler...
|
// not supported using Visual Studio 2022 compiler...
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
// #include "../Thing.h"
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "Participant.h"
|
#include "Participant.h"
|
||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
|
using namespace RoboidControl;
|
||||||
|
|
||||||
class ControlCoreSuite2 : public ::testing::Test {
|
class ControlCoreSuite2 : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
// SetUp and TearDown can be used to set up and clean up before/after each
|
// SetUp and TearDown can be used to set up and clean up before/after each
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "SiteServer.h"
|
#include "SiteServer.h"
|
||||||
#include "Thing.h"
|
#include "Thing.h"
|
||||||
|
|
||||||
namespace Passer {
|
using namespace RoboidControl;
|
||||||
|
|
||||||
// Function to get the current time in milliseconds as unsigned long
|
// Function to get the current time in milliseconds as unsigned long
|
||||||
unsigned long get_time_ms() {
|
unsigned long get_time_ms() {
|
||||||
@ -94,6 +94,4 @@ TEST_F(ControlCoreSuite, Thing) {
|
|||||||
ASSERT_EQ(1, 1);
|
ASSERT_EQ(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Passer
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user