ZeroMQ Remote API with getContactInfo() C++ Bug

Report crashes, strange behaviour, or apparent bugs
Post Reply
CroCr
Posts: 75
Joined: 29 Dec 2022, 01:47

ZeroMQ Remote API with getContactInfo() C++ Bug

Post 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.

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

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

Post 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

CroCr
Posts: 75
Joined: 29 Dec 2022, 01:47

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

Post 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)

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

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

Post by coppelia »

I cannot reproduce your error (at least on CoppeliaSim V4.6). At what stage exactly is the error produced?

Cheers

CroCr
Posts: 75
Joined: 29 Dec 2022, 01:47

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

Post 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.

Post Reply