B0RemoteApi communication between two PCs

Typically: "How do I... ", "How can I... " questions
Post Reply
jhyoon7579
Posts: 3
Joined: 25 Jul 2022, 01:37

B0RemoteApi communication between two PCs

Post by jhyoon7579 »

Hi. I'm working on setting Coppeliasim with B0 remote api, connecting 2 different PCs(Windows 11, server running with CoppeliaSim / Ubuntu 20.04, client running with C++) with TCP connections.

I'm struggling on constructor part of B0RemoteApi (C++) with Ubuntu part. My code works fine when I start my server and client on Ubunut at the same time. But when I start server on Windows 11 (set environmental path "B0_HOST_ID=localhost") and run client on Ubuntu (set environmental path "B0_RESOLVER=tcp://my_server_ip:22000"), it stops at constructor part of client application. I follows the step for 2 PCs communication on the following link, https://forum.coppeliarobotics.com/viewtopic.php?t=8258.

I debugged and found out that problem pops out when constructor for b0RemoteApi calls "b0_service_client_call" function, which is part of b0 library source provided by CoppeliaSim. When client program works fine, it returns some none NULL data. But in my troubled situation, it returns NULL value. I want to figure out what happens inside the function, but I couldn't because it is only provided within .so file.

Please hope I can get some help.

P.S. (minor) When I run same program with sudo option on two PCs environment provides another error, b0_node_init at constructors. When program enters that function, it does not response at all even in debug mode.

fferri
Posts: 1216
Joined: 09 Sep 2013, 19:28

Re: B0RemoteApi communication between two PCs

Post by fferri »

Hi,

setting B0_HOST_ID to localhost doesn't make sense: B0_HOST_ID is the hostname (or IP) advertised to other nodes to reach this machine, so it has to be the LAN IP address, the external IP or hostname.

Btw, b0RemoteApi is deprecated.

ZeroMQ Remote API is the recommended way for remote API and it is easier to use.

jhyoon7579
Posts: 3
Joined: 25 Jul 2022, 01:37

Re: B0RemoteApi communication between two PCs

Post by jhyoon7579 »

Hi fferri, thanks for the reply.

Same problem occurs even when I changed B0_HOST_ID to my server LAN ip address.
In addition, on server side b0 resolver command prompt, node has been successfully joined and subscribing topic, connecting to service, and publishing on topic also work fine.

Also, I recognize that B0 has been deprecated, but my source code has already been set up with this.

fferri
Posts: 1216
Joined: 09 Sep 2013, 19:28

Re: B0RemoteApi communication between two PCs

Post by fferri »

Yes it is normal as publishers/subscribers don't directly talk to each other, but do so via the XPUB/XSUB proxies.

B0_HOST_ID must be set to the same machine's IP address or globally available hostname (NOT to the server IP address as you said you did).

This means on machine A you will set B0_HOST_ID to the IP address of machine A. On machine B you will set B0_HOST_ID to the IP address of machine B, and so on...

As bluezero is closely based on ZeroMQ, the migration from bluezero to ZeroMQ should be very easy: simply replace every b0 publisher/subscriber/client/server with a ZMQ socket of the corresponding type.

EDIT: About switching the remote API implementation, i.e. from b0RemoteApi to zmqRemoteApi, it should be even more straightforward, as zmqRemoteApi is the simplest to use.

jhyoon7579
Posts: 3
Joined: 25 Jul 2022, 01:37

Re: B0RemoteApi communication between two PCs

Post by jhyoon7579 »

Thanks fferri, I solved the problem.

I set PC A's B0_HOST_ID as PC A's ip address and PC B's B0_HOST_ID as PC B's ip address.
Then I set additional environmental variable of PC B, which is a client, B0_RESOLVER as "tcp://PC_A's_ip:22000".

It works. Thanks for your comments.

Post Reply