Page 1 of 1

ZeroMQ Remote API with getContactInfo() C++ Bug

Posted: 30 Oct 2023, 00:32
by CroCr
Take a look at this c++ code,

Code: Select all

#include <iostream>
#include <vector>
#include <tuple>
#include <chrono>
#include <thread>

#include "RemoteAPIClient.h"
using namespace std;


int main(int, char**)
{
    RemoteAPIClient client;
    auto sim = client.getObject().sim();
    client.setStepping(true);
    sim.startSimulation();
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    auto CapsuleHandle = sim.getObject("./Capsule");
    auto data = sim.getContactInfo(0,CapsuleHandle,sim.handleflag_extended);

    while( sim.getSimulationState() != 0 )
    {
        client.step();
    }

    return 0;
}

I get this error

Code: Select all

terminate called after throwing an instance of 'jsoncons::json_runtime_error<std::out_of_range, void>'
  what():  Invalid array subscript
Aborted (core dumped)
The Capsule handle returns valid input (i.e. 60).

CoppeliaSim Edu, Version 4.5.1 (rev. 4) 64bit (serialization version 24). Ubuntu 18.04 LTS.

Re: ZeroMQ Remote API with getContactInfo() C++ Bug

Posted: 30 Oct 2023, 07:57
by coppelia
Hello,

you are correct. A workaround is to add following to line 2 in lua/sim.lua:

Code: Select all

_S.getContactInfo = sim.getContactInfo
function sim.getContactInfo(...)
    local a, b, c, d = _S.getContactInfo(...)
    if a == nil then
        a = {} b = {} c = {} d = {}
    end
    return a, b, c, d
end
Cheers

Re: ZeroMQ Remote API with getContactInfo() C++ Bug

Posted: 30 Oct 2023, 13:05
by CroCr
coppelia wrote: 30 Oct 2023, 07:57 Hello,

you are correct. A workaround is to add following to line 2 in lua/sim.lua:

Code: Select all

_S.getContactInfo = sim.getContactInfo
function sim.getContactInfo(...)
    local a, b, c, d = _S.getContactInfo(...)
    if a == nil then
        a = {} b = {} c = {} d = {}
    end
    return a, b, c, d
end
Cheers
I've placed it and i get this error

Code: Select all

terminate called after throwing an instance of 'jsoncons::conv_error'
  what():  Cannot convert to vector
Aborted (core dumped)

Re: ZeroMQ Remote API with getContactInfo() C++ Bug

Posted: 02 Nov 2023, 08:58
by coppelia
I cannot reproduce your error (at least on CoppeliaSim V4.6). At what stage exactly is the error produced?

Cheers

Re: ZeroMQ Remote API with getContactInfo() C++ Bug

Posted: 03 Nov 2023, 21:55
by CroCr
coppelia wrote: 02 Nov 2023, 08:58 I cannot reproduce your error (at least on CoppeliaSim V4.6). At what stage exactly is the error produced?

Cheers
I didn't understand your question. I'm running the exact C++ example above. You've advised to add some new lines to sim.lua. Adding the suggested lines yields another errors.