- 3.0.2 rigid body dynamics module.
JointPositionPIDController.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4  **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include <vector>
9 
10 namespace ct {
11 namespace rbd {
12 
18 template <size_t NJOINTS>
19 class JointPositionPIDController : public ct::core::Controller<2 * NJOINTS, NJOINTS>
20 {
21 public:
22  static const size_t STATE_DIM = 2 * NJOINTS;
23  static const size_t CONTROL_DIM = NJOINTS;
24 
25  typedef std::shared_ptr<JointPositionPIDController<NJOINTS>> Ptr;
27 
28  virtual JointPositionPIDController<NJOINTS>* clone() const override;
29 
31  const Eigen::Matrix<double, NJOINTS, 1>& desiredPosition = Eigen::Matrix<double, NJOINTS, 1>::Zero(),
32  const Eigen::Matrix<double, NJOINTS, 1>& desiredVelocity = Eigen::Matrix<double, NJOINTS, 1>::Zero(),
33  const std::vector<PIDController::parameters_t>& parameters = std::vector<PIDController::parameters_t>(NJOINTS,
34  PIDController::parameters_t()));
35 
36  JointPositionPIDController(const Eigen::Matrix<double, NJOINTS, 1>& desiredPosition,
37  const Eigen::Matrix<double, NJOINTS, 1>& desiredVelocity,
38  const PIDController::parameters_t& parameters);
39 
41 
43  const core::Time& t,
44  core::ControlVector<NJOINTS>& control) override;
45 
46  void setDesiredPosition(const Eigen::Matrix<double, NJOINTS, 1>& desiredPosition);
47 
48  void setDesiredPosition(double desiredPosition, int jointId);
49 
50  void setAllPIDGains(double kp, double ki, double kd);
51 
52  void reset();
53 
54 protected:
55  std::vector<PIDController> jointControllers_;
56 };
57 
58 } // namespace rbd
59 } // namespace ct
virtual JointPositionPIDController< NJOINTS > * clone() const override
Definition: JointPositionPIDController-impl.h:12
A joint position controller using a PID controller for all joints.
Definition: JointPositionPIDController.h:19
std::shared_ptr< JointPositionPIDController< NJOINTS > > Ptr
Definition: JointPositionPIDController.h:25
void setDesiredPosition(const Eigen::Matrix< double, NJOINTS, 1 > &desiredPosition)
Definition: JointPositionPIDController-impl.h:64
static const size_t STATE_DIM
Definition: JointPositionPIDController.h:22
void computeControl(const core::StateVector< STATE_DIM > &state, const core::Time &t, core::ControlVector< NJOINTS > &control) override
Definition: JointPositionPIDController-impl.h:51
void setAllPIDGains(double kp, double ki, double kd)
Definition: JointPositionPIDController-impl.h:81
ct::core::PIDController< double > PIDController
Definition: JointPositionPIDController.h:26
virtual ~JointPositionPIDController()
Definition: JointPositionPIDController-impl.h:18
JointPositionPIDController(const Eigen::Matrix< double, NJOINTS, 1 > &desiredPosition=Eigen::Matrix< double, NJOINTS, 1 >::Zero(), const Eigen::Matrix< double, NJOINTS, 1 > &desiredVelocity=Eigen::Matrix< double, NJOINTS, 1 >::Zero(), const std::vector< PIDController::parameters_t > &parameters=std::vector< PIDController::parameters_t >(NJOINTS, PIDController::parameters_t()))
Definition: JointPositionPIDController-impl.h:23
static const size_t CONTROL_DIM
Definition: JointPositionPIDController.h:23
std::vector< PIDController > jointControllers_
Definition: JointPositionPIDController.h:55
void reset()
Definition: JointPositionPIDController-impl.h:95
double Time