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

Send countdown messages from a port (paired with os/view_count.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/Time.h>
#include <cstdio>
constexpr double loop_delay = 1.0;
int main(int argc, char* argv[])
{
if (argc != 2) {
return 1;
}
Network yarp;
BufferedPort<Bottle> out;
out.open(argv[1]);
for (int i = 10; i >= 0; i--) {
printf("at %d\n", i);
Bottle& msg = out.prepare();
msg.clear();
msg.addString("countdown");
msg.addInt32(i);
out.write();
yarp::os::Time::delay(loop_delay);
}
return 0;
}
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:61
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition: Network.h:783
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
int main(int argc, char *argv[])
Definition: yarpros.cpp:264