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
12
18#include <yarp/dev/IMotor.h>
27#include <yarp/dev/IAxisInfo.h>
33#include <yarp/dev/IMotor.h>
34
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{
67private:
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 yarp::dev::IJointFault* iJointFault{ nullptr };
115
116 bool setDevice(yarp::dev::DeviceDriver* device, bool owned);
117 bool openAndAttachSubDevice(yarp::os::Property& prop);
118
119 void closeDevice();
120 void closePorts();
121
122public:
128 ~ControlBoard_nws_yarp() override = default;
129
130 // yarp::dev::DeviceDriver
131 bool close() override;
132 bool open(yarp::os::Searchable& prop) override;
133
134 // yarp::dev::WrapperSingle
135 bool attach(yarp::dev::PolyDriver* poly) override;
136 bool detach() override;
137
138 // yarp::os::PeriodicThread
139 void run() override;
140};
141
142
143#endif // YARP_DEV_CONTROLBOARD_NWS_YARP_H
constexpr double default_period
Definition: FakeOdometry.h:14
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() 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 & operator=(ControlBoard_nws_yarp &&)=delete
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:30
Interface for control devices, amplifier commands.
Interface for getting information about specific axes, if available.
Definition: IAxisInfo.h:36
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:23
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...
Interface for getting info about the fault which may occur on a robot.
Definition: IJointFault.h:23
Control board, encoder interface.
Control board, encoder interface.
Definition: IMotor.h:94
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition: IPWMControl.h:23
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Definition: IPidControl.h:204
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:23
Helper interface for an object that can wrap/or "attach" to a single other device.
Definition: WrapperSingle.h:31
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:46
A class for storing options and configuration information.
Definition: Property.h:33
A base class for nested structures that can be searched.
Definition: Searchable.h:56
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:21