Skip to content

Commit 3422ae4

Browse files
authored
Cleanup TODOs and collision coverage (#2286)
1 parent d111194 commit 3422ae4

File tree

8 files changed

+80
-47
lines changed

8 files changed

+80
-47
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ IncludeCategories:
110110
Priority: 50
111111

112112
# C++ standard library headers, then C
113-
# TODO(JS): Add when new C++ STL header begins with "c" is found
113+
# C-prefix headers (including the full C++20 set) are matched by the "^<c.*>$" regex
114114
- Regex: "^<charconv>$"
115115
Priority: 100
116116
- Regex: "^<chrono>$"

.github/workflows/ci_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
strategy:
4646
fail-fast: false
4747
matrix:
48-
build_type: ["Release"] # TODO: Add Debug
48+
build_type: ["Release"] # Windows CI keeps Release-only to keep runtimes acceptable
4949
steps:
5050
- name: Checkout
5151
uses: actions/checkout@v6

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,8 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
462462
message(FATAL_ERROR "The installed g++ version is ${GCC_VERSION}. ${PROJECT_NAME} requires g++ ${gcc_required_version} or greater.")
463463
endif()
464464
if(GCC_VERSION VERSION_GREATER_EQUAL 13.2.0)
465-
# TODO: These warnings should be properly addressed and these compiler options removed
466-
add_compile_options(-Wno-overloaded-virtual -Wno-alloc-size-larger-than -Wno-dangling-pointer)
467-
endif()
468-
if(GCC_VERSION VERSION_GREATER_EQUAL 13.2.0)
469-
# TODO: These warnings should be properly addressed and these compiler options removed
465+
# GCC 13 currently reports noisy diagnostics in upstream dependencies; silence
466+
# them until Eigen/FCL updates remove the false positives.
470467
add_compile_options(-Wno-overloaded-virtual -Wno-alloc-size-larger-than -Wno-dangling-pointer)
471468
endif()
472469
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")

cmake/dart_defs.cmake

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,7 @@ function(add_component package_name component)
728728
FILE "${package_name}_${component}Targets.cmake"
729729
DESTINATION "${CONFIG_INSTALL_DIR}"
730730
)
731-
# TODO(JS): It would be nice if we could check if ${target} has at least one
732-
# dependency target.
731+
# Record dependency state so install_component_exports can guard against empty components.
733732

734733
set_property(
735734
TARGET "${target}"
@@ -747,6 +746,11 @@ function(add_component package_name component)
747746
TARGET "${target}"
748747
PROPERTY "${component_prefix}LIBRARIES"
749748
)
749+
set_property(
750+
TARGET "${target}"
751+
PROPERTY "${component_prefix}HAS_DEPENDENCY_TARGET"
752+
FALSE
753+
)
750754
set_property(
751755
GLOBAL
752756
APPEND
@@ -852,6 +856,9 @@ function(add_component_targets package_name component)
852856
endif()
853857

854858
set(target "${component_prefix}${component}")
859+
if(NOT dependency_targets)
860+
message(FATAL_ERROR "Component '${component}' must have at least one dependency target.")
861+
endif()
855862
add_dependencies("${target}" ${ARGN})
856863

857864
foreach(dependency_target IN LISTS dependency_targets)
@@ -882,6 +889,11 @@ function(add_component_targets package_name component)
882889
)
883890
endforeach()
884891

892+
set_property(
893+
TARGET "${target}"
894+
PROPERTY "${component_prefix}HAS_DEPENDENCY_TARGET"
895+
TRUE
896+
)
885897
set_property(
886898
TARGET "${target}"
887899
APPEND
@@ -899,11 +911,24 @@ function(install_component_exports package_name)
899911
get_property(components GLOBAL PROPERTY "${package_name}_COMPONENTS")
900912

901913
set(output_prefix "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_INSTALL_DIR}")
914+
file(MAKE_DIRECTORY "${output_prefix}")
902915

903916
foreach(component IN LISTS components)
904917
set(target "${component_prefix}${component}")
905918

906-
# TODO: Replace this manual generation with a configure_file.
919+
get_property(
920+
has_dependency_targets
921+
TARGET "${target}"
922+
PROPERTY "${component_prefix}HAS_DEPENDENCY_TARGET"
923+
)
924+
if(NOT has_dependency_targets)
925+
message(
926+
FATAL_ERROR
927+
"Component '${component}' has no dependency targets. "
928+
"Call add_component_targets(${package_name} ${component} <targets>)."
929+
)
930+
endif()
931+
907932
set(output_path
908933
"${output_prefix}/${package_name}_${component}Component.cmake")
909934

dart/CMakeLists.txt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ endif()
171171
# C++ standard settings
172172
target_compile_features(dart PUBLIC cxx_std_20)
173173

174+
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" dart_host_processor)
175+
set(dart_host_architecture "unknown")
176+
if(dart_host_processor MATCHES "amd64|x86_64")
177+
set(dart_host_architecture "x86_64")
178+
elseif(dart_host_processor MATCHES "i[3-6]86")
179+
set(dart_host_architecture "x86")
180+
elseif(dart_host_processor MATCHES "aarch64|arm64")
181+
set(dart_host_architecture "arm64")
182+
elseif(dart_host_processor MATCHES "^arm")
183+
set(dart_host_architecture "arm")
184+
elseif(dart_host_processor MATCHES "riscv64")
185+
set(dart_host_architecture "riscv64")
186+
endif()
187+
174188
# Build DART with all available SIMD instructions
175189
if(DART_ENABLE_SIMD)
176190
if(MSVC)
@@ -189,14 +203,13 @@ if(DART_ENABLE_SIMD)
189203
target_compile_options(dart PUBLIC -march=native -faligned-new)
190204
endif()
191205
else()
192-
# TODO: Improve this part to detect the system's architecture and apply the
193-
# appropriate SIMD instructions.
194-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
195-
# Remove SSE flags if set elsewhere
196-
string(REPLACE "-msse" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
197-
string(REPLACE "-msse2" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
198-
string(REPLACE "-msse3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
199-
string(REPLACE "-mssse3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
206+
# Remove x86-specific flags when building on non-x86 architectures to keep
207+
# builds portable without enabling the SIMD option.
208+
if(NOT dart_host_architecture STREQUAL "x86"
209+
AND NOT dart_host_architecture STREQUAL "x86_64")
210+
foreach(flag "-msse" "-msse2" "-msse3" "-mssse3")
211+
string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
212+
endforeach()
200213
endif()
201214
endif()
202215

examples/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ add_subdirectory(capsule_ground_contact)
3131
if(DART_HAVE_OCTOMAP)
3232
add_subdirectory(point_cloud)
3333
endif()
34-
# TODO: Re-enable when rerun example has source files
35-
# add_subdirectory(rerun)
3634
add_subdirectory(rigid_chain)
3735
add_subdirectory(rigid_cubes)
3836
add_subdirectory(rigid_loop)

python/tests/unit/dynamics/test_meta_skeleton.py renamed to python/tests/integration/test_meta_skeleton.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import platform
2-
31
import dartpy as dart
42
import pytest
53

6-
# TODO(JS): Move this to integration category once created
7-
8-
94
def test_basic():
105
urdfParser = dart.io.DartLoader()
116
kr5 = urdfParser.parse_skeleton("dart://sample/urdf/KR5/KR5 sixx R650.urdf")

python/tests/unit/collision/test_collision.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
import platform
2-
31
import dartpy as dart
42
import numpy as np
53
import pytest
64

75

8-
def collision_groups_tester(cd):
9-
size = [1, 1, 1]
10-
pos1 = [0, 0, 0]
11-
pos2 = [0.5, 0, 0]
6+
def _collision_detector_factories():
7+
detectors = [("fcl", dart.FCLCollisionDetector)]
8+
9+
if hasattr(dart, "DARTCollisionDetector"):
10+
detectors.append(("dart", dart.DARTCollisionDetector))
11+
12+
if hasattr(dart, "BulletCollisionDetector"):
13+
detectors.append(("bullet", dart.BulletCollisionDetector))
14+
15+
if hasattr(dart, "OdeCollisionDetector"):
16+
detectors.append(("ode", dart.OdeCollisionDetector))
17+
18+
return detectors
1219

20+
21+
_COLLISION_DETECTORS = _collision_detector_factories()
22+
if not _COLLISION_DETECTORS:
23+
pytest.skip("No collision detectors available", allow_module_level=True)
24+
25+
26+
def collision_groups_tester(cd):
1327
simple_frame1 = dart.SimpleFrame()
1428
simple_frame2 = dart.SimpleFrame()
1529

@@ -102,25 +116,16 @@ def collision_groups_tester(cd):
102116
assert not group.collide(group2)
103117

104118

105-
def test_collision_groups():
106-
cd = dart.FCLCollisionDetector()
107-
collision_groups_tester(cd)
119+
_COLLISION_IDS = [name for name, _ in _COLLISION_DETECTORS]
108120

109-
cd = dart.DARTCollisionDetector()
110-
collision_groups_tester(cd)
111121

112-
if hasattr(dart, "BulletCollisionDetector"):
113-
cd = dart.BulletCollisionDetector()
114-
collision_groups_tester(cd)
115-
116-
if hasattr(dart, "OdeCollisionDetector"):
117-
cd = dart.OdeCollisionDetector()
118-
collision_groups_tester(cd)
122+
@pytest.mark.parametrize("name, cd_factory", _COLLISION_DETECTORS, ids=_COLLISION_IDS)
123+
def test_collision_groups(name, cd_factory):
124+
collision_groups_tester(cd_factory())
119125

120126

121-
# TODO: Add more collision detectors
122-
@pytest.mark.parametrize("cd", [dart.FCLCollisionDetector()])
123-
def test_filter(cd):
127+
@pytest.mark.parametrize("name, cd_factory", _COLLISION_DETECTORS, ids=_COLLISION_IDS)
128+
def test_filter(name, cd_factory):
124129
# Create two bodies skeleton. The two bodies are placed at the same position
125130
# with the same size shape so that they collide by default.
126131
skel = dart.Skeleton()
@@ -143,7 +148,7 @@ def test_filter(cd):
143148

144149
# Set a new collision detector
145150
constraint_solver = world.get_constraint_solver()
146-
constraint_solver.set_collision_detector(cd)
151+
constraint_solver.set_collision_detector(cd_factory())
147152

148153
# Get the collision group from the constraint solver
149154
group = constraint_solver.get_collision_group()

0 commit comments

Comments
 (0)