I'm a beginner in using YARP. My goal is to create two ports, and connect them (I'm using an Ubuntu virtual machine). The writer should receive inputs from the command line through the argv pointer.
When I run the code:
#include <yarp/os/all.h>
#include <iostream>
using namespace yarp::os;
int main(int argc, char *argv[]) {
int i = 0;
// Set up YARP
Network yarp;
// Create port
Port pout;
bool ok = pout.open("/examples/port/sender");
if (!ok) {
std::cerr << "Failed to open port" << std::endl;
return 1;
}
// waiting for the receiver before transmitting
yarp.waitConnection("/examples/port/sender", "/examples/port/receiver");
// send data in a loop
for(i = 0; i < argc; i++) {
Bottle b;
int x = atoi(argv[i]);
b.addInt(x);
std::cout << "Sending " << x << " message " << std::endl;
pout.write(b);
}
// close port
pout.close();
return 0;
}
I got the following errors:
[ERROR] |yarp.os.Network| Cannot connect to port /root
[ERROR] |yarp.os.Port| Port /examples/port/sender failed to activate (invalid address)
Failed to open port
Can you tell me what is the mistake I did please?