ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Incorrect opening a urdf file in Gazebo

asked 2018-01-07 01:08:03 -0600

tooght gravatar image

updated 2018-01-11 06:05:30 -0600

Hi everyone. I created a .URDF from SolidWorks using SW2URDF plugin. This urdf file that I created, opens in rviz smoothly, however this urdf file opens in the gazebo incorrectly and the model file has missing links and joints.

moving joints have linkage and linkage joints(eg: wheel) but none for fixed joints(eg: lidar,realsense ..).

HOW CAN I SOLVE THE PROBLEM?

The first time I run the file gazebo.Launch is the model gazebo image(wrong):

image description

the image that appears when I reload the model after pressing the stop button on the lower toolbar: image description

(model reload command: rosrun gazebo_ros spawn_model -file rospack find car_design_full/urdf/car_design_full.urdf -urdf -z 0.1 -model my_object)

but the same mistakes still continue ( the model file has missing links and joints.)

Gazebo errors that occur when I edit the model file:
image description

Error [Param.hh:266] Unable to set parameter[velocity].Type type used must have a stream input and outputoperator, which allow boost::lexical_cast tofunction properly.
Error [Param.hh:266] Unable to set parameter[acceleration].Type type used must have a stream input and outputoperator, which allow boost::lexical_cast tofunction properly.
Error [Param.hh:266] Unable to set parameter[wrench].Type type used must have a stream input and outputoperator, which allow boost::lexical_cast tofunction properly.

log file: /home/ubuntu/.ros/log/952cd6c8-f367-11e7-a297-448a5bed66ea/spawn_urdf-4*.log:

