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/VirtualRobot.h>
32
33// RobotAPI
35
36namespace armarx
37{
38
40 {
41
42 public:
43 struct Config
44 {
45 float pos_reached_threshold = 10; // [mm]
46 float ori_reached_threshold = 0.1; // [rad]
47 float pos_near_threshold = 50; // [mm]
48 float ori_near_threshold = 0.2; // [rad]
49 };
50
51 struct Target
52 {
53 Eigen::Vector2f pos;
54 float ori;
55 };
56
57 public:
58 ObstacleAvoidingPlatformUnitHelper(armarx::PlatformUnitInterfacePrx platform_unit,
60
61 ObstacleAvoidingPlatformUnitHelper(armarx::PlatformUnitInterfacePrx platform_unit,
63 const Config& cfg);
64
66
67 void setTarget(const Eigen::Vector2f& target_pos, float target_ori);
68
69 void setTarget(const Target& target);
70
72
73 void update();
74
75 void setWaypoints(const std::vector<Target>& waypoints);
76
77 void addWaypoint(const Eigen::Vector2f& waypoint_pos, float waypoint_ori);
78
79 void addWaypoint(const Target& waypoint);
80
81 bool isLastWaypoint() const;
82
83 bool isCurrentTargetNear() const;
84
85 bool isCurrentTargetReached() const;
86
87 bool isFinalTargetNear() const;
88
89 bool isFinalTargetReached() const;
90
91 void setMaxVelocities(float max_vel, float max_angular_vel);
92
93 float getPositionError() const;
94
95 float getOrientationError() const;
96
97 private:
98 armarx::PlatformUnitInterfacePrx m_platform_unit;
99
101
102 std::vector<Target> m_waypoints;
103 unsigned int m_current_waypoint_index = 0;
104 bool m_waypoint_changed = false;
105
106 Config m_cfg;
107 };
108
109} // namespace armarx
void setTarget(const Eigen::Vector2f &target_pos, float target_ori)
void setMaxVelocities(float max_vel, float max_angular_vel)
ObstacleAvoidingPlatformUnitHelper(armarx::PlatformUnitInterfacePrx platform_unit, VirtualRobot::RobotPtr robot)
void setWaypoints(const std::vector< Target > &waypoints)
void addWaypoint(const Eigen::Vector2f &waypoint_pos, float waypoint_ori)
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.