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

Send countdown messages from a port (paired with os/view_count.cpp example).

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:64
A mini-server for performing network communication in the background.
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:706
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