Gazebo ignores self collide and gravity in urdf
Hello,
I am running ROS Noetic with Gazebo 11.11.0 (Ubuntu Focal) and trying to turn off gravity and self-collision on a few links. I tried both of these variations:
<!-- given upperarm_actuator_body_link is a <link> in URDF -->
<gazebo reference="upperarm_actuator_body_link">
<gravity>false</gravity>
<self_collide>false</self_collide>
</gazebo>
<!-- given upperarm_actuator_body_link is a <link> in URDF -->
<gazebo reference="upperarm_actuator_body_link">
<turnGravityOff>true</turnGravityOff>
<selfCollide>false</selfCollide>
</gazebo>
Also tried the same thing with 0
and 1
instead of True
and False
.
Gazebo doesn't recognize it. In the inspector pane selecting the link shows self collide "False" is unchecked, and gravity "True" is checked.
Full URDF: https://github.com/01binary/str1ker/blob/master/description/robot.urdf
If you want to clone & run "roslaunch str1ker gazebo.launch" and preview behavior, all the stuff is in "description" folder: https://github.com/01binary/str1ker/
This is all documented and there are examples of both variations on GitHub. Are you seeing the same thing or do I file a Gazebo bug and start trying to debug it?
[EDIT]
Found the source code, it appears to be correct at first glance, looks like I have to debug & create a pull request. If it looks correct but doesn't work, then it must be broken.
https://github.com/gazebosim/sdformat/blob/sdf13/src/parser_urdf.cc
// parser_urdf.cpp line 1382
else if (strcmp(childElem->Name(), "turnGravityOff") == 0)
{
std::string valueStr = GetKeyValueAsString(childElem);
sdf->isGravity = true;
// default of gravity is true
if (lowerStr(valueStr) == "false" || lowerStr(valueStr) == "no" ||
valueStr == "0")
{
sdf->gravity = true;
}
else
{
sdf->gravity = false;
}
}
// parser_urdf.cc line 1437
else if (strcmp(childElem->Name(), "selfCollide") == 0)
{
sdf->isSelfCollide = true;
std::string valueStr = GetKeyValueAsString(childElem);
// default of selfCollide is false
if (lowerStr(valueStr) == "true" || lowerStr(valueStr) == "yes" ||
valueStr == "1")
{
sdf->selfCollide = true;
}
else
{
sdf->selfCollide = false;
}
}
Asked by Val on 2023-07-27 10:24:41 UTC
Answers
After building sdformat from source and debugging, I noticed that it was actually working: the changes were not very well communicated.
The property panel said either true or false, depending on the value of the setting in the file, but also had a checkbox.
I expected that the checkbox would be checked or unchecked depending on the value specified for these two settings, but the checkbox is always unchecked, and the value displayed changes between true and false.
Asked by Val on 2023-08-04 09:43:25 UTC
Comments
This issue looks related, and is still open: https://github.com/gazebosim/sdformat/issues/71 (but I'm no longer sure which git repo has the source code for gazebo11.)
This comment indicates some kind of patch went in around Aug 2021.
Asked by Mike Scheutzow on 2023-07-29 08:02:19 UTC