[Research] Can we write a script to load an SDF in Drake?

Issue #80 resolved
Andrés Fortier created an issue

A basic program that takes a path with an SDF file and loads it into the Drake visualizer.

02/03/2017 - SP2

Comments (23)

  1. Agustin Alba Chicar

    I got a sample project inside Drake's repository structure at the same level of automotive sample. Also, I included a model like the sample box in the box plugin. From this script, which loads the complete demo, I could only try to load drake_visualizer and then my application but I got no model visualized neither recognized by the visualizer. At this moment what I could get is the following:

    • You have this class structure: systems::System <--systems::LeafSystem <-- autormotive::SimpleCar which manages the car states through time. I had a child of LeafSystem with an empty implementation of the methods.
    • systems::DiagramBuilder class can add Systems to your simulation. You have to add at least one system and then build them. Once you build it, you get a systems::Diagram which is necessary to get a systems::Simulator. This last class is the one that manages the complete simulation process.

    Also, I tried the sdf samples and I got this output console:

    [2017-02-06 14:34:10.426] [console] [info] Adding joint chassis_floor_axle to the plant.
    [2017-02-06 14:34:10.426] [console] [info] Adding joint steering to the plant.
    [2017-02-06 14:34:10.426] [console] [info] Adding joint left_hub to the plant.
    [2017-02-06 14:34:10.426] [console] [info] Adding joint left_pin to the plant.
    [2017-02-06 14:34:10.426] [console] [info] Adding joint left_wheel_joint to the plant.
    [2017-02-06 14:34:10.426] [console] [info] Adding joint axle_tie_rod_arm to the plant.
    [2017-02-06 14:34:10.426] [console] [info] Adding joint right_hub to the plant.
    [2017-02-06 14:34:10.427] [console] [info] Made joint right_pin a loop joint.
    [2017-02-06 14:34:10.427] [console] [info] Adding joint right_wheel_joint to the plant.
    [2017-02-06 14:34:10.427] [console] [info] Adding joint chassis_rear_axle to the plant.
    [2017-02-06 14:34:10.427] [console] [info] Adding joint rear_left_wheel_joint to the plant.
    [2017-02-06 14:34:10.427] [console] [info] Adding joint rear_right_wheel_joint to the plant.
    [2017-02-06 14:34:10.427] [console] [info] Adding joint body to the plant.
    

    I guess I'm on the way. I'll take a deeper look in the sample trying to complete the code a bit more to get something visualized.

  2. Agustin Alba Chicar

    Got a box loaded into Drake but the program fails with a Segmentation fault (core dumped). We need further development on this.

    BoxInDrakw!.png

  3. Agustin Alba Chicar

    Further research show that when calling simulator->Initialize() method the program breaks. I tried to catch any exceptions but got no luck with it.

  4. Agustin Alba Chicar

    Got a sample box inside Drake without breaking the program. In this branch, I have created a sample project that does the trick.

    Here are instructions to build and to run the simulation. Also, a bug came up when working with this which was reported here.

  5. Agustin Alba Chicar

    Using darpa_box.world I could get the following:

    darpa_box_sample.png

    Just two minor modifications were made to the world file:

    1. Removed the plugin node
    2. Changed the file extension from ".world" to ".sdf" due to Drake's support.

    There are some rotated boxes, but this should be easily solved.

  6. Agustin Alba Chicar

    I have tested some variations of the mesh, with obj and dae formats and both fail with the following:

    ERROR: In /build/buildd/vtk-5.8.0/IO/vtkOBJReader.cxx, line 192
    vtkOBJReader (0x32d1b70): Error reading 'v' at line 1
    
    ERROR: In /build/buildd/vtk-5.8.0/Graphics/vtkTransformPolyDataFilter.cxx, line 84
    vtkTransformPolyDataFilter (0x32d42c0): No input data
    
    ERROR: In /build/buildd/vtk-5.8.0/IO/vtkOBJReader.cxx, line 192
    vtkOBJReader (0x32d38a0): Error reading 'v' at line 1
    
    ERROR: In /build/buildd/vtk-5.8.0/Graphics/vtkTransformPolyDataFilter.cxx, line 84
    vtkTransformPolyDataFilter (0x32ded10): No input data
    

    I'll need to dive into the examples a bit more to see the differences in code and in the sdf/urdf files.

  7. Agustin Alba Chicar

    Some tests yesterday ended up in the following:

    • VTK is the rendering engine of Drake
    • We can do the following: drake_visualizer --> File --> Open data and open a obj file. This is totally valid.
    • VTK uses the locale numeric configuration. So the floating point separator depends on LC_NUMERIC value in your environment. For example, if it is es_AR.UTF-8, the separator will be a ' , ', but if it is C the separator will be ' . '. So files generated with different locales probably will fail due to the env configuration of the system at the running time.
  8. Andrés Fortier reporter

    Ahh, nice catch! I was seeing that error too! Just form the top of my head, how about running with $ LC_ALL=C drake-visualizer?

  9. Agustin Alba Chicar

    In fact it was on of the Drake's developer that realized of that. And your suggestion works perfectly!

  10. Agustin Alba Chicar

    Matthew Woehlke, one of the Drake's developers, posted an issue in VTK repository after some tests with bare code from VTK (using a Python console that the project provides). We found there that VTK Python console overrides the locale configuration, so you won't get that error with ',' floating point separator. Here is the link --> https://gitlab.kitware.com/vtk/vtk/issues/16981

    From C++ code, VTK uses the current locale, so it will adapt to the environment.

  11. Log in to comment