libfranka  0.14.1
FCI C++ API
active_control.h
Go to the documentation of this file.
1 // Copyright (c) 2023 Franka Robotics GmbH
2 // Use of this source code is governed by the Apache-2.0 license, see LICENSE
3 #pragma once
4 
6 #include <franka/exception.h>
7 
8 #include "robot.h"
9 
16 namespace franka {
17 
22  public:
23  ~ActiveControl() override;
24 
25  std::pair<RobotState, Duration> readOnce() override;
26 
27  void writeOnce(const Torques& /* control_input */) override {
28  throw franka::ControlException(wrong_write_once_method_called);
29  };
30 
31  void writeOnce(const JointPositions& /* motion_generator_input */,
32  const std::optional<const Torques>& /*control_input*/) override {
33  throw franka::ControlException(wrong_write_once_method_called);
34  };
35 
36  void writeOnce(const JointVelocities& /* motion_generator_input */,
37  const std::optional<const Torques>& /* control_input */) override {
38  throw franka::ControlException(wrong_write_once_method_called);
39  };
40 
41  void writeOnce(const CartesianPose& /* motion_generator_input */,
42  const std::optional<const Torques>& /* control_input */) override {
43  throw franka::ControlException(wrong_write_once_method_called);
44  };
45 
46  void writeOnce(const CartesianVelocities& /* motion_generator_input */,
47  const std::optional<const Torques>& /* control_input */) override {
48  throw franka::ControlException(wrong_write_once_method_called);
49  };
50 
51  void writeOnce(const JointPositions& motion_generator_input) override {
52  writeOnce(motion_generator_input, std::optional<const Torques>());
53  };
54 
55  void writeOnce(const JointVelocities& motion_generator_input) override {
56  writeOnce(motion_generator_input, std::optional<const Torques>());
57  };
58 
59  void writeOnce(const CartesianPose& motion_generator_input) override {
60  writeOnce(motion_generator_input, std::optional<const Torques>());
61  };
62 
63  void writeOnce(const CartesianVelocities& motion_generator_input) override {
64  writeOnce(motion_generator_input, std::optional<const Torques>());
65  };
66 
67  protected:
76  ActiveControl(std::shared_ptr<Robot::Impl> robot_impl,
77  uint32_t motion_id,
78  std::unique_lock<std::mutex> control_lock);
79 
81  std::shared_ptr<Robot::Impl> robot_impl;
82 
84  uint32_t motion_id;
85 
87  std::unique_lock<std::mutex> control_lock;
88 
91 
93  std::optional<Duration> last_read_access;
94 
95  private:
96  const std::string wrong_write_once_method_called{
97  "Wrong writeOnce method called for currently active control!"};
98 };
99 
100 } // namespace franka
Abstract interface class as the base of the active controllers.
Allows the user to read the state of a Robot and to send new control commands after starting a contro...
Definition: active_control_base.h:27
Documented in ActiveControlBase.
Definition: active_control.h:21
uint32_t motion_id
motion id of running motion
Definition: active_control.h:84
void writeOnce(const CartesianVelocities &, const std::optional< const Torques > &) override
Updates the cartesian velocity and torque commands of an active control.
Definition: active_control.h:46
std::optional< Duration > last_read_access
duration to last read access
Definition: active_control.h:93
void writeOnce(const JointVelocities &, const std::optional< const Torques > &) override
Updates the joint velocity and torque commands of an active control.
Definition: active_control.h:36
ActiveControl(std::shared_ptr< Robot::Impl > robot_impl, uint32_t motion_id, std::unique_lock< std::mutex > control_lock)
Construct a new ActiveControl object.
void writeOnce(const CartesianPose &, const std::optional< const Torques > &) override
Updates the cartesian position and torque commands of an active control.
Definition: active_control.h:41
std::pair< RobotState, Duration > readOnce() override
Waits for a robot state update and returns it.
void writeOnce(const CartesianPose &motion_generator_input) override
Updates the cartesian pose commands of an active control, with internal controller.
Definition: active_control.h:59
void writeOnce(const JointPositions &, const std::optional< const Torques > &) override
Updates the joint position and torque commands of an active control.
Definition: active_control.h:31
void writeOnce(const JointVelocities &motion_generator_input) override
Updates the joint velocity commands of an active control, with internal controller.
Definition: active_control.h:55
void writeOnce(const JointPositions &motion_generator_input) override
Updates the joint position commands of an active control, with internal controller.
Definition: active_control.h:51
void writeOnce(const Torques &) override
Updates torque commands of an active control.
Definition: active_control.h:27
std::shared_ptr< Robot::Impl > robot_impl
shared pointer to Robot::Impl instance for read and write accesses
Definition: active_control.h:81
void writeOnce(const CartesianVelocities &motion_generator_input) override
Updates the cartesian velocity commands of an active control, with internal controller.
Definition: active_control.h:63
std::unique_lock< std::mutex > control_lock
control-lock preventing parallel control processes
Definition: active_control.h:87
bool control_finished
flag indicating if control process is finished
Definition: active_control.h:90
Stores values for Cartesian pose motion generation.
Definition: control_types.h:127
Stores values for Cartesian velocity motion generation.
Definition: control_types.h:211
Stores values for joint position motion generation.
Definition: control_types.h:72
Stores values for joint velocity motion generation.
Definition: control_types.h:99
Stores joint-level torque commands without gravity and friction.
Definition: control_types.h:45
Contains exception definitions.
Contains the franka::Robot type.
ControlException is thrown if an error occurs during motion generation or torque control.
Definition: exception.h:73