Skip to content

Commit

Permalink
Fix bullet related segfaults on macOS
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Apr 6, 2023
1 parent 12baaf7 commit f2b1d36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bullet-featherstone/src/Base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ class Base : public Implements3d<FeatureList<Feature>>
public: std::unordered_map<std::size_t, CollisionInfoPtr> collisions;
public: std::unordered_map<std::size_t, JointInfoPtr> joints;

public: std::vector<std::unique_ptr<btGImpactMeshShape>> meshesGImpact;
// Note, the order of triangleMeshes and meshesGImpact is important. Reversing
// the order causes segfaults on macOS during destruction.
public: std::vector<std::unique_ptr<btTriangleMesh>> triangleMeshes;
public: std::vector<std::unique_ptr<btGImpactMeshShape>> meshesGImpact;
};

} // namespace bullet_featherstone
Expand Down
7 changes: 6 additions & 1 deletion test/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ foreach(plugin IN LISTS plugins)
endforeach()

if (DART_FOUND)
target_link_libraries(MockDoublePendulum PUBLIC ${DART_LIBRARIES})
# Linking against libdart-collision-bullet causes a segfault on macOS for
# some reason. We'll remove it since MockDoublePendulum doesn't use bullet
# for collision checking.
set(DART_LIBRARIES_NO_BULLET ${DART_LIBRARIES})
list(REMOVE_ITEM DART_LIBRARIES_NO_BULLET dart-collision-bullet)
target_link_libraries(MockDoublePendulum PUBLIC ${DART_LIBRARIES_NO_BULLET})
target_compile_definitions(MockDoublePendulum PRIVATE
"GZ_PHYSICS_RESOURCE_DIR=\"${GZ_PHYSICS_RESOURCE_DIR}\"")
if (MSVC)
Expand Down

0 comments on commit f2b1d36

Please sign in to comment.