Pointing.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <VirtualRobot/VirtualRobot.h>
4 
6 #include <RobotAPI/interface/components/TrajectoryPlayerInterface.h>
10 
11 #include "Side.h"
12 
14 {
15  class PointingException : public armarx::LocalException
16  {
17  };
18 
20  {
21  };
22 
24  {
25  };
26 } // namespace armarx::exceptions::local
27 
29 {
30 
31  /**
32  * @brief Implementation of a 'Pointing'-gesture.
33  *
34  * Lets the robot point somewhere by aligning the forearm with the passed target, aligning the
35  * wrist, and setting a hand shape.
36  *
37  * @ingroup Library-pointing
38  */
39  class Pointing : virtual public armarx::Logging
40  {
41  public:
42  struct Remote
43  {
44  std::string robotName;
47  armarx::TrajectoryPlayerInterfacePrx trajectoryPlayer;
48  };
49 
50  struct Parameters
51  {
52  /** Side of the arm to point with. */
54 
55  /** Position to point at. */
57 
58  /** Name of the hand preshape to use. If none is provided, the hand will be ignored. */
59  std::optional<std::string> handShape;
60 
61  /** Maximum velocity */
62  double maxVelocity;
63 
64  /** Maximum acceleration */
66  };
67 
68  public:
69  Pointing(const Remote& remote);
70 
71  /**
72  * @brief Executes the pointing gesture.
73  *
74  * Let's the robot point at the passed target. Blocks unitl the target configuration is
75  * reached or the execution is aborted with @ref abort.
76  *
77  * @param params Parameterization of the pointing gesture.
78  *
79  * @throws armarx::exceptions::local::PointingFailedException Thrown if the pointing gesture
80  * could not be executed.
81  * @throws armarx::exceptions::local::PointingAbortedException Thrown when the execution is
82  * aborted with @ref abort() before reaching the target configuration.
83  */
84  void execute(const Parameters params);
85 
86  /**
87  * @brief Aborts a running execution.
88  */
89  void abort();
90 
91 
92  private:
93  VirtualRobot::RobotPtr getRobot();
94 
95  Eigen::Vector3f toGlobal(const armarx::FramedPosition&, VirtualRobot::RobotPtr);
96 
97  void visualizeTarget(const Eigen::Vector3f& target);
98 
100  computeArmTrajectory(VirtualRobot::RobotPtr robot, Side side, Eigen::Vector3f target);
101 
102  void
103  addWristTrajectory(VirtualRobot::RobotPtr robot, Side side, armarx::TrajectoryPtr traj);
104 
105  std::map<std::string, float>
106  getShapeJointValues(VirtualRobot::RobotPtr robot, Side side, const std::string& shapeName);
107 
108  void addHandTrajectory(VirtualRobot::RobotPtr robot,
110  const std::map<std::string, float>& shapeJointValues);
111 
112  void playTrajectory(armarx::TrajectoryPtr traj);
113 
114  private:
115  Remote remote_;
116  std::atomic_bool aborted;
117  };
118 
119 } // namespace armarx::control::pointing::core
Client.h
armarx::control::pointing::core::Pointing::Pointing
Pointing(const Remote &remote)
Definition: Pointing.cpp:15
armarx::control::pointing::core
Definition: Pointing.cpp:13
armarx::control::pointing::core::Pointing::Parameters
Definition: Pointing.h:50
armarx::control::pointing::core::Pointing::Parameters::maxVelocity
double maxVelocity
Maximum velocity.
Definition: Pointing.h:62
armarx::control::pointing::core::Pointing::execute
void execute(const Parameters params)
Executes the pointing gesture.
Definition: Pointing.cpp:21
armarx::control::pointing::core::Pointing::Remote::memoryNameSystem
armarx::armem::client::MemoryNameSystem memoryNameSystem
Definition: Pointing.h:46
armarx::control::pointing::core::Pointing::Parameters::handShape
std::optional< std::string > handShape
Name of the hand preshape to use.
Definition: Pointing.h:59
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
IceInternal::Handle< Trajectory >
armarx::control::pointing::core::Side
Side
Describes the side of an arm.
Definition: Side.h:10
armarx::exceptions::local
Definition: DynamicLibraryException.h:31
FramedPose.h
armarx::control::pointing::core::Pointing::Parameters::side
Side side
Side of the arm to point with.
Definition: Pointing.h:53
armarx::exceptions::local::PointingException
Definition: Pointing.h:15
armarx::control::pointing::core::Pointing::abort
void abort()
Aborts a running execution.
Definition: Pointing.cpp:53
armarx::FramedPosition
The FramedPosition class.
Definition: FramedPose.h:142
armarx::control::pointing::core::Pointing::Parameters::maxAcceleration
double maxAcceleration
Maximum acceleration.
Definition: Pointing.h:65
armarx::control::pointing::core::Pointing::Parameters::target
armarx::FramedPosition target
Position to point at.
Definition: Pointing.h:56
Trajectory.h
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
armarx::exceptions::local::PointingFailedException
Definition: Pointing.h:19
armarx::control::pointing::core::Pointing::Remote::trajectoryPlayer
armarx::TrajectoryPlayerInterfacePrx trajectoryPlayer
Definition: Pointing.h:47
armarx::exceptions::local::PointingAbortedException
Definition: Pointing.h:23
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::control::pointing::core::Pointing::Remote
Definition: Pointing.h:42
MemoryNameSystem.h
armarx::control::pointing::core::Pointing::Remote::arviz
armarx::viz::Client arviz
Definition: Pointing.h:45
armarx::control::pointing::core::Pointing
Implementation of a 'Pointing'-gesture.
Definition: Pointing.h:39
armarx::viz::Client
Definition: Client.h:109
Side.h
armarx::control::pointing::core::Pointing::Remote::robotName
std::string robotName
Definition: Pointing.h:44
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18