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

Auto snapshot bot #250

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Auto snapshot bot #250

wants to merge 16 commits into from

Conversation

neworderofjamie
Copy link
Collaborator

This needs testing with a calibrated Vicon system but otherwise, I think it's working:

  • Improved the BOB_PACKED macro using some __VA_ARGS__
  • Switched Vicon::UDP::getObjectReference to return a std::unique_ptr to a reference object
  • Switched Vicon::UDP to use std::array<char, 24> to store names - seems a bit nicer but stil requires some nastiness
  • Updated examples to be compatible with Vicon API changes
  • Incorporated Tank PID into snapshot bot

Copy link
Collaborator

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! And I'm sure this code will come in handy...

include/common/macros.h Show resolved Hide resolved
include/robots/control/tank_pid.h Show resolved Hide resolved
name.c_str(),
timeoutDuration);
return std::make_unique<ObjectReference<ObjectDataType>>(
*this, name.c_str(), timeoutDuration);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose an alternative would be leave the return value for getObjectReference() as ObjectReference<...> and just turn into a pointer like so:

myPtr = std::make_unique<ObjectReference<ObjectDataType>>(vicon.getObjectReference(...));

It's not important though

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so would that copy the version on the stack into the heap? I don't quite understand how you can std::make_unique a stack object

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You'd be just invoking the copy/move ctor for ObjectReference

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After having re-reviewed this 11 months later I think an optional might be a better option here.


// Start moving towards it
m_TankPID->moveTo(*m_CurrentTrainingRouteWaypoint);
LOGD << "Moving to waypoint (" << m_CurrentTrainingRouteWaypoint->x() << ", " << m_CurrentTrainingRouteWaypoint->y() << ")";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I overloaded operator<<() for Vector2 so this could be:

LOGD << "Moving to waypoint " << m_CurrentTrainingRouteWaypoint;

LOGI << "Vicon: Found new object: " << data.objectName;
pos = m_ObjectData.emplace(data.objectName, ObjectDataType { data.objectName }).first;
LOGI << "Vicon: Found new object: " << data.objectName.data();
pos = m_ObjectData.emplace(data.objectName, ObjectDataType { data.objectName.data() }).first;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could add a getName() convenience function that returns a const char * just to make it more explicit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants