Skip to content

Commit 82cf0e7

Browse files
authored
Add dart7 core library scaffold (#2097)
1 parent 6642d2d commit 82cf0e7

File tree

92 files changed

+13946
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+13946
-424
lines changed

.clang-format

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ IncludeCategories:
6868
# DART library headers (with angle brackets) - ordered from high-level to low-level
6969
- Regex: '^<dart\/config\.hpp>$' # config first
7070
Priority: 10
71+
- Regex: '^<dart7\/fwd\.hpp>$' # dart7 forward declarations first
72+
Priority: 11
73+
- Regex: '^<dart7\/.*\.h(pp)?>$' # other dart7 headers
74+
Priority: 12
7175
- Regex: '^<dart\/test\/.*\.h(pp)?>$' # test utilities
7276
Priority: 20
7377
- Regex: '^<dart\/python\/.*\.h(pp)?>$' # bindings
@@ -99,24 +103,6 @@ IncludeCategories:
99103
- Regex: '^<dart\/external\/.*\.h(pp)?>$' # external dependencies
100104
Priority: 50
101105

102-
# DART7 experimental library headers (angle brackets)
103-
- Regex: '^<dart7\/version\.hpp>$' # core version info
104-
Priority: 60
105-
- Regex: '^<dart7\/common\/.*\.h(pp)?>$' # common utilities
106-
Priority: 61
107-
- Regex: '^<dart7\/space\/.*\.h(pp)?>$' # state space utilities
108-
Priority: 62
109-
- Regex: '^<dart7\/frame\/.*\.h(pp)?>$' # frame subsystem
110-
Priority: 63
111-
- Regex: '^<dart7\/multi_body\/.*\.h(pp)?>$' # multibody subsystem
112-
Priority: 64
113-
- Regex: '^<dart7\/.*\.h(pp)?>$' # other dart7 headers
114-
Priority: 70
115-
116-
# dartpy7 experimental bindings
117-
- Regex: '^<dartpy7\/.*\.h(pp)?>$'
118-
Priority: 80
119-
120106
# 3rd-party headers
121107
- Regex: '^<.*\.h(pp)?>$'
122108
Priority: 50

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ set(DART_PKG_EXTERNAL_DEPS "assimp, ccd, eigen3, fcl, octomap")
111111
#===============================================================================
112112
# Build options
113113
#===============================================================================
114+
115+
# DART 7.0 options
116+
option(DART7_VERBOSE "Show detailed DART7 dependency information" OFF)
117+
114118
if(MSVC)
115119
set(DART_RUNTIME_LIBRARY "/MD" CACHE STRING "BaseName chosen by the user at CMake configure time")
116120
set_property(CACHE DART_RUNTIME_LIBRARY PROPERTY STRINGS /MD /MT)
@@ -163,7 +167,6 @@ dart_option(DART_USE_SYSTEM_IMGUI
163167
dart_option(DART_USE_SYSTEM_GOOGLEBENCHMARK "Use system GoogleBenchmark" OFF CATEGORY system)
164168
dart_option(DART_USE_SYSTEM_GOOGLETEST "Use system GoogleTest" OFF CATEGORY system)
165169
dart_option(DART_USE_SYSTEM_PYBIND11 "Use system pybind11" OFF CATEGORY system)
166-
dart_option(DART_USE_SYSTEM_NANOBIND "Use system nanobind" OFF CATEGORY system)
167170
dart_option(DART_USE_SYSTEM_TRACY "Use system Tracy" OFF CATEGORY system)
168171
dart_option(DART_VERBOSE "Whether print detailed information in CMake process" OFF CATEGORY diagnostics)
169172
dart_option(DART_BUILD_DART7 "Build experimental DART7 library" OFF CATEGORY build)
@@ -460,6 +463,14 @@ add_subdirectory(dart)
460463

461464
if(DART_BUILD_DART7)
462465
add_subdirectory(dart7)
466+
467+
if(MSVC)
468+
add_subdirectory(tests_dart7)
469+
add_subdirectory(examples_dart7)
470+
else()
471+
add_subdirectory(tests_dart7 EXCLUDE_FROM_ALL)
472+
add_subdirectory(examples_dart7 EXCLUDE_FROM_ALL)
473+
endif()
463474
endif()
464475

465476
set(DART_IN_SOURCE_BUILD TRUE)

benchmarks_dart7/CMakeLists.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright (c) 2011-2025, The DART development contributors
2+
# All rights reserved.
3+
#
4+
# The list of contributors can be found at:
5+
# https://github.com/dartsim/dart/blob/main/LICENSE
6+
#
7+
# This file is provided under the "BSD-style" License
8+
9+
# DART 7.0 Benchmarks
10+
#
11+
# Simply list benchmark files here. The benchmark name is derived from filename.
12+
# Example: bm_profiling.cpp -> bm_profiling
13+
#
14+
# Since benchmarks_dart7/ is a sibling to dart7/ (not a subdirectory), we need to
15+
# include dependencies and helper functions here.
16+
17+
cmake_minimum_required(VERSION 3.22.1)
18+
19+
# Include dart7 utility functions (must come first to define dart7_find_package)
20+
include(dart7_defs)
21+
22+
# Include dependency finding (makes benchmark available)
23+
include(dart7_dependencies)
24+
25+
if(NOT DART7_BUILD_BENCHMARKS)
26+
message(STATUS "dart7: Benchmarks disabled (benchmark not found)")
27+
return()
28+
endif()
29+
30+
message(STATUS "dart7: Configuring benchmarks...")
31+
32+
#==============================================================================
33+
# Benchmark List
34+
#==============================================================================
35+
# To add a new benchmark, simply add the filename to this list
36+
37+
set(DART7_BENCHMARKS
38+
bm_profiling.cpp
39+
)
40+
41+
# Register all benchmarks
42+
foreach(bm_file ${DART7_BENCHMARKS})
43+
# Extract benchmark name from filename (remove .cpp extension)
44+
get_filename_component(bm_name ${bm_file} NAME_WE)
45+
dart7_add_benchmark(${bm_name} ${CMAKE_CURRENT_SOURCE_DIR}/${bm_file})
46+
list(APPEND DART7_BENCHMARK_TARGETS ${bm_name})
47+
endforeach()
48+
49+
# Create meta target for all benchmarks
50+
add_custom_target(dart7_benchmarks
51+
DEPENDS ${DART7_BENCHMARK_TARGETS}
52+
COMMENT "Building all DART7 benchmarks"
53+
)
54+
55+
list(LENGTH DART7_BENCHMARKS num_benchmarks)
56+
message(STATUS "dart7: ${num_benchmarks} benchmark(s)")

benchmarks_dart7/bm_profiling.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (c) 2011-2025, The DART development contributors
3+
* All rights reserved.
4+
*
5+
* The list of contributors can be found at:
6+
* https://github.com/dartsim/dart/blob/main/LICENSE
7+
*
8+
* This file is provided under the following "BSD-style" License:
9+
* Redistribution and use in source and binary forms, with or
10+
* without modification, are permitted provided that the following
11+
* conditions are met:
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
* * Redistributions in binary form must reproduce the above
15+
* copyright notice, this list of conditions and the following
16+
* disclaimer in the documentation and/or other materials provided
17+
* with the distribution.
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19+
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26+
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
#include <benchmark/benchmark.h>
34+
#include <dart7/common/profiling.hpp>
35+
36+
#include <cmath>
37+
38+
using namespace dart7::common;
39+
40+
// Benchmark ScopedTimer overhead
41+
static void BM_ScopedTimerOverhead(benchmark::State& state)
42+
{
43+
ProfileStats::reset();
44+
45+
for (auto _ : state) {
46+
DART7_PROFILE_SCOPE("test");
47+
}
48+
}
49+
BENCHMARK(BM_ScopedTimerOverhead);
50+
51+
// Benchmark profiling with actual work
52+
static void BM_ProfilingWithWork(benchmark::State& state)
53+
{
54+
ProfileStats::reset();
55+
56+
for (auto _ : state) {
57+
DART7_PROFILE_SCOPE("computation");
58+
volatile double result = 0.0;
59+
for (int i = 0; i < state.range(0); ++i) {
60+
result += std::sin(i * 0.001);
61+
}
62+
}
63+
}
64+
BENCHMARK(BM_ProfilingWithWork)->Range(8, 8 << 10);
65+
66+
// Benchmark manual profiling
67+
static void BM_ManualProfiling(benchmark::State& state)
68+
{
69+
ProfileStats::reset();
70+
71+
for (auto _ : state) {
72+
DART7_PROFILE_BEGIN(manual);
73+
volatile double result = 0.0;
74+
for (int i = 0; i < 100; ++i) {
75+
result += i;
76+
}
77+
DART7_PROFILE_END(manual);
78+
}
79+
}
80+
BENCHMARK(BM_ManualProfiling);
81+
82+
BENCHMARK_MAIN();

0 commit comments

Comments
 (0)