ESP32 ant following trail

This commit is contained in:
Pascal Serrarens 2025-02-27 11:20:13 +01:00
parent 6cfa481548
commit c7650f1be1
3 changed files with 15 additions and 8 deletions

View File

@ -120,20 +120,23 @@ RemoteParticipant* Participant::AddParticipant(const char* ipAddress, int port)
#pragma region Send #pragma region Send
void Participant::SendThingInfo(RemoteParticipant* owner, Thing* thing) { void Participant::SendThingInfo(RemoteParticipant* remoteParticipant, Thing* thing) {
std::cout << "Send thing info " << (int)thing->id << " \n"; std::cout << "Send thing info " << (int)thing->id << " \n";
ThingMsg* thingMsg = new ThingMsg(this->networkId, thing); ThingMsg* thingMsg = new ThingMsg(this->networkId, thing);
this->Send(owner, thingMsg); this->Send(remoteParticipant, thingMsg);
delete thingMsg; delete thingMsg;
NameMsg* nameMsg = new NameMsg(this->networkId, thing); NameMsg* nameMsg = new NameMsg(this->networkId, thing);
this->Send(owner, nameMsg); this->Send(remoteParticipant, nameMsg);
delete nameMsg; delete nameMsg;
ModelUrlMsg* modelMsg = new ModelUrlMsg(this->networkId, thing); ModelUrlMsg* modelMsg = new ModelUrlMsg(this->networkId, thing);
this->Send(owner, modelMsg); this->Send(remoteParticipant, modelMsg);
delete modelMsg; delete modelMsg;
PoseMsg* poseMsg = new PoseMsg(this->networkId, thing, true); PoseMsg* poseMsg = new PoseMsg(this->networkId, thing, true);
this->Send(owner, poseMsg); this->Send(remoteParticipant, poseMsg);
delete poseMsg; delete poseMsg;
BinaryMsg* customMsg = new BinaryMsg(this->networkId, thing);
this->Send(remoteParticipant, customMsg);
delete customMsg;
} }
bool Participant::Send(RemoteParticipant* remoteParticipant, IMessage* msg) { bool Participant::Send(RemoteParticipant* remoteParticipant, IMessage* msg) {
@ -166,6 +169,9 @@ void Participant::PublishThingInfo(Thing* thing) {
ModelUrlMsg* modelMsg = new ModelUrlMsg(this->networkId, thing); ModelUrlMsg* modelMsg = new ModelUrlMsg(this->networkId, thing);
this->Publish(modelMsg); this->Publish(modelMsg);
delete modelMsg; delete modelMsg;
PoseMsg* poseMsg = new PoseMsg(this->networkId, thing, true);
this->Publish(poseMsg);
delete poseMsg;
BinaryMsg* customMsg = new BinaryMsg(this->networkId, thing); BinaryMsg* customMsg = new BinaryMsg(this->networkId, thing);
this->Publish(customMsg); this->Publish(customMsg);
delete customMsg; delete customMsg;

View File

@ -4,9 +4,9 @@
#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/SiteMsg.h"
#include "Messages/ParticipantMsg.h" #include "Messages/ParticipantMsg.h"
#include "Messages/PoseMsg.h" #include "Messages/PoseMsg.h"
#include "Messages/SiteMsg.h"
#include "Messages/ThingMsg.h" #include "Messages/ThingMsg.h"
#include "RemoteParticipant.h" #include "RemoteParticipant.h"
@ -33,7 +33,7 @@ class Participant : public RemoteParticipant {
const char* name = "Participant"; const char* name = "Participant";
//int localPort = 0; // int localPort = 0;
RemoteParticipant* site = nullptr; RemoteParticipant* site = nullptr;
#if defined(ARDUINO) #if defined(ARDUINO)
@ -72,9 +72,9 @@ class Participant : public RemoteParticipant {
void ReceiveData(unsigned char bufferSize, char* senderIpAddress, unsigned int senderPort); void ReceiveData(unsigned char bufferSize, char* senderIpAddress, unsigned int senderPort);
void ReceiveData(unsigned char bufferSize, RemoteParticipant* remoteParticipant); void ReceiveData(unsigned char bufferSize, RemoteParticipant* remoteParticipant);
protected:
std::list<RemoteParticipant*> senders; std::list<RemoteParticipant*> senders;
protected:
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);

View File

@ -13,6 +13,7 @@ TouchSensor::TouchSensor(RemoteParticipant* participant) : Thing(participant) {
// } // }
void TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) {} void TouchSensor::GenerateBinary(char* bytes, unsigned char* ix) {}
void TouchSensor::ProcessBinary(char* bytes) { void TouchSensor::ProcessBinary(char* bytes) {
this->touchedSomething = (bytes[0] == 1); this->touchedSomething = (bytes[0] == 1);
// if (this->touchedSomething) // if (this->touchedSomething)