YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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#include <yarp/os/RpcServer.h>
13
19#include <yarp/dev/IMotor.h>
28#include <yarp/dev/IAxisInfo.h>
34#include <yarp/dev/IMotor.h>
36
38#include <yarp/os/Stamp.h>
39#include <yarp/sig/Vector.h>
40
42
43#include <string>
44
46#include "RPCMessagesParser.h"
49
72{
73private:
74 std::mutex m_mutex;
75
76 // thrift
77 std::unique_ptr<ControlBoardRPCd> m_RPC;
78 yarp::os::RpcServer m_rpcPort;
79
80 yarp::os::BufferedPort<yarp::sig::Vector> outputPositionStatePort; // Port /state:o streaming out the encoder positions
81 yarp::os::BufferedPort<CommandMessage> inputStreamingPort; // Input streaming port for high frequency commands
82 yarp::os::Port inputRPCPort; // Input RPC port for set/get remote calls
83 yarp::os::Port extendedOutputStatePort; // Port /stateExt:o streaming out the struct with the robot data
84
85 yarp::os::PortWriterBuffer<yarp::dev::impl::jointData> extendedOutputState_buffer; // Buffer associated to the extendedOutputStatePort port
86 yarp::os::PortReaderBuffer<yarp::os::Bottle> inputRPC_buffer; // Buffer associated to the inputRPCPort port
87
88 RPCMessagesParser RPC_parser; // Message parser associated to the inputRPCPort port
89 StreamingMessagesParser streaming_parser; // Message parser associated to the inputStreamingPort port
90
91 std::string partName; // to open ports and print more detailed debug messages
92 yarp::sig::Vector times; // time for each joint
93 yarp::os::Stamp time; // envelope to attach to the state port
94
95 size_t subdevice_joints {0};
96 yarp::sig::VectorOf<double> tmpVariableForFloatSignals; // temporary variable to store float signals before copying them into the jointData struct
97 bool subdevice_ready = false;
98
99 yarp::dev::IPidControl* iPidControl{nullptr};
100 yarp::dev::IPositionControl* iPositionControl{nullptr};
101 yarp::dev::IPositionDirect* iPositionDirect{nullptr};
102 yarp::dev::IVelocityControl* iVelocityControl{nullptr};
103 yarp::dev::IEncodersTimed* iEncodersTimed{nullptr};
104 yarp::dev::IMotor* iMotor{nullptr};
105 yarp::dev::IMotorEncoders* iMotorEncoders{nullptr};
106 yarp::dev::IAmplifierControl* iAmplifierControl{nullptr};
107 yarp::dev::IControlLimits* iControlLimits{nullptr};
108 yarp::dev::IControlCalibration* iControlCalibration{nullptr};
109 yarp::dev::ITorqueControl* iTorqueControl{nullptr};
110 yarp::dev::IImpedanceControl* iImpedanceControl{nullptr};
111 yarp::dev::IControlMode* iControlMode{nullptr};
112 yarp::dev::IAxisInfo* iAxisInfo{nullptr};
113 yarp::dev::IPreciselyTimed* iPreciselyTimed{nullptr};
114 yarp::dev::IInteractionMode* iInteractionMode{nullptr};
115 yarp::dev::IRemoteVariables* iRemoteVariables{nullptr};
116 yarp::dev::IPWMControl* iPWMControl{nullptr};
117 yarp::dev::ICurrentControl* iCurrentControl{nullptr};
118 yarp::dev::IJointFault* iJointFault{ nullptr };
119 yarp::dev::IJointBrake* iJointBrake {nullptr};
120 yarp::dev::IVelocityDirect* iVelocityDirect{ nullptr };
121
122 bool setDevice(yarp::dev::DeviceDriver* device, bool owned);
123 bool openAndAttachSubDevice(yarp::os::Property& prop);
124
125 void closeDevice();
126 void closePorts();
127
128public:
134 ~ControlBoard_nws_yarp() override = default;
135
136 // yarp::dev::DeviceDriver
137 bool close() override;
138 bool open(yarp::os::Searchable& prop) override;
139
140 // yarp::dev::WrapperSingle
141 bool attach(yarp::dev::PolyDriver* poly) override;
142 bool detach() override;
143
144 // rpc port
145 bool read(yarp::os::ConnectionReader& connection) override;
146
147 // yarp::os::PeriodicThread
148 void run() override;
149};
150
151
152#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
This class is the parameters parser for class ControlBoard_nws_yarp.
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 read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
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.
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.
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 controlling a joint equipped with brakes (hardware or simulated).
Definition IJointBrake.h:23
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.
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.
Interface for control boards implementing direct 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.
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An abstraction for a periodic thread.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
A mini-server for network communication.
Definition Port.h:46
A class for storing options and configuration information.
Definition Property.h:33
A port that is specialized as an RPC server.
Definition RpcServer.h:23
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21