YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImplementPidControl.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_IMPLEMENTPIDCONTROL_H
7#define YARP_DEV_IMPLEMENTPIDCONTROL_H
8
10
11namespace yarp::dev {
12class ImplementPidControl;
13}
14
15namespace yarp::dev::impl {
16
17template <typename T>
18class FixedSizeBuffersManager;
19
20} // namespace yarp::dev::impl
21
23{
24protected:
25 IPidControlRaw* m_iraw=nullptr;
26 void* m_helper=nullptr;
27 std::vector<int> m_buffer_ints;
28 std::vector<double> m_buffer_doubles;
29 std::vector<Pid> m_buffer_pids;
30 std::mutex m_imp_mutex;
31
38 bool initialize(int size, const int *amap, const double *enc, const double *zos, const double* newtons, const double* amps, const double* dutys);
39
44 bool uninitialize();
45
46 bool setConversionUnits(const PidControlTypeEnum& pidtype, const PidFeedbackUnitsEnum fbk_conv_units, const PidOutputUnitsEnum out_conv_units);
47
48public:
49 /* Constructor.
50 * @param y is the pointer to the class instance inheriting from this
51 * implementation.
52 */
54
55 /* Destructor.
56 */
57 virtual ~ImplementPidControl();
58
59 yarp::dev::ReturnValue getAvailablePids(int j, std::vector<PidControlTypeEnum>& avail) override;
60 yarp::dev::ReturnValue setPid(const PidControlTypeEnum& pidtype, int j, const Pid &pid) override;
61 yarp::dev::ReturnValue setPids(const PidControlTypeEnum& pidtype, const Pid *pids) override;
62 yarp::dev::ReturnValue setPidReference(const PidControlTypeEnum& pidtype, int j, double ref) override;
63 yarp::dev::ReturnValue setPidReferences(const PidControlTypeEnum& pidtype, const double *refs) override;
64 yarp::dev::ReturnValue setPidErrorLimit(const PidControlTypeEnum& pidtype, int j, double limit) override;
65 yarp::dev::ReturnValue setPidErrorLimits(const PidControlTypeEnum& pidtype, const double *limits) override;
66 yarp::dev::ReturnValue getPidError(const PidControlTypeEnum& pidtype, int j, double *err) override;
67 yarp::dev::ReturnValue getPidErrors(const PidControlTypeEnum& pidtype, double *errs) override;
68 yarp::dev::ReturnValue getPidOutput(const PidControlTypeEnum& pidtype, int j, double *out) override;
69 yarp::dev::ReturnValue getPidOutputs(const PidControlTypeEnum& pidtype, double *outs) override;
70 yarp::dev::ReturnValue getPid(const PidControlTypeEnum& pidtype, int j, Pid *pid) override;
71 yarp::dev::ReturnValue getPids(const PidControlTypeEnum& pidtype, Pid *pids) override;
72 yarp::dev::ReturnValue getPidReference(const PidControlTypeEnum& pidtype, int j, double *ref) override;
73 yarp::dev::ReturnValue getPidReferences(const PidControlTypeEnum& pidtype, double *refs) override;
74 yarp::dev::ReturnValue getPidErrorLimit(const PidControlTypeEnum& pidtype, int j, double *ref) override;
75 yarp::dev::ReturnValue getPidErrorLimits(const PidControlTypeEnum& pidtype, double *refs) override;
76 yarp::dev::ReturnValue resetPid(const PidControlTypeEnum& pidtype, int j) override;
77 yarp::dev::ReturnValue enablePid(const PidControlTypeEnum& pidtype, int j) override;
78 yarp::dev::ReturnValue disablePid(const PidControlTypeEnum& pidtype, int j) override;
79 yarp::dev::ReturnValue setPidOffset(const PidControlTypeEnum& pidtype, int j, double v) override;
80 yarp::dev::ReturnValue setPidFeedforward(const PidControlTypeEnum& pidtype, int j, double v) override;
81 yarp::dev::ReturnValue getPidOffset(const PidControlTypeEnum& pidtype, int j, double& v) override;
82 yarp::dev::ReturnValue getPidFeedforward(const PidControlTypeEnum& pidtype, int j, double& v) override;
83 yarp::dev::ReturnValue isPidEnabled(const PidControlTypeEnum& pidtype, int j, bool& enabled) override;
85 yarp::dev::ReturnValue getPidExtraInfos(const PidControlTypeEnum& pidtype, std::vector<yarp::dev::PidExtraInfo>& units) override;
86
87 void b();
88};
89
90#endif // YARP_DEV_IMPLEMENTPIDCONTROL_H
Interface for a generic control board device implementing a PID controller.
Definition IPidControl.h:31
Interface for a generic control board device implementing a PID controller, with scaled arguments.
yarp::dev::ReturnValue setPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double limit) override
Set the error limit for the controller on a specific joint.
yarp::dev::ReturnValue setPidOffset(const PidControlTypeEnum &pidtype, int j, double v) override
Set an offset value for a given controller.
yarp::dev::ReturnValue getPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double *ref) override
Get the error limit for the controller on a specific joint.
yarp::dev::ReturnValue setPid(const PidControlTypeEnum &pidtype, int j, const Pid &pid) override
Set new PID value for a joint axis.
yarp::dev::ReturnValue setPidErrorLimits(const PidControlTypeEnum &pidtype, const double *limits) override
Get the error limit for the controller on all joints.
std::vector< double > m_buffer_doubles
bool uninitialize()
Clean up internal data and memory.
yarp::dev::ReturnValue getPidOutput(const PidControlTypeEnum &pidtype, int j, double *out) override
Get the output of the controller (e.g.
yarp::dev::ReturnValue getPidErrors(const PidControlTypeEnum &pidtype, double *errs) override
Get the error of all joints.
yarp::dev::ReturnValue setPidReferences(const PidControlTypeEnum &pidtype, const double *refs) override
Set the controller reference, multiple axes.
yarp::dev::ReturnValue setPids(const PidControlTypeEnum &pidtype, const Pid *pids) override
Set new PID value on multiple axes.
bool initialize(int size, const int *amap, const double *enc, const double *zos, const double *newtons, const double *amps, const double *dutys)
Initialize the internal data and alloc memory.
yarp::dev::ReturnValue getPidError(const PidControlTypeEnum &pidtype, int j, double *err) override
Get the current error for a joint.
yarp::dev::ReturnValue getPids(const PidControlTypeEnum &pidtype, Pid *pids) override
Get current PID value for a specific joint.
yarp::dev::ReturnValue isPidEnabled(const PidControlTypeEnum &pidtype, int j, bool &enabled) override
Get the current status (enabled/disabled) of the PID.
yarp::dev::ReturnValue getPidReferences(const PidControlTypeEnum &pidtype, double *refs) override
Get the current reference of all PID controllers.
yarp::dev::ReturnValue getPidExtraInfos(const PidControlTypeEnum &pidtype, std::vector< yarp::dev::PidExtraInfo > &units) override
Get PID extra info and measurement units for a specific joint.
yarp::dev::ReturnValue setPidReference(const PidControlTypeEnum &pidtype, int j, double ref) override
Set the controller reference for a given axis.
yarp::dev::ReturnValue disablePid(const PidControlTypeEnum &pidtype, int j) override
Disable the PID computation for a joint.
yarp::dev::ReturnValue getPidOutputs(const PidControlTypeEnum &pidtype, double *outs) override
Get the output of the controllers (e.g.
yarp::dev::ReturnValue getPidErrorLimits(const PidControlTypeEnum &pidtype, double *refs) override
Get the error limit for all controllers.
yarp::dev::ReturnValue setPidFeedforward(const PidControlTypeEnum &pidtype, int j, double v) override
Set the feedforward value for the specified PID controller.
yarp::dev::ReturnValue getPidOffset(const PidControlTypeEnum &pidtype, int j, double &v) override
Get the currently set offset value for the specified PID controller.
yarp::dev::ReturnValue getPid(const PidControlTypeEnum &pidtype, int j, Pid *pid) override
Get current PID value for a specific joint.
yarp::dev::ReturnValue getAvailablePids(int j, std::vector< PidControlTypeEnum > &avail) override
Return a list of available pid types mode for the given joint.
yarp::dev::ReturnValue getPidExtraInfo(const PidControlTypeEnum &pidtype, int j, yarp::dev::PidExtraInfo &units) override
Get PID extra info and measurement units for a specific joint.
yarp::dev::ReturnValue resetPid(const PidControlTypeEnum &pidtype, int j) override
Reset the controller of a given joint, usually sets the current status of the joint as the reference ...
yarp::dev::ReturnValue enablePid(const PidControlTypeEnum &pidtype, int j) override
Enable the PID computation for a joint.
yarp::dev::ReturnValue getPidReference(const PidControlTypeEnum &pidtype, int j, double *ref) override
Get the current reference of the PID controller for a specific joint.
yarp::dev::ReturnValue getPidFeedforward(const PidControlTypeEnum &pidtype, int j, double &v) override
Get the currently set feedforward value for the specified PID controller.
bool setConversionUnits(const PidControlTypeEnum &pidtype, const PidFeedbackUnitsEnum fbk_conv_units, const PidOutputUnitsEnum out_conv_units)
Contains the parameters for a PID.
For streams capable of holding different kinds of content, check what they actually have.
PidOutputUnitsEnum
Definition PidEnums.h:64
PidControlTypeEnum
Definition PidEnums.h:15
PidFeedbackUnitsEnum
Definition PidEnums.h:58
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_dev_API
Definition api.h:18