YARP
Yet Another Robot Platform
ControlBoardHelpers.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_DEV_CONTROLBOARDHELPERS_H
11 #define YARP_DEV_CONTROLBOARDHELPERS_H
12 
13 #include <yarp/os/PortablePair.h>
14 #include <yarp/os/Bottle.h>
15 #include <yarp/sig/Vector.h>
16 
17 #ifndef DOXYGEN_SHOULD_SKIP_THIS
18 
19 /* the control command message type
20  * head is a Bottle which contains the specification of the message type
21  * body is a Vector which move the robot accordingly
22  */
24 
25 /* check whether the last command failed */
26 inline bool CHECK_FAIL(bool ok, yarp::os::Bottle& response) {
27 
28  if (ok) {
29  if (response.get(0).isVocab() && response.get(0).asVocab() == VOCAB_FAILED) {
30  return false;
31  }
32  }
33  else
34  return false;
35 
36  return true;
37 }
38 
39 #endif // DOXYGEN_SHOULD_SKIP_THIS
40 
41 #endif // YARP_DEV_CONTROLBOARDHELPERS_H_H
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:228
virtual bool isVocab() const
Checks if value is a vocabulary identifier.
Definition: Value.cpp:177
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:50
A simple collection of objects that can be described and transmitted in a portable way...
Definition: Bottle.h:72
contains the definition of a Vector type
constexpr yarp::conf::vocab32_t VOCAB_FAILED
Definition: GenericVocabs.h:19
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:231