Aikido
JointCommandExecutor.hpp
Go to the documentation of this file.
1 #ifndef AIKIDO_CONTROL_JOINTCOMMANDEXECUTOR_HPP_
2 #define AIKIDO_CONTROL_JOINTCOMMANDEXECUTOR_HPP_
3 
4 #include <chrono>
5 #include <future>
6 #include <set>
7 
8 #include <dart/dart.hpp>
9 
12 #include "aikido/control/util.hpp"
13 
14 namespace aikido {
15 namespace control {
16 
20 template <ExecutorType T>
22 {
23 public:
28  const std::vector<dart::dynamics::DegreeOfFreedom*> dofs,
29  const std::set<ExecutorType> otherTypes = std::set<ExecutorType>(),
30  const std::chrono::milliseconds threadRate = defaultThreadRate)
31  : Executor(
32  concatenateTypes(std::set<ExecutorType>{T}, otherTypes),
33  dofs,
34  threadRate)
35  {
36  }
37 
39  {
40  }
41 
48  virtual std::future<int> execute(
49  const std::vector<double>& command,
50  const std::chrono::duration<double>& timeout,
51  const std::chrono::system_clock::time_point& timepoint)
52  = 0;
53 
60  virtual std::future<int> execute(
61  const std::vector<double>& command,
62  const std::chrono::duration<double>& timeout)
63  {
64  return this->execute(command, timeout, std::chrono::system_clock::now());
65  }
66 
67  // Documentation inherited.
68  virtual void step(
69  const std::chrono::system_clock::time_point& timepoint) override = 0;
70 
72  virtual void cancel() = 0;
73 };
74 
75 // Define common executor types
79 
80 } // namespace control
81 } // namespace aikido
82 
83 #endif
aikido::control::JointCommandExecutor
Abstract class for executing a command of a single type on a group of joints.
Definition: JointCommandExecutor.hpp:21
util.hpp
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::control::JointCommandExecutor::step
virtual void step(const std::chrono::system_clock::time_point &timepoint) override=0
Step to a point in time.
aikido::control::JointCommandExecutor::execute
virtual std::future< int > execute(const std::vector< double > &command, const std::chrono::duration< double > &timeout, const std::chrono::system_clock::time_point &timepoint)=0
Execute a Joint Command, setting future upon completion.
aikido::control::concatenateTypes
std::set< ExecutorType > concatenateTypes(std::set< ExecutorType > first, std::set< ExecutorType > second)
Concatenate two sets of ExecutorTypes Useful for initializer-list constructors.
Definition: util.hpp:29
Executor.hpp
pointers.hpp
aikido::control::JointCommandExecutor::JointCommandExecutor
JointCommandExecutor(const std::vector< dart::dynamics::DegreeOfFreedom * > dofs, const std::set< ExecutorType > otherTypes=std::set< ExecutorType >(), const std::chrono::milliseconds threadRate=defaultThreadRate)
Constructor.
Definition: JointCommandExecutor.hpp:27
aikido::control::defaultThreadRate
constexpr std::chrono::milliseconds defaultThreadRate
Default rate for ExecutorThread to call step()
Definition: Executor.hpp:47
aikido::control::ExecutorType
ExecutorType
Type of executor Can be used to determine if 2 executors make conflicting demands of individual degre...
Definition: Executor.hpp:35
aikido::control::JointCommandExecutor::execute
virtual std::future< int > execute(const std::vector< double > &command, const std::chrono::duration< double > &timeout)
Execute a Joint Command, setting future upon completion.
Definition: JointCommandExecutor.hpp:60
aikido::control::JointCommandExecutor::~JointCommandExecutor
virtual ~JointCommandExecutor()
Definition: JointCommandExecutor.hpp:38
aikido::control::JointCommandExecutor::cancel
virtual void cancel()=0
Cancels the current command.
aikido::control::Executor
Abstract class for executing commands on degrees of freedom.
Definition: Executor.hpp:50