From 5b5513971c6690df32f99d56c4b25469df9aeb02 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 18 May 2025 17:34:52 +0200 Subject: [PATCH] Reduced the use of raw pointers --- CMakeLists.txt | 6 +++--- LinearAlgebra/Direction.cpp | 6 ++++-- LinearAlgebra/Direction.h | 2 -- LinearAlgebra/Polar.cpp | 4 ++-- LinearAlgebra/Spherical.cpp | 4 ++++ LinearAlgebra/Spherical.h | 1 - LinearAlgebra/SwingTwist.cpp | 6 +++++- LinearAlgebra/test/Direction_test.cc | 2 ++ Participant.cpp | 2 ++ Participant.h | 14 ++++++++------ Posix/PosixParticipant.cpp | 8 ++++---- Posix/PosixParticipant.h | 5 +++++ Thing.cpp | 11 ++++++----- Thing.h | 11 ++++------- Things/DifferentialDrive.cpp | 6 +++++- Things/DifferentialDrive.h | 5 +++-- Things/DigitalSensor.cpp | 3 ++- Things/DigitalSensor.h | 3 ++- Things/Motor.cpp | 14 +++++++++++--- Things/Motor.h | 5 +++-- Things/RelativeEncoder.cpp | 4 ++-- Things/RelativeEncoder.h | 3 ++- Things/TemperatureSensor.cpp | 4 +++- Things/TemperatureSensor.h | 3 ++- Things/TouchSensor.cpp | 3 ++- Things/TouchSensor.h | 5 +++-- examples/BB2B.cpp | 14 +++++++------- test/participant_test.cc | 15 +++++++++------ test/thing_test.cc | 4 ++-- 29 files changed, 107 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09c1b91..e4a9a1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,13 +19,13 @@ if(ESP_PLATFORM) REQUIRES esp_netif esp_wifi ) else() + set(CMAKE_CXX_STANDARD 17) # Enable c++11 standard + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + project(RoboidControl) add_subdirectory(LinearAlgebra) add_subdirectory(Examples) - set(CMAKE_CXX_STANDARD 17) # Enable c++11 standard - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - add_compile_definitions(GTEST) include(FetchContent) FetchContent_Declare( diff --git a/LinearAlgebra/Direction.cpp b/LinearAlgebra/Direction.cpp index f9c5e40..86fa77c 100644 --- a/LinearAlgebra/Direction.cpp +++ b/LinearAlgebra/Direction.cpp @@ -9,6 +9,7 @@ #include +namespace LinearAlgebra { template DirectionOf::DirectionOf() { this->horizontal = AngleOf(); @@ -98,5 +99,6 @@ void DirectionOf::Normalize() { } } -template class DirectionOf; -template class DirectionOf; +template class LinearAlgebra::DirectionOf; +template class LinearAlgebra::DirectionOf; +} \ No newline at end of file diff --git a/LinearAlgebra/Direction.h b/LinearAlgebra/Direction.h index 57f6647..8c58b6c 100644 --- a/LinearAlgebra/Direction.h +++ b/LinearAlgebra/Direction.h @@ -99,6 +99,4 @@ using Direction = DirectionSingle; } // namespace LinearAlgebra -using namespace LinearAlgebra; - #endif \ No newline at end of file diff --git a/LinearAlgebra/Polar.cpp b/LinearAlgebra/Polar.cpp index 9dea130..15ac40f 100644 --- a/LinearAlgebra/Polar.cpp +++ b/LinearAlgebra/Polar.cpp @@ -175,5 +175,5 @@ PolarOf PolarOf::Rotate(const PolarOf& v, AngleOf angle) { return r; } -template class PolarOf; -template class PolarOf; \ No newline at end of file +template class LinearAlgebra::PolarOf; +template class LinearAlgebra::PolarOf; \ No newline at end of file diff --git a/LinearAlgebra/Spherical.cpp b/LinearAlgebra/Spherical.cpp index 1a50357..0371f92 100644 --- a/LinearAlgebra/Spherical.cpp +++ b/LinearAlgebra/Spherical.cpp @@ -5,6 +5,8 @@ #include +namespace LinearAlgebra { + template SphericalOf::SphericalOf() { this->distance = 0.0f; @@ -301,3 +303,5 @@ SphericalOf SphericalOf::RotateVertical(const SphericalOf& v, template class SphericalOf; template class SphericalOf; + +} // namespace LinearAlgebra \ No newline at end of file diff --git a/LinearAlgebra/Spherical.h b/LinearAlgebra/Spherical.h index 5cad52c..309db03 100644 --- a/LinearAlgebra/Spherical.h +++ b/LinearAlgebra/Spherical.h @@ -186,7 +186,6 @@ using Spherical = SphericalSingle; #endif } // namespace LinearAlgebra -using namespace LinearAlgebra; #include "Polar.h" #include "Vector3.h" diff --git a/LinearAlgebra/SwingTwist.cpp b/LinearAlgebra/SwingTwist.cpp index 58905c7..deca73c 100644 --- a/LinearAlgebra/SwingTwist.cpp +++ b/LinearAlgebra/SwingTwist.cpp @@ -4,6 +4,8 @@ #include "SwingTwist.h" +namespace LinearAlgebra { + template SwingTwistOf::SwingTwistOf() { this->swing = DirectionOf(AngleOf(), AngleOf()); @@ -165,4 +167,6 @@ void SwingTwistOf::Normalize() { } template class SwingTwistOf; -template class SwingTwistOf; \ No newline at end of file +template class SwingTwistOf; + +} \ No newline at end of file diff --git a/LinearAlgebra/test/Direction_test.cc b/LinearAlgebra/test/Direction_test.cc index 461140c..6489caa 100644 --- a/LinearAlgebra/test/Direction_test.cc +++ b/LinearAlgebra/test/Direction_test.cc @@ -6,6 +6,8 @@ #include "Direction.h" +using namespace LinearAlgebra; + #define FLOAT_INFINITY std::numeric_limits::infinity() TEST(Direction16, Compare) { diff --git a/Participant.cpp b/Participant.cpp index 03197e6..51dfabd 100644 --- a/Participant.cpp +++ b/Participant.cpp @@ -8,6 +8,8 @@ namespace RoboidControl { ParticipantRegistry Participant::registry; +Participant LocalParticipant = Participant("0.0.0.0", 0); + Participant::Participant(const char* ipAddress, int port) { // make a copy of the ip address string int addressLength = (int)strlen(ipAddress); diff --git a/Participant.h b/Participant.h index 49ee749..35c5ce4 100644 --- a/Participant.h +++ b/Participant.h @@ -10,7 +10,7 @@ class ParticipantRegistry { public: /// @brief Retrieve a participant by its address /// @param ipAddress The IP address of the participant - /// @param port The port number of the participant + /// @param port The port number of the participant /// @return The participant or a nullptr when it could not be found Participant* Get(const char* ipAddress, unsigned int port); /// @brief Retrieve a participant by its network ID @@ -20,7 +20,7 @@ class ParticipantRegistry { /// @brief Add a participant with the given details /// @param ipAddress The IP address of the participant - /// @param port The port number of the participant + /// @param port The port number of the participant /// @return The added participant Participant* Add(const char* ipAddress, unsigned int port); /// @brief Add a participant @@ -33,17 +33,17 @@ class ParticipantRegistry { private: #if defined(NO_STD) -public: + public: Participant** GetAll() const; int count = 0; -private: + private: Participant** participants; #else -public: + public: /// @brief Get all participants /// @return All participants const std::list& GetAll() const; -private: + private: /// @brief The list of known participants std::list participants; #endif @@ -72,6 +72,8 @@ class Participant { /// @brief Destructor for the participant ~Participant(); + static Participant LocalParticipant; + public: #if defined(NO_STD) unsigned char thingCount = 0; diff --git a/Posix/PosixParticipant.cpp b/Posix/PosixParticipant.cpp index 466035a..a01a059 100644 --- a/Posix/PosixParticipant.cpp +++ b/Posix/PosixParticipant.cpp @@ -11,7 +11,7 @@ namespace RoboidControl { namespace Posix { -void Setup(int localPort, const char* remoteIpAddress, int remotePort) { +void ParticipantUDP::Setup(int localPort, const char* remoteIpAddress, int remotePort) { #if defined(__unix__) || defined(__APPLE__) // Create a UDP socket @@ -63,7 +63,7 @@ void Setup(int localPort, const char* remoteIpAddress, int remotePort) { #endif } -void Receive() { +void ParticipantUDP::Receive() { #if defined(__unix__) || defined(__APPLE__) sockaddr_in client_addr; socklen_t len = sizeof(client_addr); @@ -90,7 +90,7 @@ void Receive() { #endif } -bool Send(Participant* remoteParticipant, int bufferSize) { +bool ParticipantUDP::Send(Participant* remoteParticipant, int bufferSize) { #if defined(__unix__) || defined(__APPLE__) // std::cout << "Send to " << remoteParticipant->ipAddress << ":" << ntohs(remoteParticipant->port) // << "\n"; @@ -113,7 +113,7 @@ bool Send(Participant* remoteParticipant, int bufferSize) { return true; } -bool Publish(IMessage* msg) { +bool ParticipantUDP::Publish(IMessage* msg) { #if defined(__unix__) || defined(__APPLE__) int bufferSize = msg->Serialize(this->buffer); if (bufferSize <= 0) diff --git a/Posix/PosixParticipant.h b/Posix/PosixParticipant.h index ec16d32..a83569f 100644 --- a/Posix/PosixParticipant.h +++ b/Posix/PosixParticipant.h @@ -11,6 +11,11 @@ class ParticipantUDP : public RoboidControl::ParticipantUDP { void Receive(); bool Send(Participant* remoteParticipant, int bufferSize); bool Publish(IMessage* msg); + + protected: + sockaddr_in remote_addr; + sockaddr_in server_addr; + sockaddr_in broadcast_addr; }; } // namespace Posix diff --git a/Thing.cpp b/Thing.cpp index 67a704e..3f8168c 100644 --- a/Thing.cpp +++ b/Thing.cpp @@ -20,7 +20,7 @@ namespace RoboidControl { #pragma region Init -Thing Root = Thing(Thing::Type::Undetermined, Root); +Thing Thing::Root = Thing(Thing::Type::Undetermined, Root); Thing::Thing(unsigned char thingType, Thing& parent) { this->type = thingType; @@ -38,6 +38,7 @@ Thing::Thing(unsigned char thingType, Thing& parent) { // << this->owner->ipAddress << ":" << this->owner->port << // std::endl; this->owner->Add(this, true); + this->SetParent(&parent); } Thing::Thing(Participant* owner, unsigned char thingType) { @@ -63,10 +64,10 @@ Thing::Thing(Participant* owner, unsigned char thingType) { this->owner->Add(this, true); } -Thing::Thing(Thing* parent, unsigned char thingType) //, unsigned char thingId) - : Thing(parent->owner, thingType) { //}, thingId) { - this->SetParent(parent); -} +// Thing::Thing(Thing* parent, unsigned char thingType) //, unsigned char thingId) +// : Thing(parent->owner, thingType) { //}, thingId) { +// this->SetParent(parent); +// } Thing Thing::Reconstruct(Participant* owner, unsigned char thingType, unsigned char thingId) { Thing thing = Thing(owner, thingType); diff --git a/Thing.h b/Thing.h index 8247bc5..cc97ab8 100644 --- a/Thing.h +++ b/Thing.h @@ -41,18 +41,17 @@ class Thing { }; #pragma region Init - static Thing Root; // = Thing(Type::Undetermined, Root); + static Thing Root; - Thing(unsigned char thingType = Type::Undetermined, Thing& parent = Root); + Thing(unsigned char thingType = Thing::Type::Undetermined, Thing& parent = Root); /// @brief Create a new thing for a participant /// @param owner The owning participant /// @param thingType The type of thing (can use Thing::Type) /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID - Thing(Participant* owner = nullptr, - unsigned char thingType = Type::Undetermined); - // unsigned char thingId = 0); + Thing(Participant* owner, + unsigned char thingType = Thing::Type::Undetermined); /// @brief Create a new child thing /// @param parent The parent thing @@ -60,8 +59,6 @@ class Thing { /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID /// @note The owner will be the same as the owner of the parent thing - Thing(Thing* parent, - unsigned char thingType = 0); //, unsigned char thingId = 0); static Thing Reconstruct(Participant* owner, unsigned char thingType, diff --git a/Things/DifferentialDrive.cpp b/Things/DifferentialDrive.cpp index 30b3c0b..29c9e66 100644 --- a/Things/DifferentialDrive.cpp +++ b/Things/DifferentialDrive.cpp @@ -16,7 +16,11 @@ DifferentialDrive::DifferentialDrive(Participant* owner) : Thing(owner, Type::Di this->leftWheel = new Motor(); this->rightWheel = new Motor(); } -DifferentialDrive::DifferentialDrive(Thing* parent) : Thing(parent, Type::DifferentialDrive) { +// DifferentialDrive::DifferentialDrive(Thing* parent) : Thing(parent, Type::DifferentialDrive) { +// this->leftWheel = new Motor(); +// this->rightWheel = new Motor(); +// } +DifferentialDrive::DifferentialDrive(Thing& parent) : Thing(Type::DifferentialDrive, parent) { this->leftWheel = new Motor(); this->rightWheel = new Motor(); } diff --git a/Things/DifferentialDrive.h b/Things/DifferentialDrive.h index 2647a12..65cd5a7 100644 --- a/Things/DifferentialDrive.h +++ b/Things/DifferentialDrive.h @@ -16,13 +16,14 @@ class DifferentialDrive : public Thing { /// @param participant The local participant /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID - DifferentialDrive(Participant* participant = nullptr); //, + DifferentialDrive(Participant* participant); //, //unsigned char thingId = 0); /// @brief Create a new child differential drive /// @param parent The parent thing /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID - DifferentialDrive(Thing* parent); //, unsigned char thingId = 0); + // DifferentialDrive(Thing* parent); //, unsigned char thingId = 0); + DifferentialDrive(Thing& parent = Thing::Root); /// @brief Configures the dimensions of the drive /// @param wheelDiameter The diameter of the wheels in meters diff --git a/Things/DigitalSensor.cpp b/Things/DigitalSensor.cpp index 08a959e..0ac2414 100644 --- a/Things/DigitalSensor.cpp +++ b/Things/DigitalSensor.cpp @@ -12,7 +12,8 @@ namespace RoboidControl { DigitalSensor::DigitalSensor(Participant* owner) : Thing(owner, Type::Switch) {} -DigitalSensor::DigitalSensor(Thing* parent) : Thing(parent, Type::Switch) {} +// DigitalSensor::DigitalSensor(Thing* parent) : Thing(parent, Type::Switch) {} +DigitalSensor::DigitalSensor(Thing& parent) : Thing(Type::Switch, parent) {} int DigitalSensor::GenerateBinary(char* bytes, unsigned char* ix) { bytes[(*ix)++] = state ? 1 : 0; diff --git a/Things/DigitalSensor.h b/Things/DigitalSensor.h index a9c0571..9b77f6b 100644 --- a/Things/DigitalSensor.h +++ b/Things/DigitalSensor.h @@ -18,7 +18,8 @@ class DigitalSensor : public Thing { /// @param parent The parent thing /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID - DigitalSensor(Thing* parent); //, unsigned char thingId = 0); + // DigitalSensor(Thing* parent); //, unsigned char thingId = 0); + DigitalSensor(Thing& parent = Thing::Root); /// @brief The sigital state bool state = 0; diff --git a/Things/Motor.cpp b/Things/Motor.cpp index 96b50a6..f9796b1 100644 --- a/Things/Motor.cpp +++ b/Things/Motor.cpp @@ -1,9 +1,17 @@ #include "Motor.h" -RoboidControl::Motor::Motor(Participant* owner) : Thing(owner, Type::UncontrolledMotor) {} +namespace RoboidControl { -RoboidControl::Motor::Motor(Thing* parent) : Thing(parent, Type::UncontrolledMotor) {} +RoboidControl::Motor::Motor(Participant* owner) + : Thing(owner, Type::UncontrolledMotor) {} + +// RoboidControl::Motor::Motor(Thing* parent) +// : Thing(parent, Type::UncontrolledMotor) {} + +Motor::Motor(Thing& parent) : Thing(Type::UncontrolledMotor, parent) {} void RoboidControl::Motor::SetTargetSpeed(float targetSpeed) { - this->targetSpeed = targetSpeed; + this->targetSpeed = targetSpeed; } + +} // namespace RoboidControl \ No newline at end of file diff --git a/Things/Motor.h b/Things/Motor.h index 1ff6716..d10d15b 100644 --- a/Things/Motor.h +++ b/Things/Motor.h @@ -6,8 +6,9 @@ namespace RoboidControl { class Motor : public Thing { public: - Motor(Participant* owner = nullptr); - Motor(Thing* parent); + Motor(Participant* owner); + // Motor(Thing* parent); + Motor(Thing& parent = Thing::Root); /// @brief Motor turning direction enum class Direction { Clockwise = 1, CounterClockwise = -1 }; diff --git a/Things/RelativeEncoder.cpp b/Things/RelativeEncoder.cpp index dd10cdd..e13891f 100644 --- a/Things/RelativeEncoder.cpp +++ b/Things/RelativeEncoder.cpp @@ -4,8 +4,8 @@ namespace RoboidControl { RelativeEncoder::RelativeEncoder(Participant* owner) : Thing(owner, Type::IncrementalEncoder) {} -RelativeEncoder::RelativeEncoder(Thing* parent) - : Thing(parent, Type::IncrementalEncoder) {} +// RelativeEncoder::RelativeEncoder(Thing* parent) +// : Thing(parent, Type::IncrementalEncoder) {} float RelativeEncoder::GetRotationSpeed() { return rotationSpeed; diff --git a/Things/RelativeEncoder.h b/Things/RelativeEncoder.h index fec8c2b..573e7c5 100644 --- a/Things/RelativeEncoder.h +++ b/Things/RelativeEncoder.h @@ -15,7 +15,8 @@ class RelativeEncoder : public Thing { /// @param distancePerRevolution The distance a wheel travels per full /// rotation RelativeEncoder(Participant* owner); - RelativeEncoder(Thing* parent); + // RelativeEncoder(Thing* parent); + RelativeEncoder(Thing& parent); /// @brief Get the rotation speed /// @return The speed in revolutions per second diff --git a/Things/TemperatureSensor.cpp b/Things/TemperatureSensor.cpp index 632b3c0..d9c9113 100644 --- a/Things/TemperatureSensor.cpp +++ b/Things/TemperatureSensor.cpp @@ -10,7 +10,9 @@ namespace RoboidControl { TemperatureSensor::TemperatureSensor(Participant* owner) : Thing(owner, Type::TemperatureSensor) {} -TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(parent, Type::TemperatureSensor) {} +TemperatureSensor::TemperatureSensor(Thing& parent) : Thing(Type::TemperatureSensor, parent) {} + +// TemperatureSensor::TemperatureSensor(Thing* parent) : Thing(parent, Type::TemperatureSensor) {} void TemperatureSensor::SetTemperature(float temp) { this->temperature = temp; diff --git a/Things/TemperatureSensor.h b/Things/TemperatureSensor.h index 629c178..23f56fa 100644 --- a/Things/TemperatureSensor.h +++ b/Things/TemperatureSensor.h @@ -13,7 +13,8 @@ class TemperatureSensor : public Thing { /// @param networkId The network ID of the sensor /// @param thingId The ID of the thing TemperatureSensor(Participant* participant); //, unsigned char thingId); - TemperatureSensor(Thing* parent); + // TemperatureSensor(Thing* parent); + TemperatureSensor(Thing& parent = Thing::Root); /// @brief The measured temperature float temperature = 0; diff --git a/Things/TouchSensor.cpp b/Things/TouchSensor.cpp index 7657072..d3d2a91 100644 --- a/Things/TouchSensor.cpp +++ b/Things/TouchSensor.cpp @@ -15,7 +15,8 @@ namespace RoboidControl { TouchSensor::TouchSensor(Participant* owner) : Thing(owner, Type::TouchSensor) {} -TouchSensor::TouchSensor(Thing* parent) : Thing(parent, Type::TouchSensor) {} +// TouchSensor::TouchSensor(Thing* parent) : Thing(parent, Type::TouchSensor) {} +TouchSensor::TouchSensor(Thing& parent) : Thing(Type::TouchSensor, parent) {} int TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) { bytes[(*ix)++] = touchedSomething ? 1 : 0; diff --git a/Things/TouchSensor.h b/Things/TouchSensor.h index e857f90..aca28a4 100644 --- a/Things/TouchSensor.h +++ b/Things/TouchSensor.h @@ -14,12 +14,13 @@ class TouchSensor : public Thing { /// @param owner The owning participant /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID - TouchSensor(Participant* owner = nullptr); //, unsigned char thingId = 0); + TouchSensor(Participant* owner); //, unsigned char thingId = 0); /// @brief Create a new child touch sensor /// @param parent The parent thing /// @param thingId The ID of the thing, leave out or set to zero to generate /// an ID - TouchSensor(Thing* parent); //, unsigned char thingId = 0); + // TouchSensor(Thing* parent); //, unsigned char thingId = 0); + TouchSensor(Thing& parent = Thing::Root); /// @brief Value which is true when the sensor is touching something, false /// otherwise diff --git a/examples/BB2B.cpp b/examples/BB2B.cpp index 1dad561..a07aa9f 100644 --- a/examples/BB2B.cpp +++ b/examples/BB2B.cpp @@ -17,26 +17,26 @@ using namespace RoboidControl; int main() { // The robot's propulsion is a differential drive - DifferentialDrive* bb2b = new DifferentialDrive(); + DifferentialDrive bb2b = DifferentialDrive(); // Is has a touch sensor at the front left of the roboid - TouchSensor* touchLeft = new TouchSensor(bb2b); + TouchSensor touchLeft = TouchSensor(bb2b); // and other one on the right - TouchSensor* touchRight = new TouchSensor(bb2b); + TouchSensor touchRight = TouchSensor(bb2b); // Do forever: while (true) { // The left wheel turns forward when nothing is touched on the right side // and turn backward when the roboid hits something on the right - float leftWheelSpeed = (touchRight->touchedSomething) ? -600.0f : 600.0f; + float leftWheelSpeed = (touchRight.touchedSomething) ? -600.0f : 600.0f; // The right wheel does the same, but instead is controlled by // touches on the left side - float rightWheelSpeed = (touchLeft->touchedSomething) ? -600.0f : 600.0f; + float rightWheelSpeed = (touchLeft.touchedSomething) ? -600.0f : 600.0f; // When both sides are touching something, both wheels will turn backward // and the roboid will move backwards - bb2b->SetWheelVelocity(leftWheelSpeed, rightWheelSpeed); + bb2b.SetWheelVelocity(leftWheelSpeed, rightWheelSpeed); // Update the roboid state - bb2b->Update(true); + bb2b.Update(true); // and sleep for 100ms #if defined(ARDUINO) diff --git a/test/participant_test.cc b/test/participant_test.cc index 42c686b..0b4e147 100644 --- a/test/participant_test.cc +++ b/test/participant_test.cc @@ -7,6 +7,9 @@ #include "Participants/SiteServer.h" #include "Thing.h" +#include +#include + using namespace RoboidControl; TEST(Participant, Participant) { @@ -15,7 +18,7 @@ TEST(Participant, Participant) { unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 7000) { - participant->Update(milliseconds); + participant->Update(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); milliseconds = Thing::GetTimeMs(); @@ -29,7 +32,7 @@ TEST(Participant, SiteServer) { unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 7000) { - siteServer->Update(milliseconds); + siteServer->Update(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); milliseconds = Thing::GetTimeMs(); @@ -44,8 +47,8 @@ TEST(Participant, SiteParticipant) { unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 7000) { - siteServer->Update(milliseconds); - participant->Update(milliseconds); + siteServer->Update(); + participant->Update(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); milliseconds = Thing::GetTimeMs(); @@ -63,8 +66,8 @@ TEST(Participant, ThingMsg) { unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 7000) { - siteServer->Update(milliseconds); - participant->Update(milliseconds); + siteServer->Update(); + participant->Update(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); milliseconds = Thing::GetTimeMs(); diff --git a/test/thing_test.cc b/test/thing_test.cc index b8ceea1..74ff48c 100644 --- a/test/thing_test.cc +++ b/test/thing_test.cc @@ -15,7 +15,7 @@ TEST(RoboidControlSuite, HiddenParticipant) { unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 1000) { - Thing::UpdateThings(milliseconds); + Thing::UpdateThings(); milliseconds = Thing::GetTimeMs(); } @@ -29,7 +29,7 @@ TEST(RoboidControlSuite, IsolatedParticipant) { unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 1000) { - participant->Update(milliseconds); + participant->Update(); milliseconds = Thing::GetTimeMs(); }