Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 6 ➡️ 7 #594

Merged
merged 8 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Ubuntu CI

on: [push, pull_request]
on:
pull_request:
push:
branches:
- 'ign-physics[0-9]'
- 'gz-physics[0-9]?'
- 'main'

jobs:
jammy-ci:
Expand Down
130 changes: 130 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)

package(
default_visibility = GZ_VISIBILITY,
features = GZ_FEATURES,
)

licenses(["notice"]) # Apache-2.0

exports_files(["LICENSE"])

gz_configure_header(
name = "physics_config_hh",
src = "include/gz/physics/config.hh.in",
cmakelists = ["CMakeLists.txt"],
defines = {
# These definitions are unused,
# this is merely to suppress generator warnings
"GZ_PHYSICS_ENGINE_INSTALL_DIR": "unused",
},
package = "physics",
)

gz_export_header(
name = "include/gz/physics/Export.hh",
export_base = "GZ_PHYSICS",
lib_name = "gz-physics",
visibility = ["//visibility:private"],
)

public_headers_no_gen = glob([
"include/gz/physics/*.hh",
"include/gz/physics/detail/*.hh",
])

sources = glob(
["src/*.cc"],
exclude = [
"src/*_TEST.cc",
],
)

gz_include_header(
name = "physics_hh_genrule",
out = "include/gz/physics.hh",
hdrs = public_headers_no_gen + [
"include/gz/physics/config.hh",
"include/gz/physics/Export.hh",
],
)

public_headers = public_headers_no_gen + [
"include/gz/physics/config.hh",
"include/gz/physics/Export.hh",
"include/gz/physics.hh",
]

cc_library(
name = "physics",
srcs = sources,
hdrs = public_headers,
defines = [
'GZ_PHYSICS_ENGINE_RELATIVE_INSTALL_DIR=\\"unused\\"',
"GZ_PHYSICS_BAZEL_BUILD=true",
],
includes = ["include"],
deps = [
GZ_ROOT + "math",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "plugin:core",
GZ_ROOT + "plugin:loader",
GZ_ROOT + "utils",
],
)

cc_library(
name = "heightmap",
hdrs = [
"heightmap/include/gz/physics/heightmap/HeightmapShape.hh",
"heightmap/include/gz/physics/heightmap/detail/HeightmapShape.hh",
],
includes = ["heightmap/include"],
)

cc_library(
name = "mesh",
hdrs = [
"mesh/include/gz/physics/mesh/MeshShape.hh",
"mesh/include/gz/physics/mesh/detail/MeshShape.hh",
],
includes = ["mesh/include"],
)

cc_library(
name = "sdf",
hdrs = glob([
"sdf/include/gz/physics/sdf/*.hh",
]),
includes = ["sdf/include"],
deps = [
GZ_ROOT + "sdformat",
],
)

test_sources = glob(
include = ["src/*_TEST.cc"],
)

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "physics",
},
deps = [
":physics",
GZ_ROOT + "physics/test:test_headers",
"@gtest",
"@gtest//:gtest_main",
],
) for src in test_sources]
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ gz_find_package(gz-common5
REQUIRED_BY heightmap mesh dartsim tpe tpelib bullet)
set(GZ_COMMON_VER ${gz-common5_VERSION_MAJOR})

# This is only used for test support
gz_find_package(gz-common5 REQUIRED COMPONENTS testing)

#--------------------------------------
# Find gz-math
gz_find_package(gz-math7 REQUIRED COMPONENTS eigen3)
Expand Down Expand Up @@ -90,8 +93,6 @@ gz_find_package(GzBullet

message(STATUS "-------------------------------------------\n")

set(GZ_PHYSICS_RESOURCE_DIR "${CMAKE_SOURCE_DIR}/resources")

# Plugin install dirs
set(GZ_PHYSICS_ENGINE_RELATIVE_INSTALL_DIR
${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/engine-plugins
Expand Down
45 changes: 45 additions & 0 deletions bullet-featherstone/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
)

private_headers = glob(["src/*.hh"])

sources = glob(
["src/*.cc"],
exclude = [
"src/*_TEST.cc",
"src/plugin.cc",
],
)

cc_library(
name = "bullet-featherstone",
srcs = sources + private_headers,
includes = ["include"],
visibility = GZ_VISIBILITY,
deps = [
GZ_ROOT + "common",
GZ_ROOT + "common/graphics",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "third_party/bullet3:BulletCollision",
GZ_ROOT + "third_party/bullet3:BulletDynamics",
],
)

cc_binary(
name = "libgz-physics-bullet-featherstone-plugin.so",
srcs = [
"src/plugin.cc",
],
linkshared = True,
visibility = GZ_VISIBILITY,
deps = [
":bullet-featherstone",
GZ_ROOT + "plugin:register",
],
)
55 changes: 55 additions & 0 deletions dartsim/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)

public_headers = ["include/gz/physics/dartsim/World.hh"]

private_headers = glob(["src/*.hh"])

sources = glob(
["src/*.cc"],
exclude = [
"src/*_TEST.cc",
"src/plugin.cc",
],
)

cc_library(
name = "dartsim",
srcs = sources + private_headers,
hdrs = public_headers,
includes = ["include"],
visibility = GZ_VISIBILITY,
deps = [
GZ_ROOT + "common",
GZ_ROOT + "common/geospatial",
GZ_ROOT + "common/profiler",
GZ_ROOT + "math/eigen3",
GZ_ROOT + "physics",
GZ_ROOT + "physics:heightmap",
GZ_ROOT + "physics:mesh",
GZ_ROOT + "physics:sdf",
GZ_ROOT + "third_party/dart:simulation",
GZ_ROOT + "third_party/dart:collision-bullet",
GZ_ROOT + "third_party/dart:collision-ode",
],
)

cc_binary(
name = "libgz-physics-dartsim-plugin.so",
srcs = [
"src/plugin.cc",
],
linkshared = True,
visibility = GZ_VISIBILITY,
deps = [
":dartsim",
GZ_ROOT + "plugin:register",
],
)
20 changes: 6 additions & 14 deletions dartsim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,21 @@ gz_build_tests(
LIB_DEPS
${features}
${dartsim_plugin}
gz-plugin${GZ_PLUGIN_VER}::loader
gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER}
gz-physics-test
gz-common${GZ_COMMON_VER}::geospatial
${PROJECT_LIBRARY_TARGET_NAME}-sdf
${PROJECT_LIBRARY_TARGET_NAME}-heightmap
${PROJECT_LIBRARY_TARGET_NAME}-mesh
TEST_LIST tests
ENVIRONMENT
GZ_PHYSICS_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX})
GZ_PHYSICS_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/src
)

