PositionControllerHelper.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5 * Karlsruhe Institute of Technology (KIT), all rights reserved.
6 *
7 * ArmarX is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ArmarX is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#pragma once
25
26#include <Eigen/Dense>
27
28#include <VirtualRobot/IK/JacobiProvider.h>
29#include <VirtualRobot/VirtualRobot.h>
30
33
35
36namespace Eigen
37{
39}
40
41namespace armarx
42{
43
45 using PositionControllerHelperPtr = std::shared_ptr<PositionControllerHelper>;
46
48 {
49 public:
50 PositionControllerHelper(const VirtualRobot::RobotNodePtr& tcp,
52 const Eigen::Matrix4f& target);
53 PositionControllerHelper(const VirtualRobot::RobotNodePtr& tcp,
55 const std::vector<Eigen::Matrix4f>& waypoints);
56 PositionControllerHelper(const VirtualRobot::RobotNodePtr& tcp,
58 const std::vector<PosePtr>& waypoints);
59
60 void readConfig(const CartesianPositionControllerConfigBase& config);
61 void readConfig(const CartesianPositionControllerConfigBasePtr& config);
62
63 // read data and write targets, call this if you are unsure, anywhere in your control loop.
64 // use updateRead and updateWrite for better performance
65 void update();
66 // read data, call this after robot sync
67 void updateRead();
68 // write targets, call this at the end of your control loop, before the sleep
69 void updateWrite();
70
71 void setNewWaypoints(const std::vector<Eigen::Matrix4f>& waypoints);
72 void setNewWaypoints(const std::vector<PosePtr>& waypoints);
73 void addWaypoint(const Eigen::Matrix4f& waypoint);
74 void setTarget(const Eigen::Matrix4f& target);
76 void setFeedForwardVelocity(const Eigen::Vector3f& feedForwardVelocityPos,
77 const Eigen::Vector3f& feedForwardVelocityOri);
79 void immediateHardStop(bool clearTargets = true);
80
81 float getPositionError() const;
82
83 float getOrientationError() const;
84
85 bool isCurrentTargetReached() const;
86 bool isCurrentTargetNear() const;
87 bool isFinalTargetReached() const;
88 bool isFinalTargetNear() const;
89
90 bool isLastWaypoint() const;
91
92 const Eigen::Matrix4f& getCurrentTarget() const;
93 const Eigen::Vector3f getCurrentTargetPosition() const;
94
95 size_t skipToClosestWaypoint(float rad2mmFactor);
96
97 void setNullSpaceControl(bool enabled);
98
99 std::string getStatusText();
100
102 {
106
107 int loops = 100;
108 float stepLength = 0.05f;
109 float eps = 0.001;
110 float maxOriErrorIncrease = 1.f / 180 * M_PI;
112 VirtualRobot::IKSolver::CartesianSelection cartesianSelection =
113 VirtualRobot::IKSolver::All;
114 VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod =
115 VirtualRobot::JacobiProvider::eSVD;
116 };
117
118 /**
119 * @brief OptimizeNullspace
120 * @param tcp
121 * @param rns
122 * @param target target pose in root frame of the robot
123 * @param args
124 * @return
125 */
126 static bool
127 OptimizeNullspace(const VirtualRobot::RobotNodePtr& tcp,
128 const VirtualRobot::RobotNodeSetPtr& rns,
129 const Eigen::Matrix4f& target,
131
134
135 std::vector<Eigen::Matrix4f> waypoints;
137
142 Eigen::Vector6f feedForwardVelocity = Eigen::Vector6f::Zero();
144 };
145} // namespace armarx
#define M_PI
Definition MathTools.h:17
CartesianPositionController posController
void readConfig(const CartesianPositionControllerConfigBase &config)
static bool OptimizeNullspace(const VirtualRobot::RobotNodePtr &tcp, const VirtualRobot::RobotNodeSetPtr &rns, const Eigen::Matrix4f &target, const NullspaceOptimizationArgs &args=NullspaceOptimizationArgs())
OptimizeNullspace.
std::vector< Eigen::Matrix4f > waypoints
const Eigen::Matrix4f & getCurrentTarget() const
VelocityControllerHelperPtr velocityControllerHelper
size_t skipToClosestWaypoint(float rad2mmFactor)
void immediateHardStop(bool clearTargets=true)
void setTarget(const Eigen::Matrix4f &target)
const Eigen::Vector3f getCurrentTargetPosition() const
PositionControllerHelper(const VirtualRobot::RobotNodePtr &tcp, const VelocityControllerHelperPtr &velocityControllerHelper, const Eigen::Matrix4f &target)
void setNewWaypoints(const std::vector< Eigen::Matrix4f > &waypoints)
void setFeedForwardVelocity(const Eigen::Vector6f &feedForwardVelocity)
void addWaypoint(const Eigen::Matrix4f &waypoint)
Matrix< float, 6, 1 > Vector6f
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< VelocityControllerHelper > VelocityControllerHelperPtr
std::shared_ptr< PositionControllerHelper > PositionControllerHelperPtr
VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod