Yet Another Robot Platform
Use YARP to talk to ROS services

Please see "example/ros" in the YARP source code for full examples.

For simple cases, we can just use YARP Bottles whose content matches ROS types structurally. For example, to call a ROS service that adds two integers, we could do this:

* Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
* All rights reserved.
* This software may be modified and distributed under the terms of the
* BSD-3-Clause license. See the accompanying LICENSE file for details.
#include <stdio.h>
#include <stdlib.h>
#include <yarp/os/all.h>
using namespace yarp::os;
int main(int argc, char *argv[]) {
if (argc!=3) {
fprintf(stderr,"Call as %s X Y\n", argv[0]);
return 1;
Network yarp;
Node node("/yarp_add_int_client");
RpcClient client;
if (!client.open("add_two_ints")) {
fprintf(stderr,"Failed to open client\n");
return 1;
Bottle msg, reply;
if (!client.write(msg,reply)) {
fprintf(stderr,"Failed to call service\n");
return 1;
printf("Got %d\n", reply.get(0).asInt32());
return 0;

An example CMakeLists.txt file to compile this and link with YARP would be:

cmake_minimum_required(VERSION 3.5)
find_package(YARP REQUIRED)
add_executable(add_int_client_v1 add_int_client_v1.cpp)
target_link_libraries(add_int_client_v1 ${YARP_LIBRARIES})

On the ROS side we'd do:

rosrun rospy_tutorials add_two_ints_server

Then on the YARP side we can try it out (assume the above program is compiled as 'add_int_client_v1'):

./add_int_client_v1 4 6
yarp: Port /yarp_add_int_client active at tcp://
yarp: Port /add_two_ints+1@/yarp_add_int_client active at tcp://
Got 10