Skip to content

Instantly share code, notes, and snippets.

@nelsonlaquet
Created May 9, 2011 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelsonlaquet/963663 to your computer and use it in GitHub Desktop.
Save nelsonlaquet/963663 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
class CanOnlyGuess2
{
private:
int _channelPerNameCount;
std::string _channel;
std::string _prevName;
public:
void CanOnlyGuess()
{
for (auto i = 0; i < numChannels; i++)
{
GetChannel();
ProcessChannel();
}
AddTrackedObject();
}
private:
void GetChannel()
{
_channel = readChannel();
_channel = channel.substr(0, channel.find(" "));
}
void ResetNameCount(int newValue, bool replaceNames = true)
{
_prevName = _channel;
if (replaceNames)
_channelPerNameCount = newValue;
}
void ProcessChannel()
{
if (_channel == "Time")
return;
auto channelNameChanged = _prevName != _channel;
if (_prevName.length() == 0 || !channelNameChanged)
ResetNameCount(_channelPerNameCount++, !channelNameChanged);
else
{
AddTrackedObject();
ResetNameCount(1);
}
}
void AddTrackedObject()
{
if (_channelPerNameCount == 4)
{
ViconTrackedObject m(_prevName, POSITION);
objects.push_back(m);
}
else if (_channelPerNameCount == 6)
{
ViconTrackedObject sdo(_prevName, SIX_DOF);
objects.push_back(sdo);
}
else
throw std::string("Unexpected number of DOF");
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment