Open hwiedPro opened 1 year ago
Will close this during further researching this topic and reopen later.
I elaborated a bit more and therefore reopen
@hwiedPro With the dae loading there were three issues:
for your example model, the prefix path was not set correctly in the mars: fixed https://github.com/rock-simulation/mars/commit/df130a59b8c064adb7f71a669e574c5e62641dd6
the segmentation failt comes since the mars can not create geode for some reason: fixed, now we have no segmentation failt, but proper error message https://github.com/rock-simulation/mars/commit/43356fdc19d038c80491805a7f95ca0ede8c740f
we still can not load the dae for some reason, but mars does not crash anymore: need to inverstigate why we can not load dae format
also added for any case that we can have dae folder in smurf model to store the meshes, same is done for stl and obj https://github.com/rock-simulation/mars/commit/5dc81040c799f876d36191acaf9273e1a09dab1d
STL Issue:
Obj Issue:
NOTE: please be carefully to merge loading branch into devel, since the current models will be not loaded properly
Regarding the OBJ Export, please checkout the ReaderWriter::Options for ReaderWriterOBJ: https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgPlugins/obj/ReaderWriterOBJ.cpp#L61 used here: https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgPlugins/obj/ReaderWriterOBJ.cpp#L204
This is exactly the rotation we need to apply to the obj files e.g. in phobos to later import them correctly with the current verion in MARS.
See https://codedocs.xyz/openscenegraph/OpenSceneGraph/a01746.html#a2304aa40f119d6a0d852f7b709be6e74
ToDo: Review the mesh import to MARS
Obj mesh orientations are interpreted not consistently, I guess this comes from the old default how they were exported from blender by default.
I had a look on the behaviour of pyBullet, Gazebo, rock-roboviz and MARS using the doc/a test model; and also into the mesh formats.
This I will explain deeper in the following.
As described below the most simulators and mesh formats are consistent, I suggest the following that MARS should be adapted to interpret obj (bobj), stl and dae accordingly.
Test data
I created the mesh above in blender to identify the axes when loaded. (Color coding: RGB = XYZ)The length and points of the arms display the axis by their length and vertices at their end: x=1, y=2, z=3
This mesh is included in the following URDF:
The mesh I exchanged vs their DAE/STL/OBj version during testing.
Mesh formats
STL
STL saves vertices in the following format:
When using the convention Z is Up and Y is Forward, the STL base frame has the same orientation as intended by the mesh. See the format example which shows a face that was created with vertices on all axis with different distances from the origin: x = 1 y =2 z =3.
Wavefront OBJ
OBJ saves vertices in the following format:
Equally to STL the OBJ origin is the same as the origin during creation when using the export convention Z is Up and Y is Forward.
Collada DAE
In DAE vertices are saved in the following format:
Again DAE uses the same origin as STL and OBJ.
Expectation
As URDF gives transformations from root->link->mesh the orientation of the mesh is clearly defined. I'd expect that the mesh will placed accordingly. As the test URDF, presented above, has only zero transformations and the mesh is oriented in all tested mesh formats without any orientation, I'd expect that in all simulators the X-arm of the mesh will point in X-direction, Y-arm in Y-direction and Z-arm in Z-direction.
Testing the simulators
pyBullet
PyBullet fulfils the expectation for all formats.
MARS
In the images X is pointing in to the right, Y up and Z into the screen. MARS fulfils the expectation for STL and DAE, but obj seems to be loaded differently. Here showing only the visual representation.
Further bugs STL collisions #98
Please note that MARS seems to load STL Meshes also differently depending on whether the mesh is loaded as visual or collision (see also #98). I reproduced this issue
I also tested MARS with the collisions. ![mars_stl](https://user-images.githubusercontent.com/35524093/216558919-696b4035-c45b-4a9f-b4b6-244d89f47527.png)DAE Collisions
Loading the URDF with DAE as a collision mesh was not possible and threw a segmentation fault.
```bash gdb --args mars_app -s mesh_orientation_tester.urdf ``` returned: ``` Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Gtk-Message: 10:14:15.389: Failed to load module "canberra-gtk-module" Active locale (LC_ALL): [OK] config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/mars_Preferences.yaml MARS::loadCoreLibs: Loading default core libraries... info: Simulator: no console loaded. output to stdout! EntityFactory: registering factory for type 'smurf'. EntityFactory: registering factory for type 'urdf'. EntityFactory: registering factory for type 'particle'. info: smurf_loader: added SMURF loader to loadCenter config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/configWindows.yml osg_frames: load ${AUTOPROJ_CURRENT_ROOT}/install/simulation/mars/common/graphics/osg_frames/share/osg_frames/resources/frame.obj config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/mars_Gui.yaml config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/mars_Graphics.yaml retina scale: 1 [New Thread 0x7fffdb4e9700 (LWP 14170)] [New Thread 0x7fffdacd8700 (LWP 14171)] initialized postDrawCallback set use shader: 1 1 MARS::loadAdditionalLibs: Loading default additional libraries... info: Simulator: console loaded. stop output to stdout! ERROR: could not find SpaceMouse! Do you have read permission on the /dev/input/ device? lib_manager - NOTIFICATION (concerning optional library): libPythonMars.so: cannot open shared object file: No such file or directory config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/DataBrokerPlotter.yaml config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/mars_Simulator.yaml config file not found: ${AUTOPROJ_CURRENT_ROOT}/install/configuration/mars_default/mars_Physics.yaml SMURFLoader::loadFile: file_extension=.urdf Reading in ./mesh_orientation_tester.urdf... Creating 1 simulation entities... Loading Entity of type urdf. SMURF::createEntity: Creating entity of type urdf ...loading urdf data from ./mesh_orientation_tester.urdf. parsing model... mapIndex: 1 smurfing robot: mesh_orientation_tester... Warning: The DOM was unable to create an attribute xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance at line 11. Probably a schema violation. Warning: The DOM was unable to create an attribute xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance at line 11. Probably a schema violation. Thread 1 "mars_app" received signal SIGSEGV, Segmentation fault. ``` with the following backtrace ``` #0 mars::graphics::LoadDrawObject::loadGeodes (this=GAZEBO
For Gazebo I had to adapt the URDF a little, but those changes doesn't affect the behaviour of mesh interpretation:
Regarding the loading of meshes Gazebo beaves exactly as expected. In the images the Origin-Frame of Gazebo is pointing as follows: X is pointing away from the viewer into the screen plane, Y is pointing to the left and Z is pointing upwards. The greyish stuff in front is the shadow of the test mesh.
I suggest for MARS adding the orientation info how the obj-meshes should be parsed in SMURF.