Hello Professor Hauser,
I have a problem where running my code in Python 3 gives me a segmentation fault but running my code using Python 2 works fine. Based on some debugging, it appears that the error occurs when reading the URDF file. Here is my code (which I have greatly simplified to try and figure out this issue), URDF file, and the error I get (using faulthandler).
Python Code:
import faulthandler
import klampt
FILEPATH = "./agrobot_sim.xml"
if __name__ == "__main__":
faulthandler.enable()
world = klampt.WorldModel()
print("got world")
res = world.readFile(FILEPATH)
print("read file")
robot = world.robot(0)
URDF:
<?xml version="1.0" encoding="utf-8"?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from robot_controlsim_v2.xacro | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<robot name="ranch_rover">
<!-- First link of the robot. Corresponds to the robot main frame. -->
<link name="link_chassis">
<pose> 0 0 0 0 0 0 </pose>
<inertial>
<mass value="24.5"/>
<origin rpy="0 0 0" xyz="0.0052 -0.0009 0.0050"/>
<inertia ixx="0.729" ixy="0.0029" ixz="-0.0160" iyx="0.0029" iyy="0.4254" iyz="0.0028" izx="-0.0160" izy="0.0028" izz="1.008"/>
</inertial>
<collision>
<geometry>
<mesh filename="agrobot/link_chassis.STL" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
</collision>
<visual name="vis1">
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/link_chassis.STL" scale="0.001 0.001 0.001"/>
</geometry>
</visual>
</link>
<!-- LINK_1 -->
<link name="Link_1">
<inertial>
<origin rpy="0 0 0" xyz="2.74225442931497E-06 -0.00353778613018245 0.0515804512927737"/>
<mass value="0.507852532624306"/>
<inertia ixx="0.000305049101665729" ixy="1.46296943748327E-09" ixz="-1.23302173450347E-08" iyy="0.000527056723286848" iyz="4.68473207349431E-06" izz="0.000309137354236652"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_1.STL"/>
</geometry>
<material name="">
<color rgba="0.752941176470588 0.752941176470588 0.752941176470588 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_1.STL"/>
</geometry>
</collision>
</link>
<joint name="Joint_1" type="revolute">
<origin rpy="0 0 0" xyz="0.190 -0.033 0.196"/>
<parent link="link_chassis"/>
<child link="Link_1"/>
<axis xyz="0 0 1"/>
<limit effort="17" lower="-3.1415" upper="3.1415" velocity="40"/>
<dynamics damping="0.0" friction="0.09"/>
</joint>
<transmission name="trans_Joint_1">
<type>transmission_interface/SimpleTransmission</type>
<joint name="Joint_1">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="motor_Joint_1">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<!-- LINK_2 -->
<link name="Link_2">
<inertial>
<origin rpy="0 0 0" xyz="0.058405779904307 2.0203040740352E-08 0.0339456863545732"/>
<mass value="0.81308899959476"/>
<inertia ixx="0.000388392439322651" ixy="-9.54214032854378E-10" ixz="1.27795112061735E-05" iyy="0.00467218660610504" iyz="-8.84832562194152E-11" izz="0.00496730197895087"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_2.STL"/>
</geometry>
<material name="">
<color rgba="0.752941176470588 0.752941176470588 0.752941176470588 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_2.STL"/>
</geometry>
</collision>
</link>
<joint name="Joint_2" type="revolute">
<origin rpy="-1.5707963267949 0 3.14159265358979" xyz="0 -0.019 0.0545"/>
<parent link="Link_1"/>
<child link="Link_2"/>
<axis xyz="0 0 1"/>
<limit effort="17" lower="-3.1415" upper="0" velocity="40"/>
<dynamics damping="0.0" friction="0.09"/>
</joint>
<transmission name="trans_Joint_2">
<type>transmission_interface/SimpleTransmission</type>
<joint name="Joint_2">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="motor_Joint_2">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<!-- LINK_3 -->
<link name="Link_3">
<inertial>
<origin rpy="0 0 0" xyz="0.232598222729073 -9.20818372995846E-07 -0.00955342978657184"/>
<mass value="0.336944931620173"/>
<inertia ixx="3.67648841212008E-05" ixy="-9.59389619481419E-11" ixz="-1.81657115526022E-06" iyy="0.00138520509069701" iyz="2.76629218451524E-12" izz="0.00140450563412969"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_3.STL"/>
</geometry>
<material name="">
<color rgba="0.752941176470588 0.752941176470588 0.752941176470588 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_3.STL"/>
</geometry>
</collision>
</link>
<joint name="Joint_3" type="revolute">
<origin rpy="0 0 -1.5708" xyz="0.352 0 0.05275"/>
<parent link="Link_2"/>
<child link="Link_3"/>
<axis xyz="0 0 1"/>
<limit effort="17" lower="-1.0472" upper="2.6" velocity="40"/>
<dynamics damping="0.0" friction="0.09"/>
</joint>
<transmission name="trans_Joint_3">
<type>transmission_interface/SimpleTransmission</type>
<joint name="Joint_3">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="motor_Joint_3">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<!-- LINK_4 -->
<link name="Link_4">
<inertial>
<origin rpy="0 0 0" xyz="0.0322792079054944 0.0215434702240224 1.30818635455249E-05"/>
<mass value="0.213921465907275"/>
<inertia ixx="5.72875335800106E-05" ixy="-2.1737619349779E-09" ixz="-2.22685486617804E-08" iyy="2.96741933821847E-05" iyz="1.83334792134304E-09" izz="6.54238610234211E-05"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_4.STL"/>
</geometry>
<material name="">
<color rgba="0.752941176470588 0.752941176470588 0.752941176470588 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="agrobot/Link_4.STL"/>
</geometry>
</collision>
</link>
<joint name="Joint_4" type="revolute">
<origin rpy="0 0 0" xyz="0.32 0 0"/>
<parent link="Link_3"/>
<child link="Link_4"/>
<axis xyz="0 0 1"/>
<limit effort="2.268" lower="-1.571" upper="1.571" velocity="0.319"/>
<dynamics damping="0.0" friction="0.09"/>
</joint>
<transmission name="trans_Joint_4">
<type>transmission_interface/SimpleTransmission</type>
<joint name="Joint_4">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="motor_Joint_4">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
</robot>
Error:
I'm fairly new to coding and have been trying to debug this for quite some time now. I need to use Python 3 because I will be using other libraries that are only compatible with Python 3. Do you know what the issue might be? If not, would you happen to have any recommendations on debugging this?
Please let me know if you need any more information. Thank you!
Sincerely,
Ryan