gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.17k stars 476 forks source link

Collada loader failing at loading Blender exported dae rigged model with motion tracking animation attached to it. #2489

Open osrf-migration opened 6 years ago

osrf-migration commented 6 years ago

Original report (archived issue) by Lucas MCKENNA (Bitbucket: lukes3315).

The original report had attachments: test.dae


Hey,

I am trying to load a dae mesh in gazebo with attached animation frames to it. I use blender to export my mesh & animations into the collada format to input into Gazebo.

If I do not attach any skeleton to the model, Gazebo loads it up fine, the problems only start occurring when I attach a skeleton & animation to it.

Gazebo fails and crashes gazebo with this error:

0   libgazebo_common.9.dylib        0x000000010444fa2f std::__1::vector<gazebo::common::NodeTransform, std::__1::allocator<gazebo::common::NodeTransform> >::vector(std::__1::vector<gazebo::common::NodeTransform, std::__1::allocator<gazebo::common::NodeTransform> > const&) + 33
1   libgazebo_common.9.dylib        0x000000010444e7f7 gazebo::common::SkeletonNode::GetTransforms() + 21
2   libgazebo_common.9.dylib        0x000000010440944d gazebo::common::ColladaLoader::LoadAnimationSet(TiXmlElement*, gazebo::common::Skeleton*) + 5723
3   libgazebo_common.9.dylib        0x000000010440463b gazebo::common::ColladaLoader::LoadController(TiXmlElement*, TiXmlElement*, ignition::math::v4::Matrix4<double> const&, gazebo::common::Mesh*) + 183
4   libgazebo_common.9.dylib        0x0000000104403327 gazebo::common::ColladaLoader::LoadNode(TiXmlElement*, gazebo::common::Mesh*, ignition::math::v4::Matrix4<double> const&) + 2733
5   libgazebo_common.9.dylib        0x0000000104402973 gazebo::common::ColladaLoader::LoadNode(TiXmlElement*, gazebo::common::Mesh*, ignition::math::v4::Matrix4<double> const&) + 249
6   libgazebo_common.9.dylib        0x000000010440271a gazebo::common::ColladaLoader::LoadScene(gazebo::common::Mesh*) + 354
7   libgazebo_common.9.dylib        0x00000001044024cf gazebo::common::ColladaLoader::Load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 1857
8   libgazebo_common.9.dylib        0x000000010442d5b8 gazebo::common::MeshManager::Load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 1522
9   libgazebo_rendering.9.dylib     0x0000000103f56eaa gazebo::rendering::Visual::InsertMesh(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 72
10  libgazebo_rendering.9.dylib     0x0000000103f53262 gazebo::rendering::Visual::AttachMesh(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 538
11  libgazebo_rendering.9.dylib     0x0000000103f4f899 gazebo::rendering::Visual::Load() + 877
12  libgazebo_rendering.9.dylib     0x0000000103f4d57d gazebo::rendering::Visual::Load(std::__1::shared_ptr<sdf::Element>) + 113
13  libgazebo_gui.9.dylib           0x00000001032a80a9 gazebo::gui::ModelMaker::CreateModelFromSDF(std::__1::shared_ptr<sdf::Element>) + 2571
14  libgazebo_gui.9.dylib           0x00000001032a6376 gazebo::gui::ModelMaker::Init() + 2162
15  libgazebo_gui.9.dylib           0x00000001032a5969 gazebo::gui::ModelMaker::InitFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 585
16  libgazebo_gui.9.dylib           0x0000000103233de0 gazebo::gui::GLWidget::OnCreateEntity(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 716
17  libgazebo_gui.9.dylib           0x000000010324fac2 void gazebo::event::EventT<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)>::Signal<char [6], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const (&) [6], std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 248
18  libgazebo_gui.9.dylib           0x000000010324ce85 gazebo::gui::InsertModelWidget::OnModelSelection(QTreeWidgetItem*, int) + 503
19  org.qt-project.QtCore           0x00000001072a419e QMetaObject::activate(QObject*, int, int, void**) + 2334
20  org.qt-project.QtWidgets        0x00000001068c017d 0x1065b8000 + 3178877
21  org.qt-project.QtCore           0x00000001072a419e QMetaObject::activate(QObject*, int, int, void**) + 2334
22  org.qt-project.QtWidgets        0x0000000106838790 QAbstractItemView::mouseReleaseEvent(QMouseEvent*) + 848
23  org.qt-project.QtWidgets        0x00000001068a8339 QTreeView::mouseReleaseEvent(QMouseEvent*) + 345
24  org.qt-project.QtWidgets        0x00000001066024c0 QWidget::event(QEvent*) + 448

The dae model & animation load up fine if I use Apple's Preview.

Any ideas?

Cheers.

osrf-migration commented 6 years ago

Original comment by Lucas MCKENNA (Bitbucket: lukes3315).


osrf-migration commented 6 years ago

Original comment by Lucas MCKENNA (Bitbucket: lukes3315).


When exporting the model with blender and reimporting it, blender Collada's exporter seems to have completely distorted the model and the animations. Will look into it. Will leave this open in case you guys want to show an error for an erroneous blender model instead of crash. Cheers.

osrf-migration commented 6 years ago

Original comment by Roselle Carmen (Bitbucket: iamironcat).


Hi Lucas, I'm facing this issue and sent a bug report to the Blender dev team.

Bug report

I've reported a seperate issue as the distortion happens when using a .dae animated Mixamo model (which works in Blender)

Gazebo bug report (#2516)

osrf-migration commented 6 years ago

Original comment by Lucas MCKENNA (Bitbucket: lukes3315).


Hi Roselle,

I ended up writing a patch for Gazebo that fixed my crash. I wanted to share it with the community I just got caught up with other things. I added a checking condition in the ColladaLoader.cc file for Gazebo-9 which had solved my problem if I remember well.

This just fixed my crash but didn't run my animations, so there is still a problem in what blender generated, however it does work with the default humanoid models gazebo provides (walk.dae found here).

Essentially there was a nullptr for one of the joints and you can add a check for the joint (ColladaLoader.cc line 625):

        if (animation[targetBone].find(times[i]) == animation[targetBone].end() && _skel->GetNodeById(targetBone) != nullptr)
          animation[targetBone][times[i]] =
            _skel->GetNodeById(targetBone)->GetTransforms();

You'll have to recompile gazebo until they release an official fix, maybe try downloading the latest Gazebo they could've fixed it.

Hope this helps.

Cheers.

osrf-migration commented 6 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


That line has not been changed yet, see here. It would be great if you could make a pull request with the change, @lukes3315.

osrf-migration commented 6 years ago

Original comment by Lucas MCKENNA (Bitbucket: lukes3315).


Also if I remember well one of the issues I was having, was that I was trying to get animations working on a model tag instead of an actor tag in the sdf file. Since I was trying to retrieve forces applied to different joints in motion from the humanoid animations (basically retrieve forces from walking motion). I think that patch I had done was because the system doesn't load the bones nor joint transforms when trying to be loaded by the model tag since the model tag doesn't support animations. The only tag that handles animations is the actor tag in which case gazebo loads the bones and joint transforms to prevent these types of crashes.

I think it would be a good feature to add in the future to be able to retrieve transformation forces from animated models. I attached an Inertial Measurement Unit to the chest of an animated humanoid model with scripted routes (for displacement purposes) and I couldn't retrieve any angular velocities or linear accelerations that were coherent with the model's motion from Gazebo as the actor subsystem doesn't handle forces from the physics engine.

Hope the feedback helps.

osrf-migration commented 6 years ago

Original comment by Lucas MCKENNA (Bitbucket: lukes3315).


I'll do a pull request when I get back to Gazebo next week.

osrf-migration commented 5 years ago

Original comment by Roselle Carmen (Bitbucket: iamironcat).


Hi Lucas, did you managed to get the pull request up? Had a similar issue on a simpler model.

osrf-migration commented 5 years ago

Original comment by Lucas MCKENNA (Bitbucket: lukes3315).


Doing this today. Cheers.