The function getObjectsInTree does not find script objects in CoppeliaSim v4.7.0-rev0

Report crashes, strange behaviour, or apparent bugs
Post Reply
Juancho
Posts: 17
Joined: 11 Jun 2018, 03:14

The function getObjectsInTree does not find script objects in CoppeliaSim v4.7.0-rev0

Post by Juancho »

Hi there!

I'm trying to get the scripts objects in a tree using the function "getObjectsInTree" using CoppeliaSim v4.7.0-rev0. However, it looks like the function is not working.

(There is a default Panda manipulator on the scene, which includes an object script in "Franka/Script".)

Code: Select all

#include "RemoteAPIClient.h"
#include <iostream>


int main()
{
    RemoteAPIClient client;
    auto sim = client.getObject().sim();
    try
    {
        sim.startSimulation();
        auto handle = sim.getObject("/Franka");
        std::vector<int64_t> scripthandles = sim.getObjectsInTree(handle,
                                                                sim.appobj_script_type,
                                                                0);
        std::cout<<"Number of scripts: "<<scripthandles.size()<<std::endl;
        sim.stopSimulation();

    }
    catch (const std::runtime_error& e)
    {
        std::cerr << "Caught a runtime error: " << e.what() << std::endl;
        sim.stopSimulation();
    }

    return 0;
}
Output:

Code: Select all

Number of scripts: 0
Expected:

Code: Select all

Number of scripts: 1
Thank you in advance,

Best regards,

Juan

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

Re: The function getObjectsInTree does not find script objects in CoppeliaSim v4.7.0-rev0

Post by coppelia »

Hello Juan,

the second argument is wrong, you should use sim.object_script_type instead, e.g.:

Code: Select all

sim.getObjectsInTree(handle, sim.object_script_type, 0)
Cheers

Juancho
Posts: 17
Joined: 11 Jun 2018, 03:14

Re: The function getObjectsInTree does not find script objects in CoppeliaSim v4.7.0-rev0

Post by Juancho »

Thank you for your reply.

The code is working now with the modifications you suggested.

Best regards,

Juan

PS:
The script object type is not included yet as a constant in the manual (https://manual.coppeliarobotics.com/en/ ... bjectTypes).

Image
https://ibb.co/dLmt7CL

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

Re: The function getObjectsInTree does not find script objects in CoppeliaSim v4.7.0-rev0

Post by coppelia »

You are right, thanks!

Cheers

Post Reply