YARP
Yet Another Robot Platform
ControlBoardHelpers.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_DEV_CONTROLBOARDHELPERS_H
8 #define YARP_DEV_CONTROLBOARDHELPERS_H
9 
10 #include <yarp/os/PortablePair.h>
11 #include <yarp/os/Bottle.h>
12 #include <yarp/sig/Vector.h>
13 #include <yarp/dev/GenericVocabs.h>
14 
15 #ifndef DOXYGEN_SHOULD_SKIP_THIS
16 
17 /* the control command message type
18  * head is a Bottle which contains the specification of the message type
19  * body is a Vector which move the robot accordingly
20  */
22 
23 /* check whether the last command failed */
24 inline bool CHECK_FAIL(bool ok, yarp::os::Bottle& response)
25 {
26  if (ok) {
27  if (response.get(0).isVocab32() && response.get(0).asVocab32() == VOCAB_FAILED) {
28  return false;
29  }
30  } else {
31  return false;
32  }
33 
34  return true;
35 }
36 
37 #endif // DOXYGEN_SHOULD_SKIP_THIS
38 
39 #endif // YARP_DEV_CONTROLBOARDHELPERS_H_H
constexpr yarp::conf::vocab32_t VOCAB_FAILED
Definition: GenericVocabs.h:16
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
contains the definition of a Vector type
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:246
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:48
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:228
virtual bool isVocab32() const
Checks if value is a vocabulary identifier.
Definition: Value.cpp:174