Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTXSAC-356 #16

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion C++/RTTrP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ RTTrPM::RTTrPM()
this->eulerMod = NULL;
this->cavMod = NULL;
this->lavMod = NULL;
this->zoneMod = NULL;
this->zoneSubMod = NULL;
}

RTTrPM::~RTTrPM()
Expand All @@ -100,6 +102,7 @@ RTTrPM::~RTTrPM()
delete(this->quatMod);
delete(this->eulerMod);
delete(this->cavMod);
delete(this->zoneMod);

if (this->ledMod != NULL)
{
Expand Down Expand Up @@ -138,6 +141,25 @@ RTTrPM::~RTTrPM()
}
else
delete(this->lavMod);

if (this->zoneSubMod != NULL)
{
if (this->zoneSubMod->size() > 0)
{
vector<ZoneSubMod*>::iterator zoneSubIter;

for (zoneSubIter = this->zoneSubMod->begin(); zoneSubIter < this->zoneSubMod->end(); zoneSubIter++)
{
delete((*zoneSubIter));
}

delete(this->zoneSubMod);
}
else
delete(this->zoneSubMod);
}
else
delete(this->zoneSubMod);
}

void RTTrPM::printPacket(void)
Expand All @@ -162,6 +184,12 @@ void RTTrPM::printPacket(void)

if (this->lavMod != NULL)
print_vector(this->lavMod);

if (this->zoneMod != NULL)
this->zoneMod->printModule();

if (this->zoneSubMod != NULL)
print_vector(this->zoneSubMod);
}

RTTrPL::RTTrPL()
Expand Down Expand Up @@ -197,4 +225,4 @@ void RTTrPL::printModule()
print_vector((*spotIt)->chanBlocks);
}
}
}
}
4 changes: 3 additions & 1 deletion C++/RTTrP.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class RTTrPM
QuatModule *quatMod;
EulerModule *eulerMod;
CentroidAccVelMod *cavMod;
ZoneMod *zoneMod;
vector<LEDAccVelMod*> *lavMod;
vector<ZoneSubMod*> *zoneSubMod;
vector<unsigned char> *data;
vector<uint8_t> pkType;

Expand All @@ -69,4 +71,4 @@ class RTTrPL
void printModule(void);
};

#endif // RTTRP_H
#endif // RTTRP_H
112 changes: 110 additions & 2 deletions C++/thirdParty_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ QuatModule::QuatModule(vector<unsigned char> *data, uint16_t intSig, uint16_t fl
data->erase(data->begin(), data->begin() + 8);
}

if (this->intSig = 0x4154)
if (this->intSig == 0x4154)
{
this->size = ntohs(this->size);
this->latency = ntohs(this->latency);
Expand Down Expand Up @@ -694,4 +694,112 @@ void LEDAccVelMod::printModule()
cout << "Y Acceleration: " << this->accy << endl;
cout << "Z Acceleration: " << this->accz << endl;
cout << "========LED Acceleration/Velocity Module========" << endl;
}
}

ZoneMod::ZoneMod()
{

}

void ZoneMod::ZoneMod(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig)
{
copy(data->begin(), data->begin() + 2, (unsigned char *)&this->size);
data->erase(data->begin(), data->begin() + 2);
copy(data->begin(), data->begin() + 1, (unsigned char*)&this->numofZoneSubModules);
data->erase(data->begin(), data->begin() + 1);

if (this->intSig == 0x4154)
{
this->size = ntohs(this->size);
this->numofZoneSubModules = ntohs(this->numofZoneSubModules);
}
}

ZoneMod::ZoneMod(const ZoneMod &toCopy)
{
size = toCopy.size;
numofZoneSubModules = toCopy.numofZoneSubModules;
}

ZoneMod::~ZoneMod()
{

}

void ZoneMod::printModule()
{
cout << "========Colliding Zones Module ========" << endl;

cout << "Module Size: " << this->size << endl;
cout << "Number of Zones colliding with the trackable " << this->numofZoneSubModules << endl;

cout << "========Colliding Zones Module ========" << endl;

}

