GoalReachedMonitor.cpp
Go to the documentation of this file.
1 #include "GoalReachedMonitor.h"
2 
3 #include <VirtualRobot/Robot.h>
4 
7 
9 {
10 
12  const core::Scene& scene,
13  const GoalReachedMonitorConfig& config) :
14  goal_(goal), scene(scene), config(config), reachedCount(0)
15  {
16  //ARMARX_CHECK(not waypoints.empty());
17  }
18 
19  bool
20  GoalReachedMonitor::goalReached(const bool filter) const noexcept
21  {
22  // return false;
24 
25  const core::Pose world_T_robot(scene.robot->getGlobalPose());
26  const core::Pose& world_T_goal(goal_);
27 
28  const core::Pose robot_T_goal = world_T_robot.inverse() * world_T_goal;
29 
30  ARMARX_VERBOSE << "Position error: " << robot_T_goal.translation().head<2>().norm();
31 
32  const bool posReached = robot_T_goal.translation().head<2>().norm() <= config.posTh;
33  const bool oriReached = Eigen::AngleAxisf(robot_T_goal.linear()).angle() <= config.oriTh;
34 
35  if (posReached)
36  {
37  ARMARX_DEBUG << "Position goal `" << robot_T_goal.translation().head<2>()
38  << "` reached";
39  }
40 
41  if (oriReached)
42  {
43  ARMARX_DEBUG << "Orientation goal reached";
44  }
45 
46  const bool linearVelocityLow = scene.platformVelocity.linear.norm() < config.linearVelTh;
47  const bool angularVelocityLow = scene.platformVelocity.angular.norm() < config.angularVelTh;
48 
49  const bool velocityLow = linearVelocityLow and angularVelocityLow;
50 
51  if (velocityLow)
52  {
53  ARMARX_DEBUG << "Robot has come to rest.";
54  }
55 
56  bool reached = posReached and oriReached and velocityLow;
57 
58  if (reached)
59  {
60  reachedCount++;
61  ARMARX_DEBUG << "Goal reached! reachedCount: " << reachedCount;
62  return !filter || (reachedCount >= config.filterCount);
63  }
64  else
65  {
66  reachedCount = 0;
67  return false;
68  }
69  }
70 
71  const core::Pose&
72  GoalReachedMonitor::goal() const noexcept
73  {
74  return goal_;
75  }
76 
78  goal_{other.goal_}, scene{other.scene}, config(other.config)
79  {
80  }
81 
82  GoalReachedMonitor&
84  {
85  return *this;
86  }
87 } // namespace armarx::navigation::server
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::navigation::server::GoalReachedMonitor::goal
const core::Pose & goal() const noexcept
Definition: GoalReachedMonitor.cpp:72
armarx::navigation::server::GoalReachedMonitor::GoalReachedMonitor
GoalReachedMonitor(const core::Pose &goal, const core::Scene &scene, const GoalReachedMonitorConfig &config)
Definition: GoalReachedMonitor.cpp:11
GoalReachedMonitor.h
armarx::navigation::server
This file is part of ArmarX.
Definition: EventPublishingInterface.h:10
armarx::navigation::server::GoalReachedMonitor
Definition: GoalReachedMonitor.h:45
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::navigation::server::GoalReachedMonitor::goalReached
bool goalReached(bool filter=true) const noexcept
Definition: GoalReachedMonitor.cpp:20
armarx::navigation::server::GoalReachedMonitor::operator=
GoalReachedMonitor & operator=(GoalReachedMonitor &&) noexcept
Definition: GoalReachedMonitor.cpp:83
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::navigation::server::GoalReachedMonitorConfig
Definition: GoalReachedMonitor.h:34
armarx::navigation::core::Scene
Definition: types.h:71
ExpressionException.h
Logging.h
norm
double norm(const Point &a)
Definition: point.hpp:94