BipedalLocomotion::YarpUtilities namespace

Helper for YARP library.

Classes

class RosPublisher
The class internally contains a YARP based ROS node and a set of publishers.
class VectorsCollectionClient
VectorsCollectionClient is a class that implements that allows to receive a VectorsCollection from a VectorsCollectionServer.
class VectorsCollectionServer
VectorsCollectionServer is a class that implements the VectorsCollectionMetadataService.

Functions

template<typename T>
auto convertValue(const yarp::os::Value& value) -> T
Convert a value in a element of type T.
template<>
auto convertValue<int>(const yarp::os::Value& value) -> int
Convert a value in a element of type int.
template<>
auto convertValue<double>(const yarp::os::Value& value) -> double
Convert a value in a element of type double.
template<>
auto convertValue<std::string>(const yarp::os::Value& value) -> std::string
Convert a value in a element of type string.
template<>
auto convertValue<bool>(const yarp::os::Value& value) -> bool
Convert a value in a element of type Boolean.
auto addVectorOfStringToProperty(yarp::os::Property& prop, const std::string& key, const std::vector<std::string>& list) -> bool
Add a vector of string to a property of a given name.
template<typename T>
auto getElementFromSearchable(const yarp::os::Searchable& config, const std::string& key, T& number) -> bool
Extract a double from a searchable object.
template<typename T>
auto getVectorFromSearchable(const yarp::os::Searchable& config, const std::string& key, T& vector) -> bool
Extract a vector from searchable.
template<>
auto getVectorFromSearchable<std::vector<bool>>(const yarp::os::Searchable& config, const std::string& key, std::vector<bool>& vector) -> bool
Extract an std::vector<bool> from searchable.
template<typename T>
void mergeSigVector(yarp::sig::Vector& vector, const T& t)
Append a scalar to a vector.
template<typename T, typename... Args>
void mergeSigVector(yarp::sig::Vector& vector, const T& t, const Args&... args)
Variadic function used to merge several vectors.
template<typename... Args>
void sendVariadicVector(yarp::os::BufferedPort<yarp::sig::Vector>& port, const Args&... args)
Send a variadic vector through a yarp buffered port.
void populateBottleWithStrings(yarp::os::Bottle& bottle, const std::initializer_list<std::string>& strings)
Add strings to a bottle.

Function documentation

template<typename T>
T BipedalLocomotion::YarpUtilities::convertValue(const yarp::os::Value& value)

Convert a value in a element of type T.

Template parameters
T return type
Parameters
value the value that will be converted
Returns an element of type T

template<>
int BipedalLocomotion::YarpUtilities::convertValue<int>(const yarp::os::Value& value)

Convert a value in a element of type int.

Parameters
value the value that will be converted
Returns an integer

template<>
double BipedalLocomotion::YarpUtilities::convertValue<double>(const yarp::os::Value& value)

Convert a value in a element of type double.

Parameters
value the value that will be converted
Returns a double

template<>
std::string BipedalLocomotion::YarpUtilities::convertValue<std::string>(const yarp::os::Value& value)

Convert a value in a element of type string.

Parameters
value the value that will be converted
Returns a string

template<>
bool BipedalLocomotion::YarpUtilities::convertValue<bool>(const yarp::os::Value& value)

Convert a value in a element of type Boolean.

Parameters
value the value that will be converted
Returns a Boolean

bool BipedalLocomotion::YarpUtilities::addVectorOfStringToProperty(yarp::os::Property& prop, const std::string& key, const std::vector<std::string>& list)

Add a vector of string to a property of a given name.

Parameters
prop yarp property;
key is the key;
list is the vector of strings that will be added into the property.
Returns true/false in case of success/failure

template<typename T>
bool BipedalLocomotion::YarpUtilities::getElementFromSearchable(const yarp::os::Searchable& config, const std::string& key, T& number)

Extract a double from a searchable object.

Parameters
config is the searchable object;
key the name to check for;
number is the double.
Returns true/false in case of success/failure

template<typename T>
bool BipedalLocomotion::YarpUtilities::getVectorFromSearchable(const yarp::os::Searchable& config, const std::string& key, T& vector)

Extract a vector from searchable.

Parameters
config is the searchable object;
key the name to check for;
vector a vector.
Returns true/false in case of success/failure

template<>
bool BipedalLocomotion::YarpUtilities::getVectorFromSearchable<std::vector<bool>>(const yarp::os::Searchable& config, const std::string& key, std::vector<bool>& vector)

Extract an std::vector<bool> from searchable.

Parameters
config is the searchable object;
key the name to check for;
vector a std::vector<bool>
Returns true/false in case of success/failure

The specialization is required because vector.data() is not defined when vector is an std::vector<bool>

template<typename T>
void BipedalLocomotion::YarpUtilities::mergeSigVector(yarp::sig::Vector& vector, const T& t)

Append a scalar to a vector.

Parameters
vector the original vector. The new elements will be add at the end of this vector;
t is a container or a scalar. If t is a container it has to be an iterable object (the element has the methods T::begin() and T::end() or the operator[] has to be defined

vector = [vector, t]

template<typename T, typename... Args>
void BipedalLocomotion::YarpUtilities::mergeSigVector(yarp::sig::Vector& vector, const T& t, const Args&... args)

Variadic function used to merge several vectors.

Parameters
vector the original vector. The new elements will be add at the end of this vector;
t is a container or a scalar. If t is a container it has to be an iterable object (the element has the methods T::begin() and T::end()) or the operator[] has to be defined
args list containing all the vector that will be merged.

template<typename... Args>
void BipedalLocomotion::YarpUtilities::sendVariadicVector(yarp::os::BufferedPort<yarp::sig::Vector>& port, const Args&... args)

Send a variadic vector through a yarp buffered port.

Parameters
port is a Yarp buffered port
args list containing all the vector that will be send.

void BipedalLocomotion::YarpUtilities::populateBottleWithStrings(yarp::os::Bottle& bottle, const std::initializer_list<std::string>& strings)

Add strings to a bottle.

Parameters
bottle this bottle will be filled.
strings list containing all the string.