b0 remote Api can't use in headless mode

Typically: "How do I... ", "How can I... " questions
Post Reply
cong.guo
Posts: 4
Joined: 12 Dec 2019, 14:04

b0 remote Api can't use in headless mode

Post by cong.guo »

ENV:
ubuntu 16.04
coppeliasim version: v4.0.0


STEPS:
I use b0-remote-Api (java) to subscribe a topic from coppeliasim.
And I build a scene(xxx.ttt) which have a b0RemoteApiServer in it.

1.
I run
./coppeliaSim.sh -s500000 -q xxx.ttt
my apk can communicate with simulation.

2.
I run
./coppeliaSim.sh -h -s500000 -q xxx.ttt
And I get
2020-01-02 15:56:07 [resolver] info: New node has joined: 'MirHardware'
2020-01-02 15:56:07 [resolver] info: Graph: node 'MirHardware' subscribes to topic 'b0RemoteApiPubX'
2020-01-02 15:56:07 [resolver] error: Failed to resolve service 'b0RemoteApiSerX'
2020-01-02 15:56:30 [resolver] info: Node 'MirHardware-1' disconnected due to timeout

3.
even I change simAddOnScript-b0RemoteApiServer.lua to simAddOnScript_b0RemoteApiServer.lua
I get the same error-log

I hope I can get some advices. Thanks

coppelia
Site Admin
Posts: 8067
Joined: 14 Dec 2012, 00:25

Re: b0 remote Api can't use in headless mode

Post by coppelia »

Hello,

yes, there is a problem when running in headless mode. You can fix this by replacing the code in lua/b0RemoteApiServer.lua around line 1013 with:

Code: Select all

            local ui
            if simUI then
                local xml = [[ <ui closeable="false" resizable="false" title="BlueZero" modal="true">
                        <label text="Looking for BlueZero resolver..." style="* {font-size: 20px; font-weight: bold; margin-left: 20px; margin-right: 20px;}"/>
                        <label text="This can take several seconds." style="* {font-size: 20px; font-weight: bold; margin-left: 20px; margin-right: 20px;}"/>
                        </ui> ]]
                ui=simUI.create(xml)
            end
            if not simB0.pingResolver() then
                sim.addStatusbarMessage("<font color='#070'>B0 Remote API: B0 resolver was not detected. Launching it from here...</font>@html")
                sim.launchExecutable('b0_resolver','',1)
            end
            if simUI then
                simUI.destroy(ui)
            end
This is because in headless mode, variable simUI does not exist (that for the custom UI plugin, which doesn't make sense in headless mode), and causes an error.

Cheers

cong.guo
Posts: 4
Joined: 12 Dec 2019, 14:04

Re: b0 remote Api can't use in headless mode

Post by cong.guo »

Thank you :)
It works fine for me.

Post Reply