foreach(test ${tests})

target_compile_definitions(${test} PRIVATE
"dartsim_plugin_LIB=\"$<TARGET_FILE:${dartsim_plugin}>\""
"TEST_WORLD_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/worlds/\""
"GZ_PHYSICS_RESOURCE_DIR=\"${GZ_PHYSICS_RESOURCE_DIR}\"")
"dartsim_plugin_LIB=\"$<TARGET_FILE:${dartsim_plugin}>\"")

if (DART_HAS_CONTACT_SURFACE_HEADER)
target_compile_definitions(${test} PRIVATE DART_HAS_CONTACT_SURFACE)
Expand All @@ -104,10 +103,3 @@ foreach(test ${tests})
# Helps when we want to build a single test after making changes to dartsim_plugin
add_dependencies(${test} ${dartsim_plugin})
endforeach()

foreach(test UNIT_FindFeatures_TEST UNIT_RequestFeatures_TEST)
if(TARGET ${test})
target_compile_definitions(${test} PRIVATE
"dartsim_plugin_LIB=\"$<TARGET_FILE:${dartsim_plugin}>\"")
endif()
endforeach()
3 changes: 2 additions & 1 deletion dartsim/src/AddedMassFeatures_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <sdf/World.hh>

#include <test/Utils.hh>
#include "Worlds.hh"

#include "World.hh"

Expand Down Expand Up @@ -122,7 +123,7 @@ TEST(AddedMassFeatures, AddedMass)
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1;

auto world = LoadWorld(TEST_WORLD_DIR"/added_mass.sdf");
const auto world = LoadWorld(dartsim::worlds::kAddedMassSdf);
ASSERT_NE(nullptr, world);

auto dartWorld = world->GetDartsimWorld();
Expand Down
5 changes: 3 additions & 2 deletions dartsim/src/Base_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
#include "EntityManagementFeatures.hh"
#include "SDFFeatures.hh"

using namespace gz::physics;
#include "test/Resources.hh"

using namespace gz::physics;


TEST(BaseClass, RemoveModel)
Expand Down Expand Up @@ -166,7 +167,7 @@ TEST(BaseClass, SdfConstructionBookkeeping)

::sdf::Root root;

auto errors = root.Load(GZ_PHYSICS_RESOURCE_DIR "/rrbot.xml");
auto errors = root.Load(gz::physics::test::resources::kRrbotXml);
ASSERT_TRUE(errors.empty());
const ::sdf::Model *sdfModel = root.Model();
ASSERT_NE(nullptr, sdfModel);
Expand Down
10 changes: 6 additions & 4 deletions dartsim/src/EntityManagementFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
#include <unordered_map>

#include <dart/config.hpp>
#include <dart/collision/ode/OdeCollisionDetector.hpp>
#include <dart/constraint/ConstraintSolver.hpp>
#include <dart/dynamics/FreeJoint.hpp>

#include <dart/collision/CollisionFilter.hpp>
#include <dart/collision/CollisionObject.hpp>

#include "GzOdeCollisionDetector.hh"

namespace gz {
namespace physics {
namespace dartsim {
Expand Down Expand Up @@ -724,11 +725,12 @@ Identity EntityManagementFeatures::ConstructEmptyWorld(
const Identity &/*_engineID*/, const std::string &_name)
{
const auto &world = std::make_shared<dart::simulation::World>(_name);
world->getConstraintSolver()->setCollisionDetector(
dart::collision::OdeCollisionDetector::create());
auto collisionDetector = dart::collision::GzOdeCollisionDetector::create();
world->getConstraintSolver()->setCollisionDetector(collisionDetector);

// TODO(anyone) We need a machanism to configure maxNumContacts at runtime.
auto &collOpt = world->getConstraintSolver()->getCollisionOption();
// Set the max number of contacts for all collision objects
// in the world
collOpt.maxNumContacts = 10000;

world->getConstraintSolver()->getCollisionOption().collisionFilter =
Expand Down
Loading