YARP
Yet Another Robot Platform
ControlBoard_nws_yarp.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_CONTROLBOARD_NWS_YARP_H
7 #define YARP_DEV_CONTROLBOARD_NWS_YARP_H
8 
10 #include <yarp/dev/WrapperSingle.h>
11 #include <yarp/os/PeriodicThread.h>
12 
13 #include <yarp/dev/IPidControl.h>
18 #include <yarp/dev/IMotor.h>
26 #include <yarp/dev/IControlMode.h>
27 #include <yarp/dev/IAxisInfo.h>
30 #include <yarp/dev/IPWMControl.h>
33 #include <yarp/dev/IMotor.h>
34 
35 #include <yarp/os/BufferedPort.h>
36 #include <yarp/os/Stamp.h>
37 #include <yarp/sig/Vector.h>
38 
40 
41 #include <string>
42 
44 #include "RPCMessagesParser.h"
45 
46 
66 {
67 private:
68  std::string rootName;
69 
70  bool checkPortName(yarp::os::Searchable &params);
71 
72  yarp::os::BufferedPort<yarp::sig::Vector> outputPositionStatePort; // Port /state:o streaming out the encoder positions
73  yarp::os::BufferedPort<CommandMessage> inputStreamingPort; // Input streaming port for high frequency commands
74  yarp::os::Port inputRPCPort; // Input RPC port for set/get remote calls
75  yarp::os::Port extendedOutputStatePort; // Port /stateExt:o streaming out the struct with the robot data
76 
77  yarp::os::PortWriterBuffer<yarp::dev::impl::jointData> extendedOutputState_buffer; // Buffer associated to the extendedOutputStatePort port
78  yarp::os::PortReaderBuffer<yarp::os::Bottle> inputRPC_buffer; // Buffer associated to the inputRPCPort port
79 
80  RPCMessagesParser RPC_parser; // Message parser associated to the inputRPCPort port
81  StreamingMessagesParser streaming_parser; // Message parser associated to the inputStreamingPort port
82 
83  static constexpr double default_period = 0.02; // s
84  double period {default_period};
85 
86  std::string partName; // to open ports and print more detailed debug messages
87  yarp::sig::Vector times; // time for each joint
88  yarp::os::Stamp time; // envelope to attach to the state port
89 
90  yarp::dev::DeviceDriver* subdevice_ptr{nullptr};
91  bool subdevice_owned = false;
92  size_t subdevice_joints {0};
93  bool subdevice_ready = false;
94 
95  yarp::dev::IPidControl* iPidControl{nullptr};
96  yarp::dev::IPositionControl* iPositionControl{nullptr};
97  yarp::dev::IPositionDirect* iPositionDirect{nullptr};
98  yarp::dev::IVelocityControl* iVelocityControl{nullptr};
99  yarp::dev::IEncodersTimed* iEncodersTimed{nullptr};
100  yarp::dev::IMotor* iMotor{nullptr};
101  yarp::dev::IMotorEncoders* iMotorEncoders{nullptr};
102  yarp::dev::IAmplifierControl* iAmplifierControl{nullptr};
103  yarp::dev::IControlLimits* iControlLimits{nullptr};
104  yarp::dev::IControlCalibration* iControlCalibration{nullptr};
105  yarp::dev::ITorqueControl* iTorqueControl{nullptr};
106  yarp::dev::IImpedanceControl* iImpedanceControl{nullptr};
107  yarp::dev::IControlMode* iControlMode{nullptr};
108  yarp::dev::IAxisInfo* iAxisInfo{nullptr};
109  yarp::dev::IPreciselyTimed* iPreciselyTimed{nullptr};
110  yarp::dev::IInteractionMode* iInteractionMode{nullptr};
111  yarp::dev::IRemoteVariables* iRemoteVariables{nullptr};
112  yarp::dev::IPWMControl* iPWMControl{nullptr};
113  yarp::dev::ICurrentControl* iCurrentControl{nullptr};
114 
115  bool setDevice(yarp::dev::DeviceDriver* device, bool owned);
116  bool openAndAttachSubDevice(yarp::os::Property& prop);
117 
118  void closeDevice();
119  void closePorts();
120 
121 public:
127  ~ControlBoard_nws_yarp() override = default;
128 
129  // yarp::dev::DeviceDriver
130  bool close() override;
131  bool open(yarp::os::Searchable& prop) override;
132 
133  // yarp::dev::WrapperSingle
134  bool attach(yarp::dev::PolyDriver* poly) override;
135  bool detach() override;
136 
137  // yarp::os::PeriodicThread
138  void run() override;
139 };
140 
141 
142 #endif // YARP_DEV_CONTROLBOARD_NWS_YARP_H
define control board standard interfaces
define control board standard interfaces
define control board standard interfaces
contains the definition of a Vector type
controlBoard_nws_yarp: A controlBoard network wrapper server for YARP.
ControlBoard_nws_yarp & operator=(ControlBoard_nws_yarp &&)=delete
~ControlBoard_nws_yarp() override=default
void run() override
Loop function.
ControlBoard_nws_yarp & operator=(const ControlBoard_nws_yarp &)=delete
bool open(yarp::os::Searchable &prop) override
Open the DeviceDriver.
ControlBoard_nws_yarp(const ControlBoard_nws_yarp &)=delete
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool detach() override
Detach the object (you must have first called attach).
ControlBoard_nws_yarp(ControlBoard_nws_yarp &&)=delete
Helper object for parsing RPC port messages.
Callback implementation after buffered input.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
Interface for control devices, amplifier commands.
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:40
Interface for control devices, calibration commands.
Interface for control devices, commands to get/set position and veloity limits.
Interface for setting control mode in control board.
Definition: IControlMode.h:25
Interface for control boards implementing current control.
Control board, extend encoder interface with timestamps.
Interface for control boards implementing impedance control.
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
Control board, encoder interface.
Control board, encoder interface.
Definition: IMotor.h:96
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition: IPWMControl.h:25
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Definition: IPidControl.h:208
Interface for a generic control board device implementing position control.
Interface for a generic control board device implementing position control.
IRemoteVariables interface.
Interface for control boards implementing torque control.
Interface for control boards implementing velocity control.
A container for a device driver.
Definition: PolyDriver.h:24
Helper interface for an object that can wrap/or "attach" to a single other device.
Definition: WrapperSingle.h:32
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:47
A class for storing options and configuration information.
Definition: Property.h:34
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22