YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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/Bottle.h>
11#include <yarp/sig/Vector.h>
14
15#ifndef DOXYGEN_SHOULD_SKIP_THIS
16
17
18/* check whether the last command failed */
19inline yarp::dev::ReturnValue CHECK_FAIL(bool ok, yarp::os::Bottle& response)
20{
21 if (ok) {
22 if (response.get(0).isVocab32() && response.get(0).asVocab32() == VOCAB_FAILED) {
24 }
25 } else {
27 }
28
30}
31
32#define POINTERCHECK(comp,vec) if (vec==nullptr) { yCError(comp,"vec is nullptr"); return yarp::dev::ReturnValue::return_code::return_value_error_input_out_of_bounds;}
33#define JOINTIDCHECK(comp,j) if (!castToMapper(m_helper)->checkAxisId(j)) { yCError(comp,"joint id out of bound"); return yarp::dev::ReturnValue::return_code::return_value_error_input_out_of_bounds;}
34#define JOINTSIDCHECK(comp,n_joints, joints) if (!castToMapper(m_helper)->checkAxesIds(n_joints, joints)) { yCError(comp,"joint id out of bound"); return yarp::dev::ReturnValue::return_code::return_value_error_input_out_of_bounds;}
35
36#define JOINTSIDVECCHECK(comp,joints) if (!castToMapper(m_helper)->checkAxesIds(joints)) { yCError(comp,"joint id out of bound"); return yarp::dev::ReturnValue::return_code::return_value_error_input_out_of_bounds;}
37#define VECCHECK_SET_ALL(comp,vec) if (vec.size() != castToMapper(m_helper)->axes()) { yCError(comp,"vector size does not match number of joints"); return yarp::dev::ReturnValue::return_code::return_value_error_input_out_of_bounds;}
38#define VECCHECK_GET_ALL(comp,vec) if (vec.size() != castToMapper(m_helper)->axes()) { vec.resize(castToMapper(m_helper)->axes());}
39#define VECCHECK_SET_SOME(comp,jointsvec,datavec) JOINTSIDVECCHECK(comp,jointsvec) if (datavec.size() != jointsvec.size()) { yCError(comp,"vector size does not match number of joints"); return yarp::dev::ReturnValue::return_code::return_value_error_input_out_of_bounds;}
40#define VECCHECK_GET_SOME(comp,jointsvec,datavec) JOINTSIDVECCHECK(comp,jointsvec) if (datavec.size() != jointsvec.size()) { datavec.resize(jointsvec.size());}
41
42#endif // DOXYGEN_SHOULD_SKIP_THIS
43
44#endif // YARP_DEV_CONTROLBOARDHELPERS_H_H
constexpr yarp::conf::vocab32_t VOCAB_FAILED
contains the definition of a Vector type
@ return_value_error_generic
Method was successfully executed.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:252
virtual yarp::conf::vocab32_t asVocab32() const
Get 32 bit vocabulary identifier as an integer.
Definition Value.cpp:234
virtual bool isVocab32() const
Checks if value is a 32bit vocabulary identifier.
Definition Value.cpp:174