-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from VokunGahrotLaas/main
auto generation of ros2_control_py
- Loading branch information
Showing
38 changed files
with
5,589 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
BasedOnStyle: Google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: humble | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build-humble: | ||
runs-on: ubuntu-latest | ||
container: ubuntu:jammy | ||
steps: | ||
- uses: ros-tooling/[email protected] | ||
with: | ||
required-ros-distributions: humble | ||
- uses: ros-tooling/[email protected] | ||
with: | ||
package-name: ros2_control_py | ||
target-ros2-distro: humble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: rolling | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build-rolling: | ||
runs-on: ubuntu-latest | ||
container: ubuntu:jammy | ||
steps: | ||
- uses: ros-tooling/[email protected] | ||
with: | ||
required-ros-distributions: rolling | ||
- uses: ros-tooling/[email protected] | ||
with: | ||
package-name: ros2_control_py | ||
target-ros2-distro: rolling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build | ||
.cache | ||
compile_commands.json | ||
tmp | ||
install | ||
log | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "builder/cppparser"] | ||
path = builder/cppparser | ||
url = https://github.com/Gepetto/cppparser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,103 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(ros2_control_py) | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
project(ros2_control_py VERSION 0.0.2) | ||
|
||
## default ros std versions/warnings | ||
# Default to C++17 | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
endif() | ||
# Default to C11 | ||
if(NOT CMAKE_C_STANDARD) | ||
set(CMAKE_C_STANDARD 11) | ||
endif() | ||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
## sanitize address gcc/clang | ||
if(SANITIZE) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address,undefined,leak") | ||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address,undefined,leak") | ||
endif() | ||
|
||
# ROS deps | ||
find_package(ament_cmake REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(rclcpp_lifecycle REQUIRED) | ||
find_package(ament_cmake_python REQUIRED) | ||
find_package(rclpy REQUIRED) | ||
find_package(controller_interface REQUIRED) | ||
find_package(controller_manager REQUIRED) | ||
find_package(controller_manager_msgs REQUIRED) | ||
find_package(hardware_interface REQUIRED) | ||
# Python deps | ||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development) | ||
find_package(pybind11_vendor REQUIRED) | ||
find_package(pybind11 REQUIRED) | ||
|
||
ament_python_install_package(ros2_control_py) | ||
## compiles builder | ||
add_subdirectory(builder) | ||
|
||
## Vars | ||
set(_ros2_py_modules | ||
hardware_interface | ||
controller_interface | ||
ros2_control_test_assets | ||
) | ||
|
||
set(_ros2_py_src_dir ${CMAKE_CURRENT_BINARY_DIR}/src) | ||
|
||
set(_ros2_py_src ${_ros2_py_modules}) | ||
list(TRANSFORM _ros2_py_src PREPEND ${_ros2_py_src_dir}/) | ||
list(TRANSFORM _ros2_py_src APPEND _py.cpp) | ||
|
||
add_custom_command( | ||
OUTPUT ${_ros2_py_src} | ||
COMMAND builder "${_ros2_py_src_dir}" "/opt/ros/$ENV{ROS_DISTRO}/include" "$ENV{ROS_DISTRO}" ${_ros2_py_modules} | ||
DEPENDS builder | ||
) | ||
add_custom_target(run_builder | ||
DEPENDS ${_ros2_py_src} | ||
) | ||
|
||
pybind11_add_module(ros2_control_py_core | ||
src/ros2_control_py/core.cpp | ||
src/ros2_control_py/hardware_interface/hardware_interface.cpp | ||
) | ||
# __init__ in build/ for tests | ||
configure_file("${CMAKE_CURRENT_LIST_DIR}/python/${PROJECT_NAME}/__init__.py" | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/__init__.py" | ||
COPYONLY | ||
) | ||
# __init__ in install/ | ||
ament_python_install_package(${PROJECT_NAME} | ||
PACKAGE_DIR "${CMAKE_CURRENT_LIST_DIR}/python/${PROJECT_NAME}" | ||
) | ||
# python modules | ||
foreach(_module ${_ros2_py_modules}) | ||
find_package(${_module} REQUIRED) | ||
pybind11_add_module(${_module}_py | ||
"${_ros2_py_src_dir}/${_module}_py.cpp" | ||
) | ||
add_dependencies(${_module}_py run_builder) | ||
set_target_properties(${_module}_py | ||
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}/${_module} | ||
) | ||
target_include_directories(${_module}_py PRIVATE | ||
"${_ros2_py_src_dir}" | ||
) | ||
ament_target_dependencies(${_module}_py PUBLIC | ||
rclpy | ||
${_module} | ||
) | ||
# ${PYTHON_INSTALL_DIR} is exported by ament_python_install_package() above | ||
install(TARGETS ${_module}_py | ||
DESTINATION "${PYTHON_INSTALL_DIR}/${PROJECT_NAME}" | ||
) | ||
endforeach() | ||
|
||
ament_target_dependencies(ros2_control_py_core PUBLIC | ||
rclcpp | ||
rclcpp_lifecycle | ||
hardware_interface) | ||
if(BUILD_TESTING) | ||
find_package(ament_cmake_pytest REQUIRED) | ||
file(GLOB_RECURSE _pytest_tests CONFIGURE_DEPENDS RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "tests/test_*.py" "tests/*/test_*.py") | ||
foreach(_test_path ${_pytest_tests}) | ||
cmake_path(RELATIVE_PATH _test_path | ||
BASE_DIRECTORY "tests/" | ||
OUTPUT_VARIABLE _test_name | ||
) | ||
ament_add_pytest_test(${_test_name} ${_test_path}) | ||
endforeach() | ||
endif() | ||
|
||
install(TARGETS ros2_control_py_core | ||
DESTINATION "${PYTHON_INSTALL_DIR}/ros2_control_py") | ||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,34 @@ | ||
# Python bindings for ros2_control using pybind11 | ||
|
||
------------------------------------------------- | ||
|
||
## Install | ||
|
||
Assuming that your [ros2_control](https://github.com/ros-controls/ros2_control) workspace is in the directory `~/ros2_control_py_ws`: | ||
|
||
```sh | ||
mkdir -p ~/ros2_control_py_ws/src | ||
cd ~/ros2_control_py_ws/src | ||
git clone https://github.com/Gepetto/ros2_control_py --recursive | ||
cd ~/ros2_control_py_ws | ||
rosdep install --from-paths src -y --ignore-src | ||
``` | ||
|
||
## Compiling | ||
|
||
```sh | ||
cd ~/ros2_control_py_ws | ||
colcon build | ||
``` | ||
|
||
## Testing | ||
|
||
```sh | ||
cd ~/ros2_control_py_ws | ||
colcon build --cmake-args ' -DCMAKE_BUILD_TYPE=Debug -DSANITIZE' | ||
colcon test | ||
``` | ||
|
||
## Usage | ||
|
||
See [doc](doc/index.rst) and [tests](tests/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
add_subdirectory(cppparser) | ||
|
||
add_executable(builder | ||
src/main.cpp | ||
) | ||
target_link_libraries(builder | ||
PRIVATE | ||
cppparser | ||
) |
Oops, something went wrong.