28 #include <SimoxUtility/math.h>
29 #include <VirtualRobot/Nodes/RobotNode.h>
32 armarx::PlatformUnitInterfacePrx platform_unit,
40 armarx::PlatformUnitInterfacePrx platform_unit,
43 m_platform_unit{platform_unit}, m_robot{robot}, m_cfg{cfg}
50 m_platform_unit->stopPlatform();
55 const float target_ori)
57 setTarget(
Target{target_pos, target_ori});
64 m_waypoints.push_back(
target);
65 m_current_waypoint_index = 0;
66 m_waypoint_changed =
true;
72 return m_waypoints.at(m_current_waypoint_index);
79 if (isCurrentTargetNear() and not isLastWaypoint())
81 m_current_waypoint_index++;
82 m_waypoint_changed =
true;
88 if (m_waypoint_changed)
94 const float pos_thresh = m_cfg.pos_reached_threshold;
95 const float ori_thresh = m_cfg.ori_reached_threshold;
99 m_platform_unit->moveTo(
target.pos.x(),
target.pos.y(),
target.ori, pos_thresh, ori_thresh);
101 m_waypoint_changed =
false;
109 addWaypoint(
Target{waypoint_pos, waypoint_ori});
115 m_waypoints = waypoints;
116 m_current_waypoint_index = 0;
117 m_waypoint_changed =
true;
123 m_waypoints.push_back(waypoint);
129 return m_current_waypoint_index + 1 >= m_waypoints.size();
135 return getPositionError() < m_cfg.pos_near_threshold and
136 getOrientationError() < m_cfg.ori_near_threshold;
142 return getPositionError() < m_cfg.pos_reached_threshold and
143 getOrientationError() < m_cfg.ori_reached_threshold;
149 return isLastWaypoint() and isCurrentTargetNear();
155 return isLastWaypoint() and isCurrentTargetReached();
161 m_platform_unit->setMaxVelocities(max_vel, max_angular_vel);
167 const Eigen::Vector2f agent_pos = m_robot->getGlobalPosition().head<2>();
168 return (getCurrentTarget().pos - agent_pos).
norm();
174 using namespace simox::math;
176 const float agent_ori =
177 periodic_clamp<float>(mat4f_to_rpy(m_robot->getGlobalPose()).z(), -
M_PI,
M_PI);
178 return std::fabs(periodic_clamp<float>(getCurrentTarget().ori - agent_ori, -
M_PI,
M_PI));