class ZoneMod : public Packet
{
public:
uint16_t size;
uint8_t numofZoneSubModules;
ZoneMod();
ZoneMod(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
ZoneMod(const ZoneMod &toCopy);
~ZoneMod();

void printModule();
};

ZoneSubMod::ZoneSubMod()
{

}

ZoneSubMod::ZoneSubMod(std::vector<unsigned char> *data, uint16_t intSig)
{
copy(data->begin(), data->begin() + 2, (unsigned char *)&this->size);
data->erase(data->begin(), data->begin() + 2);
copy(data->begin(), data->begin() + 1, (unsigned char*)&this->zoneNameLength);
data->erase(data->begin(), data->begin() + 1);
if (this->intSig == 0x4154)
{
this->size = ntohs(this->size);
this->zoneNameLength = ntohs(this->zoneNameLength);
}
copy(data->begin(), data->begin() + this->zoneNameLength, (unsigned char*)&this->zoneName);
data->erase(data->begin(), data->begin() + this->zoneNameLength);
}

ZoneSubMod::ZoneSubMod(const ZoneSubMod &toCopy)
{
intSig = toCopy.intSig;
size = toCopy.size;
zoneNameLength = toCopy.zoneNameLength;
zoneName = toCopy.zoneName;
}

void ZoneSubMod::printModule()
{
cout << "========Colliding Zones Sub Module ========" << endl;

cout << "Zone Sub Module Size: " << this->size << endl;
cout << "Colliding Zone Name length " << this->zoneNameLength << endl;
cout << "Colliding Zone Name " << this->zoneName << endl;

cout << "========Colliding Zones Module ========" << endl;
}

class ZoneSubMod
{
public:
uint16_t intSig;
uint8_t size;
uint8_t zoneNameLength;
std::string zoneName;
ZoneSubMod();
ZoneSubMod(std::vector<unsigned char> *data, uint16_t intSig);
ZoneSubMod(const ZoneSubMod &toCopy);
~ZoneSubMod();

void printModule();
};
72 changes: 60 additions & 12 deletions C++/thirdParty_motion.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*MIT License

#Copyright(c) 2020 CAST Group of Companies Inc

#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files(the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions :

#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE. */

#ifndef THIRDPARTY_MOTION_H
#define THIRDPARTY_MOTION_H

Expand All @@ -15,16 +37,14 @@

#pragma once

using namespace std;

class Packet
{
public:
uint8_t pkType;
uint16_t intSig, fltSig;

Packet();
Packet(uint16_t intSig, uint16_t fltSig, vector<unsigned char> *data);
Packet(uint16_t intSig, uint16_t fltSig, std::vector<unsigned char> *data);
Packet(const Packet &toCopy);
~Packet();
};
Expand All @@ -34,12 +54,12 @@ class Trackable : public Packet
public:
uint16_t size;
uint8_t nameLen;
string name;
std::string name;
uint8_t numMods;
uint32_t timeStamp;

Trackable();
Trackable(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
Trackable(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
Trackable(const Trackable &toCopy);
~Trackable();

Expand All @@ -53,7 +73,7 @@ class CentroidMod : public Packet
double x, y, z;

CentroidMod();
CentroidMod(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
CentroidMod(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
CentroidMod(const CentroidMod &toCopy);
~CentroidMod();

Expand All @@ -68,7 +88,7 @@ class LEDModule : public Packet
uint8_t index;

LEDModule();
LEDModule(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
LEDModule(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
LEDModule(const LEDModule &toCopy);
~LEDModule();

Expand All @@ -82,7 +102,7 @@ class QuatModule : public Packet
double Qx, Qy, Qz, Qw;

QuatModule();
QuatModule(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
QuatModule(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
QuatModule(const QuatModule &toCopy);
~QuatModule();

Expand All @@ -96,7 +116,7 @@ class EulerModule : public Packet
double R1, R2, R3;

EulerModule();
EulerModule(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
EulerModule(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
EulerModule(const EulerModule &toCopy);
~EulerModule();

Expand All @@ -112,7 +132,7 @@ class CentroidAccVelMod : public Packet
float velx, vely, velz;

CentroidAccVelMod();
CentroidAccVelMod(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
CentroidAccVelMod(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
CentroidAccVelMod(const CentroidAccVelMod &toCopy);
~CentroidAccVelMod();

Expand All @@ -129,11 +149,39 @@ class LEDAccVelMod : public Packet
uint8_t index;

LEDAccVelMod();
LEDAccVelMod(vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
LEDAccVelMod(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
LEDAccVelMod(const LEDAccVelMod &toCopy);
~LEDAccVelMod();

void printModule();
};

#endif
class ZoneMod : public Packet
{
public:
uint16_t size;
uint8_t numofZoneSubModules;
ZoneMod();
ZoneMod(std::vector<unsigned char> *data, uint16_t intSig, uint16_t fltSig);
ZoneMod(const ZoneMod &toCopy);
~ZoneMod();

void printModule();
};

class ZoneSubMod
{
public:
uint16_t intSig;
uint8_t size;
uint8_t zoneNameLength;
std::string zoneName;
ZoneSubMod();
ZoneSubMod(std::vector<unsigned char> *data, uint16_t intSig);
ZoneSubMod(const ZoneSubMod &toCopy);
~ZoneSubMod();

void printModule();
};

#endif
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 CAST Group of Companies Inc
Copyright (c) 2020 CAST Group of Companies Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 23 additions & 0 deletions Python/RTTrP.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# MIT License

#Copyright(c) 2019 CAST Group of Companies Inc

#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files(the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions :

#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.


import struct

# Main class for the packet header, to keep things simply we just leave this as a generic class
Expand Down
Loading