YARP
Yet Another Robot Platform
os/simple_sender/simple_sender.cpp

This outputs some data to a port.Designed to be used with os/simple_receiver/simple_receiver.cpp example.

/*
* Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
* Copyright (C) 2006-2010 RobotCub Consortium
* 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 <yarp/os/Bottle.h>
#include <yarp/os/Port.h>
#include <yarp/os/Time.h>
#include <cstdio>
constexpr double loop_delay = 1.0;
constexpr size_t top = 100;
int main(int argc, char* argv[])
{
YARP_UNUSED(argc);
YARP_UNUSED(argv);
Network yarp;
Port output;
output.open("/sender");
for (size_t i = 1; i <= top; i++) {
// prepare a message
Bottle bot;
bot.addString("testing");
bot.addInt32(i);
bot.addString("of");
bot.addInt32(top);
// send the message
output.write(bot);
printf("Sent message: %s\n", bot.toString().c_str());
// wait a while
yarp::os::Time::delay(loop_delay);
}
output.close();
return 0;
}
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
Network.h
Port.h
main
int main(int argc, char *argv[])
Definition: yarpros.cpp:261
YARP_UNUSED
#define YARP_UNUSED(var)
Definition: api.h:159
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
yarp::os::Network
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition: Network.h:786
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
Time.h
yarp::os::Time::delay
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:114
Bottle.h