YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
os/simple_sender/simple_sender.cpp

This outputs some data to a port.

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

/*
* SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
* SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
* SPDX-License-Identifier: BSD-3-Clause
*/
#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;
}
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:706
A mini-server for network communication.
Definition Port.h:46
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_UNUSED(var)
Definition api.h:162