URDF importing correctly on one machine, incorrectly on another. Same code.
Posted: Tue Oct 10, 2023 10:04 am
Hi everyone,
I'm having a strange bug where my code works fine on one machine (Machine A), but on another (Machine B) Bullet fails to load the URDF file correctly. However, when the URDF file is loaded incorrectly it doesn't return a negative ID or throw any errors, it just responds to subsequent calls involving the file incorrectly.
The following is a minimal example that recreates the problem on my two machines:
On both machines this code compiles and runs without errors. On Machine A this prints:
which is correct. Machine B prints:
which is incorrect.
Can anyone advise on why this might be? The URDF file is identical and both machines are running this release of bullet.
The only difference I can think of is that Machine A is running Ubuntu 18.04, but Machine B is running Ubuntu 20.04. Though I'm unsure why that would cause this problem.
If anyone has any advice on what I could try to solve this problem or to learn more i'd be very thankful!
Additional tests described below:
First i wanted to check if it was something to do with my URDF file, so I tried it with the humanoid.urdf file from the data directory (which I moved to basics/models for consistency) . On machine A i got:
Whereas on machine B i got:
Which implies to me that this issue isn't being caused by my URDF file
As a further test, if I use the Python library urdfpy to load the same file it works fine and correctly identifies the links on both machines. I use this code:
And it correctly prints out the names of the 24 joints and then correctly visualises the robot on both machine A and machine B.
I'm having a strange bug where my code works fine on one machine (Machine A), but on another (Machine B) Bullet fails to load the URDF file correctly. However, when the URDF file is loaded incorrectly it doesn't return a negative ID or throw any errors, it just responds to subsequent calls involving the file incorrectly.
The following is a minimal example that recreates the problem on my two machines:
Code: Select all
#include <b3RobotSimulatorClientAPI_NoGUI.h>
#include <btBulletDynamicsCommon.h>
#include <iostream>
using namespace std;
int minimal_recreation(){
b3RobotSimulatorClientAPI_NoGUI* sim = new b3RobotSimulatorClientAPI_NoGUI();
bool isConnected = sim->connect(eCONNECT_SHARED_MEMORY);
if (!isConnected)
{
cout<<"Using direct mode"<<endl;
isConnected = sim->connect(eCONNECT_DIRECT);
}
else
{
cout<<"Using shared memory"<<endl;
}
sim->resetSimulation();
sim->setGravity(btVector3(0, 0, -9.8));
sim->setNumSolverIterations(100);
b3RobotSimulatorSetPhysicsEngineParameters args;
sim->getPhysicsEngineParameters(args);
const char* corin_path="basics/models/Drake_Corin.urdf";
int CorinId = sim->loadURDF(corin_path);
cout<<"loading corin with ID "<<CorinId<<" and path "<<corin_path<<endl;
int numJoints=sim->getNumJoints(CorinId);
cout<<" corin has "<<numJoints<<" joints"<<endl;
return 0;
}
Code: Select all
Using direct mode
loading corin with ID 0 and path basics/models/Drake_Corin.urdf
corin has 24 joints
Code: Select all
Using direct mode
loading corin with ID 0 and path basics/models/Drake_Corin.urdf
corin has 0 joints
Can anyone advise on why this might be? The URDF file is identical and both machines are running this release of bullet.
The only difference I can think of is that Machine A is running Ubuntu 18.04, but Machine B is running Ubuntu 20.04. Though I'm unsure why that would cause this problem.
If anyone has any advice on what I could try to solve this problem or to learn more i'd be very thankful!
Additional tests described below:
First i wanted to check if it was something to do with my URDF file, so I tried it with the humanoid.urdf file from the data directory (which I moved to basics/models for consistency) . On machine A i got:
Code: Select all
Using direct mode
loading robot with ID 0 and path basics/models/humanoid.urdf
robot has 33 joints
Code: Select all
Using direct mode
loading robot with ID 0 and path basics/models/humanoid.urdf
robot has 0 joints
As a further test, if I use the Python library urdfpy to load the same file it works fine and correctly identifies the links on both machines. I use this code:
Code: Select all
from urdfpy import URDF
robot=URDF.load('basics/models/Drake_Corin.urdf')
for joint in robot.joints:
print(joint.name)
robot.show()