ObstacleAvoidingPlatformUnitHelper.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::ArmarXObjects::ObstacleAvoidingPlatformUnit
17  * @author Christian R. G. Dreher <c.dreher@kit.edu>
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 
24 #pragma once
25 
26 
27 // Eigen
28 #include <Eigen/Core>
29 
30 // Simox
31 #include <VirtualRobot/Nodes/RobotNode.h>
32 
33 // RobotAPI
35 
36 
37 namespace armarx
38 {
39 
41  {
42 
43  public:
44 
45  struct Config
46  {
47  float pos_reached_threshold = 10; // [mm]
48  float ori_reached_threshold = 0.1; // [rad]
49  float pos_near_threshold = 50; // [mm]
50  float ori_near_threshold = 0.2; // [rad]
51  };
52 
53  struct Target
54  {
55  Eigen::Vector2f pos;
56  float ori;
57  };
58 
59  public:
60 
62  armarx::PlatformUnitInterfacePrx platform_unit,
64 
66  armarx::PlatformUnitInterfacePrx platform_unit,
68  const Config& cfg);
69 
70  virtual
72 
73  void
74  setTarget(const Eigen::Vector2f& target_pos, float target_ori);
75 
76  void
77  setTarget(const Target& target);
78 
79  Target
80  getCurrentTarget() const;
81 
82  void
83  update();
84 
85  void
86  setWaypoints(const std::vector<Target>& waypoints);
87 
88  void
89  addWaypoint(const Eigen::Vector2f& waypoint_pos, float waypoint_ori);
90 
91  void
92  addWaypoint(const Target& waypoint);
93 
94  bool
96  const;
97 
98  bool
100  const;
101 
102  bool
104  const;
105 
106  bool
108  const;
109 
110  bool
112  const;
113 
114  void
115  setMaxVelocities(float max_vel, float max_angular_vel);
116 
117  float
119  const;
120 
121  float
123  const;
124 
125  private:
126 
127  armarx::PlatformUnitInterfacePrx m_platform_unit;
128 
129  VirtualRobot::RobotPtr m_robot;
130 
131  std::vector<Target> m_waypoints;
132  unsigned int m_current_waypoint_index = 0;
133  bool m_waypoint_changed = false;
134 
135  Config m_cfg;
136 
137  };
138 
139 }
armarx::ObstacleAvoidingPlatformUnitHelper::Config::pos_reached_threshold
float pos_reached_threshold
Definition: ObstacleAvoidingPlatformUnitHelper.h:47
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
ObstacleAvoidingPlatformUnit.h
armarx::ObstacleAvoidingPlatformUnitHelper::setTarget
void setTarget(const Eigen::Vector2f &target_pos, float target_ori)
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:59
armarx::ObstacleAvoidingPlatformUnitHelper::isCurrentTargetReached
bool isCurrentTargetReached() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:156
armarx::ObstacleAvoidingPlatformUnitHelper::setWaypoints
void setWaypoints(const std::vector< Target > &waypoints)
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:124
armarx::ObstacleAvoidingPlatformUnitHelper::isLastWaypoint
bool isLastWaypoint() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:140
armarx::ObstacleAvoidingPlatformUnitHelper::Config
Definition: ObstacleAvoidingPlatformUnitHelper.h:45
armarx::ObstacleAvoidingPlatformUnitHelper::Target::ori
float ori
Definition: ObstacleAvoidingPlatformUnitHelper.h:56
armarx::ObstacleAvoidingPlatformUnitHelper::getOrientationError
float getOrientationError() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:196
armarx::ObstacleAvoidingPlatformUnitHelper::Target
Definition: ObstacleAvoidingPlatformUnitHelper.h:53
armarx::ObstacleAvoidingPlatformUnitHelper::isCurrentTargetNear
bool isCurrentTargetNear() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:148
armarx::ObstacleAvoidingPlatformUnitHelper::Config::ori_near_threshold
float ori_near_threshold
Definition: ObstacleAvoidingPlatformUnitHelper.h:50
armarx::ObstacleAvoidingPlatformUnitHelper::~ObstacleAvoidingPlatformUnitHelper
virtual ~ObstacleAvoidingPlatformUnitHelper()
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:52
armarx::ObstacleAvoidingPlatformUnitHelper::Config::ori_reached_threshold
float ori_reached_threshold
Definition: ObstacleAvoidingPlatformUnitHelper.h:48
armarx::ObstacleAvoidingPlatformUnitHelper
Definition: ObstacleAvoidingPlatformUnitHelper.h:40
armarx::ObstacleAvoidingPlatformUnitHelper::ObstacleAvoidingPlatformUnitHelper
ObstacleAvoidingPlatformUnitHelper(armarx::PlatformUnitInterfacePrx platform_unit, VirtualRobot::RobotPtr robot)
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:31
armarx::ObstacleAvoidingPlatformUnitHelper::isFinalTargetReached
bool isFinalTargetReached() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:172
armarx::ObstacleAvoidingPlatformUnitHelper::isFinalTargetNear
bool isFinalTargetNear() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:164
armarx::ObstacleAvoidingPlatformUnitHelper::getPositionError
float getPositionError() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:187
armarx::ObstacleAvoidingPlatformUnitHelper::addWaypoint
void addWaypoint(const Eigen::Vector2f &waypoint_pos, float waypoint_ori)
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:117
armarx::ObstacleAvoidingPlatformUnitHelper::Config::pos_near_threshold
float pos_near_threshold
Definition: ObstacleAvoidingPlatformUnitHelper.h:49
armarx::ObstacleAvoidingPlatformUnitHelper::Target::pos
Eigen::Vector2f pos
Definition: ObstacleAvoidingPlatformUnitHelper.h:55
armarx::ObstacleAvoidingPlatformUnitHelper::update
void update()
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:86
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ObstacleAvoidingPlatformUnitHelper::getCurrentTarget
Target getCurrentTarget() const
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:78
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::ObstacleAvoidingPlatformUnitHelper::setMaxVelocities
void setMaxVelocities(float max_vel, float max_angular_vel)
Definition: ObstacleAvoidingPlatformUnitHelper.cpp:180