Page 1 of 1

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

Posted: 17 Jun 2024, 19:47
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

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

Posted: 18 Jun 2024, 05:55
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

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

Posted: 18 Jun 2024, 16:55
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

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

Posted: 19 Jun 2024, 08:08
by coppelia
You are right, thanks!

Cheers