YARP
Yet Another Robot Platform
ControlBoardHelpers.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 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 #include <yarp/dev/GenericVocabs.h>
17 
18 #ifndef DOXYGEN_SHOULD_SKIP_THIS
19 
20 /* the control command message type
21  * head is a Bottle which contains the specification of the message type
22  * body is a Vector which move the robot accordingly
23  */
25 
26 /* check whether the last command failed */
27 inline bool CHECK_FAIL(bool ok, yarp::os::Bottle& response)
28 {
29  if (ok) {
30  if (response.get(0).isVocab() && response.get(0).asVocab() == VOCAB_FAILED) {
31  return false;
32  }
33  } else {
34  return false;
35  }
36 
37  return true;
38 }
39 
40 #endif // DOXYGEN_SHOULD_SKIP_THIS
41 
42 #endif // YARP_DEV_CONTROLBOARDHELPERS_H_H
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::os::Value::asVocab
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:231
yarp::os::PortablePair
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:51
Vector.h
contains the definition of a Vector type
PortablePair.h
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_FAILED
Definition: GenericVocabs.h:19
CommandMessage
yarp::os::PortablePair< yarp::os::Bottle, yarp::sig::Vector > CommandMessage
Definition: RPCMessagesParser.h:44
GenericVocabs.h
Bottle.h
yarp::os::Value::isVocab
virtual bool isVocab() const
Checks if value is a vocabulary identifier.
Definition: Value.cpp:177