CartesianWaypointController.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 Raphael Grimm (raphael dot grimm 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 <memory>
27 
28 #include <Eigen/Dense>
29 
30 #include <VirtualRobot/Robot.h>
31 
34 #include <RobotAPI/interface/core/CartesianWaypointControllerConfig.h>
35 
37 
38 namespace Eigen
39 {
41 }
42 
43 
44 namespace armarx
45 {
46  class CartesianWaypointController;
47  using CartesianWaypointControllerPtr = std::shared_ptr<CartesianWaypointController>;
48 
50  {
51  public:
52  CartesianWaypointController(const VirtualRobot::RobotNodeSetPtr& rns,
53  const Eigen::VectorXf& currentJointVelocity,
54  float maxPositionAcceleration,
55  float maxOrientationAcceleration,
56  float maxNullspaceAcceleration,
57  const VirtualRobot::RobotNodePtr& tcp = nullptr,
58  const VirtualRobot::RobotNodePtr& referenceFrame = nullptr
59  );
60 
61 
62  [[deprecated("compued null space velocity does not match pseudo inverse svd method in simox. never use this function.")]]
63  void setCurrentJointVelocity(const Eigen::Ref<const Eigen::VectorXf>& currentJointVelocity);
64 
65  const Eigen::VectorXf& calculate(float dt);
66 
67  void setWaypoints(const std::vector<Eigen::Matrix4f>& waypoints);
68  void swapWaypoints(std::vector<Eigen::Matrix4f>& waypoints);
69  void addWaypoint(const Eigen::Matrix4f& waypoint);
70  void setTarget(const Eigen::Matrix4f& target);
72  void setFeedForwardVelocity(const Eigen::Vector3f& feedForwardVelocityPos, const Eigen::Vector3f& feedForwardVelocityOri);
74 
75  float getPositionError() const;
76 
77  float getOrientationError() const;
78 
79  bool isCurrentTargetReached() const;
80  bool isCurrentTargetNear() const;
81  bool isFinalTargetReached() const;
82  bool isFinalTargetNear() const;
83 
84  bool isLastWaypoint() const;
85 
86  const Eigen::Matrix4f& getCurrentTarget() const;
87  const Eigen::Vector3f getCurrentTargetPosition() const;
88 
89  size_t skipToClosestWaypoint(float rad2mmFactor);
90 
91  void setNullSpaceControl(bool enabled);
92 
93  std::string getStatusText();
94 
95  void setConfig(const CartesianWaypointControllerConfig& cfg);
96 
99 
100  std::vector<Eigen::Matrix4f> waypoints;
101  size_t currentWaypointIndex = 0.f;
102 
107 
108  Eigen::Vector6f feedForwardVelocity = Eigen::Vector6f::Zero();
109  Eigen::Vector6f cartesianVelocity = Eigen::Vector6f::Zero();
110  bool autoClearFeedForward = true;
111 
112 
116 
117  private:
118  Eigen::VectorXf _out;
119  Eigen::VectorXf _jnv;
120  };
121 }
Eigen
Definition: Elements.h:36
armarx::CartesianWaypointController::getOrientationError
float getOrientationError() const
Definition: CartesianWaypointController.cpp:151
armarx::CartesianWaypointController::thresholdOrientationReached
float thresholdOrientationReached
Definition: CartesianWaypointController.h:104
armarx::CartesianWaypointController::waypoints
std::vector< Eigen::Matrix4f > waypoints
Definition: CartesianWaypointController.h:100
armarx::CartesianWaypointController::setNullSpaceControl
void setNullSpaceControl(bool enabled)
Definition: CartesianWaypointController.cpp:212
armarx::CartesianWaypointController::isCurrentTargetNear
bool isCurrentTargetNear() const
Definition: CartesianWaypointController.cpp:161
armarx::CartesianWaypointController::setCurrentJointVelocity
void setCurrentJointVelocity(const Eigen::Ref< const Eigen::VectorXf > &currentJointVelocity)
Definition: CartesianWaypointController.cpp:246
Pose.h
armarx::CartesianWaypointController::getCurrentTargetPosition
const Eigen::Vector3f getCurrentTargetPosition() const
Definition: CartesianWaypointController.cpp:186
armarx::CartesianWaypointController::ctrlCartesianPos2Vel
CartesianPositionController ctrlCartesianPos2Vel
Definition: CartesianWaypointController.h:98
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
armarx::CartesianWaypointController::nullSpaceControlEnabled
bool nullSpaceControlEnabled
Definition: CartesianWaypointController.h:113
armarx::CartesianWaypointController::skipToClosestWaypoint
size_t skipToClosestWaypoint(float rad2mmFactor)
Definition: CartesianWaypointController.cpp:192
armarx::CartesianWaypointController::isLastWaypoint
bool isLastWaypoint() const
Definition: CartesianWaypointController.cpp:176
armarx::CartesianWaypointController::getPositionError
float getPositionError() const
Definition: CartesianWaypointController.cpp:146
armarx::CartesianWaypointController::clearFeedForwardVelocity
void clearFeedForwardVelocity()
Definition: CartesianWaypointController.cpp:141
armarx::CartesianWaypointController::swapWaypoints
void swapWaypoints(std::vector< Eigen::Matrix4f > &waypoints)
Definition: CartesianWaypointController.cpp:112
CartesianVelocityControllerWithRamp.h
armarx::CartesianWaypointController::setFeedForwardVelocity
void setFeedForwardVelocity(const Eigen::Vector6f &feedForwardVelocity)
Definition: CartesianWaypointController.cpp:130
armarx::CartesianWaypointControllerPtr
std::shared_ptr< CartesianWaypointController > CartesianWaypointControllerPtr
Definition: CartesianWaypointController.h:47
armarx::CartesianWaypointController::thresholdPositionNear
float thresholdPositionNear
Definition: CartesianWaypointController.h:105
armarx::CartesianWaypointController::CartesianWaypointController
CartesianWaypointController(const VirtualRobot::RobotNodeSetPtr &rns, const Eigen::VectorXf &currentJointVelocity, float maxPositionAcceleration, float maxOrientationAcceleration, float maxNullspaceAcceleration, const VirtualRobot::RobotNodePtr &tcp=nullptr, const VirtualRobot::RobotNodePtr &referenceFrame=nullptr)
Definition: CartesianWaypointController.cpp:39
armarx::CartesianWaypointController::getCurrentTarget
const Eigen::Matrix4f & getCurrentTarget() const
Definition: CartesianWaypointController.cpp:181
armarx::CartesianWaypointController::isFinalTargetNear
bool isFinalTargetNear() const
Definition: CartesianWaypointController.cpp:171
armarx::CartesianWaypointController::isCurrentTargetReached
bool isCurrentTargetReached() const
Definition: CartesianWaypointController.cpp:156
armarx::CartesianWaypointController::cartesianVelocity
Eigen::Vector6f cartesianVelocity
Definition: CartesianWaypointController.h:109
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
armarx::CartesianWaypointController::calculate
const Eigen::VectorXf & calculate(float dt)
Definition: CartesianWaypointController.cpp:66
Eigen::Vector6f
Matrix< float, 6, 1 > Vector6f
Definition: CartesianNaturalPositionController.h:40
armarx::CartesianWaypointController::currentWaypointIndex
size_t currentWaypointIndex
Definition: CartesianWaypointController.h:101
armarx::CartesianWaypointController::thresholdPositionReached
float thresholdPositionReached
Definition: CartesianWaypointController.h:103
CartesianPositionController.h
armarx::CartesianWaypointController::setWaypoints
void setWaypoints(const std::vector< Eigen::Matrix4f > &waypoints)
Definition: CartesianWaypointController.cpp:106
armarx::CartesianWaypointController::addWaypoint
void addWaypoint(const Eigen::Matrix4f &waypoint)
Definition: CartesianWaypointController.cpp:118
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::CartesianWaypointController::setTarget
void setTarget(const Eigen::Matrix4f &target)
Definition: CartesianWaypointController.cpp:123
armarx::CartesianWaypointController
Definition: CartesianWaypointController.h:49
armarx::CartesianWaypointController::KpJointLimitAvoidance
float KpJointLimitAvoidance
Definition: CartesianWaypointController.h:115
armarx::CartesianWaypointController::jointLimitAvoidanceScale
float jointLimitAvoidanceScale
Definition: CartesianWaypointController.h:114
armarx::CartesianWaypointController::autoClearFeedForward
bool autoClearFeedForward
Definition: CartesianWaypointController.h:110
armarx::CartesianWaypointController::isFinalTargetReached
bool isFinalTargetReached() const
Definition: CartesianWaypointController.cpp:166
armarx::CartesianPositionController
Definition: CartesianPositionController.h:41
armarx::CartesianWaypointController::setConfig
void setConfig(const CartesianWaypointControllerConfig &cfg)
Definition: CartesianWaypointController.cpp:225
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
armarx::CartesianWaypointController::feedForwardVelocity
Eigen::Vector6f feedForwardVelocity
Definition: CartesianWaypointController.h:108
armarx::CartesianVelocityControllerWithRamp
Definition: CartesianVelocityControllerWithRamp.h:42
armarx::CartesianWaypointController::thresholdOrientationNear
float thresholdOrientationNear
Definition: CartesianWaypointController.h:106
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
dt
constexpr T dt
Definition: UnscentedKalmanFilterTest.cpp:42
armarx::CartesianWaypointController::ctrlCartesianVelWithRamps
CartesianVelocityControllerWithRamp ctrlCartesianVelWithRamps
Definition: CartesianWaypointController.h:97
armarx::CartesianWaypointController::getStatusText
std::string getStatusText()
Definition: CartesianWaypointController.cpp:217