Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MAminSFV committed Sep 8, 2024
1 parent b892ce8 commit f25282d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ nanobind_add_module(

target_link_libraries(custom_system PUBLIC drake::drake)
set_target_properties(custom_system PROPERTIES CXX_VISIBILITY_PRESET default)
target_compile_definitions(custom_system
PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})

# Install directive for scikit-build-core
install(TARGETS custom_system LIBRARY DESTINATION custom_system)
install(TARGETS custom_system LIBRARY DESTINATION drake_extension)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
{ name = "M. Amin Safavi", email = "[email protected]" }
]
classifiers = [
"License :: OSI Approved :: MIT License"
"License :: MIT License"
]
dependencies = [
"drake",
Expand Down
2 changes: 0 additions & 2 deletions src/custom_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ using drake::systems::Context;
using drake::systems::LeafSystem;
using drake::systems::kVectorValued;

namespace drake_extension {
/// Adds a constant to an input.
template <typename T>
class SimpleAdder : public LeafSystem<T> {
Expand Down Expand Up @@ -41,4 +40,3 @@ NB_MODULE(custom_system, m) {
nb::class_<SimpleAdder<T>, LeafSystem<T>>(m, "SimpleAdder")
.def(nb::init<T>(), nb::arg("add"));
}
} // namespace drake_extension
1 change: 1 addition & 0 deletions src/drake_extension/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .custom_system import SimpleAdder, __doc__
5 changes: 2 additions & 3 deletions tests/test_custom_system.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import numpy as np
import custom_system
from drake_extension import SimpleAdder

from pydrake.systems.analysis import Simulator
from pydrake.systems.framework import (
Expand All @@ -15,7 +14,7 @@
def test_custom_system():
builder = DiagramBuilder()
source = builder.AddSystem(ConstantVectorSource([10.]))
adder = builder.AddSystem(custom_system.SimpleAdder(100.))
adder = builder.AddSystem(drake_extension.SimpleAdder(100.))
builder.Connect(source.get_output_port(0), adder.get_input_port(0))
logger = builder.AddSystem(VectorLogSink(1))
builder.Connect(adder.get_output_port(0), logger.get_input_port(0))
Expand Down

0 comments on commit f25282d

Please sign in to comment.