Skip to content

Commit

Permalink
w
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Mar 23, 2024
1 parent 6468d7f commit 477075b
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 5 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ dart_option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
dart_option(DART_FORCE_COLORED_OUTPUT
"Always produce ANSI-colored output (GNU/Clang only)." OFF)
dart_option(DART_USE_SYSTEM_IMGUI "Use system ImGui" OFF)
dart_option(DART_BUILD_RERUN "Build with Rerun SDK" OFF)
dart_option(DART_IN_CI "Indicate building DART as part of CI" OFF)

#===============================================================================
Expand Down Expand Up @@ -200,14 +201,12 @@ endif()
set_property(CACHE DART_ACTIVE_LOG_LEVEL PROPERTY STRINGS TRACE DEBUG INFO WARN ERROR FATAL OFF)

if(BUILD_TYPE_DEBUG)
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
dart_option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
else()
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
dart_option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
endif()

option(DART_BUILD_WHEELS "Indicate building dartpy for wheels" OFF)

option(DART_BUILD_RERUN "Build with Rerun SDK" OFF)
dart_option(DART_BUILD_WHEELS "Indicate building dartpy for wheels" OFF)

#===============================================================================
# Find dependencies
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ add_subdirectory(fetch)

# Deprecated examples
add_subdirectory(deprecated_examples)

add_subdirectory(rerun)
20 changes: 20 additions & 0 deletions examples/rerun/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.22.1)

get_filename_component(example_name ${CMAKE_CURRENT_LIST_DIR} NAME)
set(example_name example-${example_name})

project(${example_name})

set(required_components utils-urdf)
set(required_libraries dart dart-utils-urdf rerun_sdk)

if(DART_IN_SOURCE_BUILD)
dart_build_example_in_source(${example_name} LINK_LIBRARIES ${required_libraries})
return()
endif()

find_package(DART 6.14.0 REQUIRED COMPONENTS ${required_components} CONFIG)

file(GLOB srcs "*.cpp" "*.hpp")
add_executable(${example_name} ${srcs})
target_link_libraries(${example_name} PUBLIC ${required_libraries})
20 changes: 20 additions & 0 deletions examples/rerun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This project is dependent on DART. Please make sure a proper version of DART is
installed before building this project.

## Build Instructions

From this directory:

$ mkdir build
$ cd build
$ cmake ..
$ make

## Execute Instructions

Launch the executable from the build directory above:

$ ./{generated_executable}

Follow the instructions detailed in the console.

91 changes: 91 additions & 0 deletions examples/rerun/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2011-2024, The DART development contributors
* All rights reserved.
*
* The list of contributors can be found at:
* https://github.com/dartsim/dart/blob/main/LICENSE
*
* This file is provided under the following "BSD-style" License:
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <dart/utils/urdf/urdf.hpp>
#include <dart/utils/utils.hpp>

#include <dart/simulation/World.hpp>

#include <dart/dart.hpp>

#include <rerun.hpp>
#include <rerun/demo_utils.hpp>

using namespace dart;
using namespace dart::common;
using namespace dart::dynamics;
using namespace dart::simulation;
using namespace dart::utils;
using namespace dart::math;
using namespace rerun::demo;

int main()
{
auto shape
= std::make_shared<dynamics::BoxShape>(Eigen::Vector3d(0.3, 0.3, 0.3));

// Create a box-shaped rigid body
auto skeleton = dynamics::Skeleton::create();
auto jointAndBody
= skeleton->createJointAndBodyNodePair<dynamics::FreeJoint>();
auto body = jointAndBody.second;
body->createShapeNodeWith<
dynamics::VisualAspect,
dynamics::CollisionAspect,
dynamics::DynamicsAspect>(shape);

// Create a world and add the rigid body
auto world = simulation::World::create();
world->addSkeleton(skeleton);

// Spawn Rerun viewer
const auto rec = rerun::RecordingStream("rerun_example_cpp");
rec.spawn().exit_on_failure();

for (auto i = 0; i < 1000; ++i) {
world->step();

for (auto j = 0u; j < world->getNumSkeletons(); ++j) {
auto skel = world->getSkeleton(j);

for (auto k = 0u; k < skel->getNumBodyNodes(); ++k) {
auto body = skel->getBodyNode(k);
body->eachShapeNodeWith<dynamics::VisualAspect>(
[&](const dynamics::ShapeNode* shapeNode) {
const auto& visualAspect = shapeNode->getVisualAspect();
shapeNode->getTransform();
const auto& shape = shapeNode->getShape();
});
}
}
}
}
7 changes: 7 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ install-local = { cmd = "cmake --install build --prefix $CONDA_PREFIX", depends_
"configure_local",
"build",
] }

example-hello-world = { cmd = "cmake --build build --target hello_world --parallel && ./build/bin/hello_world", depends_on = [
"configure",
] }
example-atlas-puppet = { cmd = "cmake --build build --target atlas_puppet --parallel && ./build/bin/atlas_puppet", depends_on = [
"configure",
] }
example-atlas-simbicon = { cmd = "cmake --build build --target atlas_simbicon --parallel && ./build/bin/atlas_simbicon", depends_on = [
"configure",
] }
example-rerun = { cmd = "cmake --build build --target example-rerun --parallel && ./build/bin/example-rerun", depends_on = [
"configure",
] }

[dependencies]
assimp = ">=5.3.1,<5.4"
Expand Down

0 comments on commit 477075b

Please sign in to comment.