Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Schniz/robotikka. Lee Ve Tom Ve Ani Doin our Robottttt
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344#include "WaypointsManager.h"
namespace Managers {
WaypointsManager::WaypointsManager(Robot* robot, vector<Waypoint> waypoints, float radius) : m_Radius(radius), m_Robot(robot) {
for (int i = 0; i < waypoints.size(); i++) { m_WaypointsQueue.push(waypoints[i]); }
m_CurrWaypoint = NULL;}
WaypointsManager::~WaypointsManager() { delete m_CurrWaypoint; m_CurrWaypoint = NULL;
delete m_Robot; m_Robot = NULL;}
Waypoint WaypointsManager::update(Location newRobotLoc) { if (m_CurrWaypoint == NULL || shouldMoveNext(newRobotLoc)) { m_CurrWaypoint = &m_WaypointsQueue.front(); m_WaypointsQueue.pop(); }
return *m_CurrWaypoint;
// TODO Calculate where the robot is currently, and what speed and yawSpeed it needs to get to the next Waypoint. // TODO Use the RobotManager to move it?}
bool WaypointsManager::shouldMoveNext(Location newRobotLoc) { return MathUtil::equals(newRobotLoc.getX(), m_CurrWaypoint->getX(), m_Radius) && MathUtil::equals(newRobotLoc.getY(), m_CurrWaypoint->getY(), m_Radius);}}