How to print a specific integer value in a Bottle in YARP?

65 Views Asked by At

I'm trying to print a specific integer value of a Bottle by using cout (the Bottle contains only integer values), but it seems that this is a wrong way to do it. The command I used in a for loop is (the b Bottle is defined outside the loop):

std::cout << b.get(i) << std::endl;

The corresponding error is:

enter image description here

I'd like to see an example regarding the reading of a Bottle value.

1

There are 1 best solutions below

5
Cory Kramer On BEST ANSWER

You would have to get at the underlying type of the Value, if you know that it is indeed an int32_t (in other words b.get(i).isInt32() is true) then

std::cout << b.get(i).asInt32() << std::endl;

For the purposes of writing, without having to check the underlying type, you might also consider simply stringifying the Value

std::cout << b.get(i).toString() << std::endl;