bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.42k stars 2.86k forks source link

URDF cannot be loaded in C++ but it can in Python #4257

Closed aled96 closed 2 years ago

aled96 commented 2 years ago

Hi,

I was using PyBullet to perform a simulation with a robot (from URDF) and everything was working. I decided to move to C++ since it is faster, but the same URDF cannot be loaded. The process dies as soon as I call loadURDF.

This is the code:

    _sim = new b3RobotSimulatorClientAPI_NoGUI();

    bool isConnected = _sim->connect(eCONNECT_SHARED_MEMORY);

    if (!isConnected){
        ROS_WARN("Using Direct mode\n");
        isConnected = _sim->connect(eCONNECT_DIRECT);
    }
    else
        ROS_WARN("Using shared memory\n");

    _sim->resetSimulation();
    _sim->setGravity(btVector3(0, 0, -9.81));

    _sim->setRealTimeSimulation(_realtime);

    _sim->setTimeStep(_time_step);

    b3RobotSimulatorSetPhysicsEngineParameters params;
    params.m_numSolverIterations = _solver_it;
    params.m_numSimulationSubSteps = _sub_steps;

    _sim->setPhysicsEngineParameter(params);

    b3RobotSimulatorLoadUrdfFileArgs robotParams;
    robotParams.m_startPosition = btVector3(_init_pos[0], _init_pos[1], _init_pos[2]);
    robotParams.m_startOrientation = btQuaternion(0,0,0,1);

    ROS_WARN("Load Robot");
    _robot = _sim->loadURDF(robot_path, robotParams);

In addition, if I try to move to the GUI version, using b3RobotSimulatorClientAPI.h I am not able to compile because it is not installed....

erwincoumans commented 2 years ago

Are the files in the current working directory? We can't support C++ use, you'll have to figure this out yourself or use Python.