[rospy.client][INFO] 2018-01-07 08:49:06,802: init_node, name[/spawn_urdf], pid[7183]
[xmlrpc][INFO] 2018-01-07 08:49:06,803: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2018-01-07 08:49:06,803: Started XML-RPC server [http://192.168.1.38:45182/]
[rospy.init][INFO] 2018-01-07 08:49:06,803: ROS Slave URI: [http://192.168.1.38:45182/]
[rospy.impl.masterslave][INFO] 2018-01-07 08:49:06,803: _ready: http://192.168.1.38:45182/
[xmlrpc][INFO] 2018-01-07 08:49:06,804: xml rpc node: starting XML-RPC server
[rospy.registration][INFO] 2018-01-07 08:49:06,804: Registering with master node http://192.168.1.38:11311
[rospy.init][INFO] 2018-01-07 08:49:06,903: registered with master
[rospy.rosout][INFO] 2018-01-07 08:49:06,904: initializing /rosout core topic
[rospy.rosout][INFO] 2018-01-07 08:49:06,905: connected to core topic /rosout
[rospy.simtime][INFO] 2018-01-07 08:49:06,906: initializing /clock core topic
[rospy.simtime][INFO] 2018-01-07 08:49:06,907: connected to core topic /clock
[rosout][INFO] 2018-01-07 08:49:06,909: Loading model xml from file
[rosout][INFO] 2018-01-07 08:49:06,910: Waiting for service /gazebo/spawn_urdf_model
[rospy.internal][INFO] 2018-01-07 08:49:07,177: topic[/rosout] adding connection to [/rosout], count 0
[rospy.internal][INFO] 2018-01-07 08:49:08,982: topic[/clock] adding connection to [http://192.168.1.38:34827/], count 0
[rosout][INFO] 2018-01-07 08:49:09,020: Calling service /gazebo/spawn_urdf_model
[rosout][INFO] 2018-01-07 08:49:09,327: Spawn status: SpawnModel: Successfully spawned model
[rospy.core][INFO] 2018-01-07 08:49:09,327: signal_shutdown [atexit]
[rospy.internal][INFO] 2018-01-07 08:49:09,329: topic[/rosout] removing connection to ...
(more)
edit retag flag offensive close merge delete

Comments

Welcome! Can you please update your question with a copy and paste of the error that Gazebo is giving you as opposed to linking to a screenshot? Text is searchable, images are not.

jayess gravatar image jayess  ( 2018-01-07 03:34:22 -0600 )edit

In addition to that: I've given you enough karma to embed all your images in your post. Could you please do that?

gvdhoorn gravatar image gvdhoorn  ( 2018-01-07 05:11:18 -0600 )edit

Mr. @jayess I prepared my question. Could you please look at my problem now ?

tooght gravatar image tooght  ( 2018-01-07 05:22:41 -0600 )edit

Again, please copy and paste the error. Text is searchable images are not.

jayess gravatar image jayess  ( 2018-01-07 12:26:33 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
3

answered 2018-01-08 10:33:59 -0600

RDaneelOlivaw gravatar image

updated 2018-01-08 10:35:26 -0600

One of the issues you have, the one that make the model appear collapsed is due to errors in the inertial values. For some reason, when the inertias are not correct , as soon as the model touches the ground and you exert some kind of force in the continuous joints of the wheels, they break and appear in the origin of the model.

You can test this by spawning the model in a zero gravity environment and it won't break any joint. I've made a full video tutorial talking about the issue and explaining how to recalculate your inertal values, at least for basic geometric shapes. Here is the VIDEO ]

Here you have some images of the differences in the inertias for a simple base_link and a wheel:

Colapsed due to wrong Inertias

Bad Inertias Simple

Same urdf except that it has recalculated inertias

Good Inertias Simple

Here I leave a geometric version of your URDF that works and the launch files and python code I used to do this. If you can upload the stl I could update this answer with the complete model as well as maybe add the control.

Inertia Calculator:

#!/usr/bin/env python
"""
Made by TheConstructSim
You can use this script as you please
"""

import math


class InertialCalculator(object):

    def __init__(self):
        print "InertialCaluclator Initialised..."

    def start_ask_loop(self):

        selection = "START"

        while selection != "Q":
            print "#############################"
            print "Select Geometry to Calculate:"
            print "[1]Box width(w)*depth(d)*height(h)"
            print "[2]Sphere radius(r)"
            print "[3]Cylinder radius(r)*height(h)"
            print "[Q]END program"
            selection = raw_input(">>")
            self.select_action(selection)

        print "InertialCaluclator Quit...Thank you"

    def select_action(self, selection):
        if selection == "1":
            mass = float(raw_input("mass>>"))
            width = float(raw_input("width>>"))
            depth = float(raw_input("depth>>"))
            height = float(raw_input("height>>"))
            self.calculate_box_inertia(m=mass, w=width, d=depth, h=height)
        elif selection == "2":
            mass = float(raw_input("mass>>"))
            radius = float(raw_input("radius>>"))
            self.calculate_sphere_inertia(m=mass, r=radius)
        elif selection == "3":
            mass = float(raw_input("mass>>"))
            radius = float(raw_input("radius>>"))
            height = float(raw_input("height>>"))
            self.calculate_cylinder_inertia(m=mass, r=radius, h=height)
        elif selection == "Q":
            print "Selected Quit"
        else:
            print "Usage: Select one of the give options"


    def calculate_box_inertia(self, m, w, d, h):
        Iw = (m/12.0)*(pow(d,2)+pow(h,2))
        Id = (m / 12.0) * (pow(w, 2) + pow(h, 2))
        Ih = (m / 12.0) * (pow(w, 2) + pow(d, 2))
        print "BOX w*d*h, Iw = "+str(Iw)+",Id = "+str(Id)+",Ih = "+str(Ih)

    def calculate_sphere_inertia(self, m, r):
        I = (2*m*pow(r,2))/5.0
        print "SPHERE Ix,y,z = "+str(I)

    def calculate_cylinder_inertia(self, m, r, h):
        Ix = (m/12.0)*(3*pow(r,2)+pow(h,2))
        Iy = Ix
        Iz = (m*pow(r,2))/2.0
        print "Cylinder Ix,y = "+str(Ix)+",Iz = "+str(Iz)

if __name__ == "__main__":
    inertial_object = InertialCalculator()
    inertial_object.start_ask_loop()

car_design_full_geometric_fixed_physics.urdf

<?xml version="1.0"?>
<robot name="car_design_full">  
<material name="material_base_link">
    <color rgba="0.929411765 0.619607843 0.149019608 1"/>
</material>    
<material name="material_sensors">
    <color rgba="0.792156862745098 0.819607843137255 0.933333333333333 1 ...
(more)
edit flag offensive delete link more

Comments

Hi.@RDaneelOlivaw Thank you so much. I have tried the suggestion that you have given, as I reached the maximum length of comments, I could not write a comment. I add below as an answer.

tooght gravatar image tooght  ( 2018-01-08 15:17:03 -0600 )edit

What I'm saying is to update your question instead of using an answer. This isn't a forum.

jayess gravatar image jayess  ( 2018-01-08 15:49:04 -0600 )edit

Hi,@RDaneelOlivaw ,I have same error(gazebo model collapse) to display our soldiworks model in gazebo,and i also try your method ,i change our inertia value in our urdf, futhermore we use meshlab to caculate our model inertia.Could you help me to see this problem?Thank you very much

regenyue gravatar image regenyue  ( 2019-04-17 04:14:20 -0600 )edit

Could you share the code in someway? Its really difficult to help you without enough information

RDaneelOlivaw gravatar image RDaneelOlivaw  ( 2019-04-23 14:08:07 -0600 )edit
2

answered 2018-01-07 11:42:54 -0600

clyde gravatar image

updated 2018-01-07 11:45:43 -0600

The URDF to SDF conversion removes all fixed joints. One workaround is to replace fixed joints with revolute joints with 0 limits. I suggest using gzsdf to see the results of the URDF to SDF conversion, you'll find instructions here: http://gazebosim.org/tutorials?tut=ro...

Take a look at previous questions, such as: https://answers.ros.org/question/1067...

edit flag offensive delete link more

Comments

thank you @clyde. I will try your suggestions.

tooght gravatar image tooght  ( 2018-01-08 15:39:21 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2018-01-07 01:07:10 -0600

Seen: 2,760 times

Last updated: Jan 11 '18