31void ControlBoard_nws_yarp::closePorts()
38 inputStreamingPort.
close();
41 outputPositionStatePort.
close();
44 extendedOutputStatePort.
close();
73 inputRPC_buffer.
attach(inputRPCPort);
74 RPC_parser.
attach(inputRPC_buffer);
84 if (!outputPositionStatePort.
open(
rootName +
"/state:o")) {
91 if (!extendedOutputStatePort.
open(
rootName +
"/stateExt:o")) {
96 extendedOutputState_buffer.
attach(extendedOutputStatePort);
100 if (subdevice_ready) {
119 yCWarning(
CONTROLBOARD,
"Part <%s>: iJointFault interface was not found in subdevice.", partName.c_str());
125 yCWarning(
CONTROLBOARD,
"Part <%s>: IPidControl interface was not found in subdevice.", partName.c_str());
130 if (!iPositionControl) {
131 yCWarning(
CONTROLBOARD,
"Part <%s>: IPositionControl interface was not found in subdevice.", partName.c_str());
136 if (!iPositionDirect) {
137 yCWarning(
CONTROLBOARD,
"Part <%s>: IPositionDirect interface was not found in subdevice.", partName.c_str());
142 if (!iVelocityControl) {
143 yCWarning(
CONTROLBOARD,
"Part <%s>: IVelocityControl interface was not found in subdevice.", partName.c_str());
148 if (!iEncodersTimed) {
149 yCWarning(
CONTROLBOARD,
"Part <%s>: IEncodersTimed interface was not found in subdevice.", partName.c_str());
155 yCWarning(
CONTROLBOARD,
"Part <%s>: IMotor interface was not found in subdevice.", partName.c_str());
160 if (!iMotorEncoders) {
161 yCWarning(
CONTROLBOARD,
"Part <%s>: IMotorEncoders interface was not found in subdevice.", partName.c_str());
166 if (!iAmplifierControl) {
167 yCWarning(
CONTROLBOARD,
"Part <%s>: IAmplifierControl interface was not found in subdevice.", partName.c_str());
172 if (!iControlLimits) {
173 yCWarning(
CONTROLBOARD,
"Part <%s>: IControlLimits interface was not found in subdevice.", partName.c_str());
178 if (!iControlCalibration) {
179 yCWarning(
CONTROLBOARD,
"Part <%s>: IControlCalibration interface was not found in subdevice.", partName.c_str());
184 if (!iTorqueControl) {
185 yCWarning(
CONTROLBOARD,
"Part <%s>: ITorqueControl interface was not found in subdevice.", partName.c_str());
190 if (!iImpedanceControl) {
191 yCWarning(
CONTROLBOARD,
"Part <%s>: IImpedanceControl interface was not found in subdevice.", partName.c_str());
197 yCWarning(
CONTROLBOARD,
"Part <%s>: IControlMode interface was not found in subdevice.", partName.c_str());
203 yCWarning(
CONTROLBOARD,
"Part <%s>: IAxisInfo interface was not found in subdevice.", partName.c_str());
208 if (!iPreciselyTimed) {
209 yCWarning(
CONTROLBOARD,
"Part <%s>: IPreciselyTimed interface was not found in subdevice.", partName.c_str());
214 if (!iInteractionMode) {
215 yCWarning(
CONTROLBOARD,
"Part <%s>: IInteractionMode interface was not found in subdevice.", partName.c_str());
220 if (!iRemoteVariables) {
221 yCWarning(
CONTROLBOARD,
"Part <%s>: IRemoteVariables interface was not found in subdevice.", partName.c_str());
227 yCWarning(
CONTROLBOARD,
"Part <%s>: IPWMControl interface was not found in subdevice.", partName.c_str());
232 if (!iCurrentControl) {
233 yCWarning(
CONTROLBOARD,
"Part <%s>: ICurrentControl interface was not found in subdevice.", partName.c_str());
241 yCError(
CONTROLBOARD) <<
"Part <%s>: iAxisInfo->getAxes() failed for subdevice " << partName.c_str();
245 else if (iEncodersTimed)
248 yCError(
CONTROLBOARD) <<
"Part <%s>: iEncodersTimed->getAxes() failed for subdevice " << partName.c_str();
252 else if (iPositionControl)
255 yCError(
CONTROLBOARD) <<
"Part <%s>: iPositionControl->getAxes() failed for subdevice " << partName.c_str();
259 else if (iVelocityControl)
262 yCError(
CONTROLBOARD) <<
"Part <%s>: iVelocityControl->getAxes() failed for subdevice " << partName.c_str();
271 subdevice_joints =
static_cast<size_t>(
tmp_axes);
272 times.
resize(subdevice_joints);
284void ControlBoard_nws_yarp::closeDevice()
287 streaming_parser.
reset();
290 subdevice_joints = 0;
291 subdevice_ready =
false;
296 iPidControl =
nullptr;
297 iPositionControl =
nullptr;
298 iPositionDirect =
nullptr;
299 iVelocityControl =
nullptr;
300 iEncodersTimed =
nullptr;
302 iMotorEncoders =
nullptr;
303 iAmplifierControl =
nullptr;
304 iControlLimits =
nullptr;
305 iControlCalibration =
nullptr;
306 iTorqueControl =
nullptr;
307 iImpedanceControl =
nullptr;
308 iControlMode =
nullptr;
310 iPreciselyTimed =
nullptr;
311 iInteractionMode =
nullptr;
312 iRemoteVariables =
nullptr;
313 iPWMControl =
nullptr;
314 iCurrentControl =
nullptr;
315 iJointFault =
nullptr;
321 if (subdevice_ready) {
325 if (!setDevice(poly,
false)) {
373 if (iEncodersTimed) {
383 if (iMotorEncoders) {
393 if (iTorqueControl) {
405 if (iCurrentControl) {
407 }
else if (iAmplifierControl) {
419 if (iInteractionMode) {
426 for (
double tt : times)
428 if (std::abs(times[0] -
tt) > 1.0)
436 time.
update(std::accumulate(times.
begin(), times.
end(), 0.0) / subdevice_joints);
440 extendedOutputState_buffer.
write();
444 v.
resize(subdevice_joints);
448 outputPositionStatePort.
write();
const yarp::os::LogComponent & CONTROLBOARD()
const double DEFAULT_PERIOD
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
void run() override
Loop function.
bool open(yarp::os::Searchable &prop) override
Open the DeviceDriver.
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).
void init(yarp::dev::DeviceDriver *x)
Initialization.
virtual bool initialize()
Initialize the internal data.
void init(yarp::dev::DeviceDriver *x)
Initialization.
Interface implemented by all device drivers.
void attach(yarp::os::TypedReader< yarp::os::Bottle > &source)
Attach this object to a source of messages.
virtual bool getCurrents(double *vals)=0
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
virtual bool getControlModes(int *modes)=0
Get the current control mode (multiple joints).
virtual bool getCurrents(double *currs)=0
Get the instantaneous current measurement for all motors.
virtual bool getEncodersTimed(double *encs, double *time)=0
Read the instantaneous acceleration of all axes.
virtual bool getEncoderAccelerations(double *accs)=0
Read the instantaneous acceleration of all axes.
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
virtual bool getEncoderSpeeds(double *spds)=0
Read the instantaneous speed of all axes.
virtual bool getInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes)=0
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
virtual bool getMotorEncoderSpeeds(double *spds)=0
Read the instantaneous speed of all motor encoders.
virtual bool getMotorEncoderAccelerations(double *accs)=0
Read the instantaneous acceleration of all motor encoders.
virtual bool getMotorEncoders(double *encs)=0
Read the position of all motor encoders.
virtual bool getDutyCycles(double *vals)=0
Gets the current dutycycle of the output of the amplifier (i.e.
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
virtual bool getTorques(double *t)=0
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
virtual bool getAxes(int *axes)=0
Get the number of controlled axes.
A container for a device driver.
yarp::sig::VectorOf< double > motorVelocity
yarp::sig::VectorOf< double > jointAcceleration
yarp::sig::VectorOf< int > controlMode
bool pwmDutycycle_isValid
yarp::sig::VectorOf< int > interactionMode
yarp::sig::VectorOf< double > current
bool jointVelocity_isValid
yarp::sig::VectorOf< double > motorAcceleration
bool motorVelocity_isValid
yarp::sig::VectorOf< double > motorPosition
yarp::sig::VectorOf< double > pwmDutycycle
bool jointAcceleration_isValid
yarp::sig::VectorOf< double > torque
bool motorAcceleration_isValid
bool interactionMode_isValid
yarp::sig::VectorOf< double > jointPosition
bool motorPosition_isValid
bool jointPosition_isValid
yarp::sig::VectorOf< double > jointVelocity
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
int getPendingReads() override
Get the number of objects ready to be read.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
void setStrict(bool strict=true) override
Call this to strictly keep all messages, or allow old ones to be quietly dropped.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
An abstraction for a periodic thread.
bool setPeriod(double period)
Set the (new) period of the thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
void attach(Port &port)
Attach this buffer to a particular port.
T & get()
A synonym of PortWriterBuffer::prepare.
void write(bool forceStrict=false)
Try to write the last buffer returned by PortWriterBuffer::get.
void attach(Port &port)
Set the Port to which objects will be written.
void setReader(PortReader &reader) override
Set an external reader for port data.
bool removeCallbackLock() override
Remove a lock on callbacks added with setCallbackLock()
void interrupt() override
Interrupt any current reads or writes attached to the port.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
void resize(size_t size) override
Resize the vector.
iterator begin() noexcept
Returns an iterator to the beginning of the VectorOf.
T * data()
Return a pointer to the first element of the vector.
iterator end() noexcept
Returns an iterator to the end of the VectorOf.
#define yCError(component,...)
#define yCWarning(component,...)
#define yCIErrorThrottle(component, id, period,...)
#define yCIWarning(component, id,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.