Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] devel from choreonoid:master #10

Open
wants to merge 41 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d320ff9
add property: joint_state_publication for on/off publishing joint_state
YoheiKakiuchi Jul 5, 2023
7a9d30e
Support ROS 2 Humble
HansRobo Dec 1, 2023
56c4103
Import deliverables from choreonoid_ros2
HansRobo Dec 1, 2023
ca12d80
Switch dependencies by ROS version in package.xml
HansRobo Dec 2, 2023
49509fe
Switch behaviors by ROS version in node/CMakeLists.txt
HansRobo Dec 2, 2023
fcd23c7
Stop using ROS2Plugin as ROS 2 node
HansRobo Feb 23, 2024
fa1e3b5
Use ROS 2 node with delegation instead of inheritance in
HansRobo Feb 23, 2024
0a57d74
Organize init/shutdown process of ROS 2 with custom context in BodyROS2
HansRobo Feb 23, 2024
08099e0
Set topic namespace by item name in BodyROS2Item
HansRobo Feb 23, 2024
73522da
Rename node_ into rosNode in BodyROS2Item
HansRobo Feb 23, 2024
4248be6
Delete init/shutdown process of ROS 2 from app
HansRobo Feb 23, 2024
12339fa
[BodyROS2] Fix 3D range sensor frames and improve memory efficiency
ssr-yuki Mar 1, 2024
81e9d0c
Use camelCase instead of snake_case
HansRobo Mar 2, 2024
7c78abb
Clean up naming from the choreonoid_ros2
HansRobo Mar 2, 2024
e90b11e
Drop PointCloud(1) support from ROS 2 plugin
HansRobo Mar 2, 2024
dc516f7
Place joint_state topic under the namespace that each BodyROS2Item has
HansRobo Mar 2, 2024
bc75d94
Fix library path for choreonoid app for ROS 2
HansRobo Mar 7, 2024
b18e146
Format header guard style
HansRobo Mar 7, 2024
8f0fcdf
Clean up unused header includes
HansRobo Mar 8, 2024
86b3adf
Use PointCould2 instead of PointCloud for 3DRangeSensor
HansRobo Mar 8, 2024
70d8d65
Enable to launch with ros 2
ssr-yuki Mar 1, 2024
b52bdf0
Merge pull request #19 from choreonoid/ros2-launch
HansRobo Mar 13, 2024
c2d039f
[BodyROS2] Use joint names for joint states surely
ssr-yuki Mar 17, 2024
422489e
Fix the initialization of the additional plugin path in the choreonoi…
s-nakaoka Mar 21, 2024
941e09d
[BodyROS2] Correct RangeVisionSensor frames
ssr-yuki Mar 18, 2024
c887ce0
Fix installation conditions of 'launch' files with catkin
ssr-yuki May 1, 2024
24c2526
Fix ROS2Plugin not to install in the normal lib directory
s-nakaoka May 6, 2024
7ca2b54
Improve the choreonoid command for ROS 2 to set plugin directories fo…
s-nakaoka May 6, 2024
84ef6d3
Improve the creation and finalization of ROS nodes and executors for …
s-nakaoka May 9, 2024
d54f738
Fix a bug in setting a nanosec value of the /clock topic in WorldROS2…
s-nakaoka May 14, 2024
a7e716a
Introduce a header to use the format function in various environments
s-nakaoka Jul 30, 2024
c4e65d1
[BodyROS] Use correct lists for imu publishers/switch servers
HansRobo Aug 23, 2024
d3d7851
[BodyROS2] Support IMU (porting from BodyROS)
HansRobo Aug 23, 2024
8d2b078
Add the link to the ament_index_cpp library to compile with jazzy
s-nakaoka Sep 3, 2024
de948af
Add dependency on ament_index_cpp in package.xml
s-nakaoka Sep 10, 2024
2d335ed
Merge branch 'feature/imu_ros2'
s-nakaoka Oct 9, 2024
1c69cf2
Improve BodyROS2Item to publish sensor data in separate threads to in…
s-nakaoka Oct 5, 2024
c36cb7b
Merge remote-tracking branch 'github/fix-launch-dir-installation'
s-nakaoka Oct 9, 2024
06787c6
Fix package.xml to depend on image_transport_plugins to support image…
s-nakaoka Oct 13, 2024
78154f9
Improve the robustness of BodyROS2Item
s-nakaoka Jan 10, 2025
a8e754a
Fix BodyROS2Item to support the spherical angle data of RangeSensor
s-nakaoka Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: build test

on:
workflow_dispatch:
pull_request:

jobs:
build:
name: build
runs-on: ubuntu-22.04
timeout-minutes: 120
strategy:
fail-fast: false
env:
ROS_DISTRO: humble
container:
image: osrf/ros:humble-desktop-jammy
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install dependencies of choreonoid
run: |
apt-get update && \
apt-get -y upgrade && \
apt-get -y install \
build-essential \
cmake-curses-gui \
libboost-dev \
libboost-system-dev \
libboost-program-options-dev \
libboost-iostreams-dev \
libeigen3-dev \
uuid-dev \
libxfixes-dev \
libyaml-dev \
libfmt-dev \
gettext \
zlib1g-dev \
libjpeg-dev \
libpng-dev \
libfreetype-dev \
qtbase5-dev \
libqt5x11extras5-dev \
libqt5svg5-dev \
qttranslations5-l10n \
python3-dev \
python3-numpy \
libassimp-dev \
libode-dev \
libfcl-dev \
libpulse-dev \
libsndfile1-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libzip-dev \
python3-colcon-coveragepy-result \
python3-colcon-lcov-result

- name: Run build test
uses: ros-tooling/[email protected]
with:
target-ros2-distro: humble
vcs-repo-file-url: dependency.repos
extra-cmake-args: -DWITH_INTEGRATION_TEST=ON
# If possible, pin the repository in the workflow to a specific commit to avoid
# changes in colcon-mixin-repository from breaking your tests.
80 changes: 54 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,39 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

find_package(
catkin REQUIRED COMPONENTS
choreonoid
roscpp
std_msgs
sensor_msgs
image_transport

# For ros_control
pluginlib
angles
controller_manager
hardware_interface
joint_limits_interface
transmission_interface
urdf
)

catkin_package(SKIP_CMAKE_CONFIG_GENERATION SKIP_PKG_CONFIG_GENERATION)
if(DEFINED ENV{ROS_VERSION})
if($ENV{ROS_VERSION} EQUAL 1)
find_package(
catkin REQUIRED COMPONENTS
roscpp
pluginlib
angles
controller_manager
hardware_interface
joint_limits_interface
transmission_interface
urdf
)
elseif ($ENV{ROS_VERSION} EQUAL 2)
find_package(
ament_cmake REQUIRED COMPONENTS
rclcpp ament_index_cpp
)
endif()
endif()

find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(choreonoid REQUIRED)

if(DEFINED ENV{ROS_VERSION})
if($ENV{ROS_VERSION} EQUAL 1)
catkin_package(SKIP_CMAKE_CONFIG_GENERATION SKIP_PKG_CONFIG_GENERATION)
include_directories(${catkin_INCLUDE_DIRS})
endif()
endif()

if(CHOREONOID_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CHOREONOID_CXX_STANDARD})
Expand All @@ -34,14 +48,28 @@ else()
add_compile_options(-std=c++14)
endif()

include_directories(${catkin_INCLUDE_DIRS})

add_subdirectory(src)

# For ros_control
install(FILES plugins.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
if(DEFINED ENV{ROS_VERSION})
if($ENV{ROS_VERSION} EQUAL 1)
# For ros_control
install(FILES plugins.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

# Install `launch` dir. only if `--install` option is set in catkin config
if(${CMAKE_INSTALL_PREFIX} MATCHES .*/install)
install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
PATTERN "ros2" EXCLUDE
)
endif()
elseif($ENV{ROS_VERSION} EQUAL 2)
ament_package()

install(DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
USE_SOURCE_PERMISSIONS
)
install(DIRECTORY
launch/ros2
DESTINATION share/${PROJECT_NAME}/launch
)
endif()
endif()
5 changes: 5 additions & 0 deletions dependency.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repositories:
choreonoid:
type: git
url: https://github.com/choreonoid/choreonoid.git
version: master
5 changes: 5 additions & 0 deletions launch/ros2/choreonoid.launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<launch>
<arg name="choreonoid_arg" default=""/>
<node name="choreonoid" pkg="choreonoid_ros" exec="choreonoid"
args="$(var choreonoid_arg)" output="screen"/>
</launch>
34 changes: 22 additions & 12 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<package format="2">
<package format="3">
<name>choreonoid_ros</name>
<version>1.7.0</version>
<description>The package for using Choreonoid as a ROS node</description>
Expand All @@ -10,22 +10,32 @@
<url type="website">http://choreonoid.org</url>
<url type="repository">https://github.com/choreonoid/choreonoid_ros.git</url>

<buildtool_depend>catkin</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend>
<buildtool_depend condition="$ROS_VERSION == 2">ament_cmake</buildtool_depend>
<depend>choreonoid</depend>
<depend>roscpp</depend>

<depend condition="$ROS_VERSION == 1">roscpp</depend>
<depend condition="$ROS_VERSION == 2">rclcpp</depend>

<depend>std_msgs</depend>
<depend>std_srvs</depend>
<depend>geometry_msgs</depend>
<depend>sensor_msgs</depend>
<depend>image_transport</depend>
<depend>pluginlib</depend>
<depend>angles</depend>
<depend>controller_manager</depend>
<depend>hardware_interface</depend>
<depend>joint_limits_interface</depend>
<depend>transmission_interface</depend>
<depend>urdf</depend>
<depend>image_transport_plugins</depend>

<depend condition="$ROS_VERSION == 1">pluginlib</depend>
<depend condition="$ROS_VERSION == 1">angles</depend>
<depend condition="$ROS_VERSION == 1">controller_manager</depend>
<depend condition="$ROS_VERSION == 1">hardware_interface</depend>
<depend condition="$ROS_VERSION == 1">joint_limits_interface</depend>
<depend condition="$ROS_VERSION == 1">transmission_interface</depend>
<depend condition="$ROS_VERSION == 1">urdf</depend>
<depend condition="$ROS_VERSION == 2">ament_index_cpp</depend>

<export>
<build_type>cmake</build_type>
<choreonoid_ros plugin="${prefix}/plugins.xml" />
<build_type condition="$ROS_VERSION == 1">cmake</build_type>
<build_type condition="$ROS_VERSION == 2">ament_cmake</build_type>
<choreonoid_ros plugin="${prefix}/plugins.xml"/>
</export>
</package>
22 changes: 17 additions & 5 deletions src/node/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
set(target choreonoid_ros)
add_executable(${target} choreonoid_ros.cpp)
set_target_properties(${target} PROPERTIES OUTPUT_NAME choreonoid)
target_link_libraries(${target} Choreonoid::CnoidBase ${roscpp_LIBRARIES})
install(TARGETS ${target} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
set(target choreonoid)

if(DEFINED ENV{ROS_VERSION})
if($ENV{ROS_VERSION} EQUAL 1)
add_executable(${target} choreonoid_ros.cpp)
set_target_properties(${target} PROPERTIES OUTPUT_NAME choreonoid)
target_link_libraries(${target} Choreonoid::CnoidBase ${roscpp_LIBRARIES})
install(TARGETS ${target} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
elseif($ENV{ROS_VERSION} EQUAL 2)
add_executable(${target} choreonoid_ros2.cpp)
ament_target_dependencies(${target} rclcpp ament_index_cpp std_msgs sensor_msgs image_transport)
set_target_properties(${target} PROPERTIES OUTPUT_NAME choreonoid)
target_link_libraries(${target} Choreonoid::CnoidBase)
install(TARGETS ${target}
RUNTIME DESTINATION lib/${PROJECT_NAME})
endif()
endif()
73 changes: 73 additions & 0 deletions src/node/choreonoid_ros2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include <ament_index_cpp/get_package_prefix.hpp>
#include <rclcpp/utilities.hpp>

#include <cnoid/App>
#include <cnoid/PluginManager>
#include <cnoid/UTF8>

#include <string>
#include <vector>
#include <iostream>

int main(int argc, char** argv)
{
// removes ros-dependent arguments
// rclcpp::remove_ros_arguments throws an error if it fails parsing
std::vector<std::string> nonRosArgvString = rclcpp::remove_ros_arguments(argc, argv);
int nonRosArgc = nonRosArgvString.size();
char* nonRosArgv[nonRosArgc];
for (int i = 0; i < nonRosArgc; ++i) {
nonRosArgv[i] = nonRosArgvString.at(i).data();
}
if (nonRosArgvString.at(nonRosArgc - 1).empty()) {
// ignores the final nonRosArgv
// because remove_ros_arguments potentially returns an empty string,
// which causes [Warning: Input file "" was not processed.] on Choreonoid
--nonRosArgc;
}

cnoid::App app(nonRosArgc, nonRosArgv, "Choreonoid-ROS2", "Choreonoid");

auto pluginManager = cnoid::PluginManager::instance();

const char* prefixVar = getenv("AMENT_PREFIX_PATH");
if(prefixVar){
do {
const char* begin = prefixVar;
while(*prefixVar != ':' && *prefixVar) prefixVar++;
pluginManager->addPluginDirectoryAsPrefix(cnoid::toUTF8(std::string(begin, prefixVar)));
} while (0 != *prefixVar++);
} else {
try {
pluginManager->addPluginDirectoryAsPrefix(
ament_index_cpp::get_package_prefix("choreonoid_ros"));
}
catch(const ament_index_cpp::PackageNotFoundError& ex){
std::cerr << "Error: The choreonoid_ros package is not found." << std::endl;
return 1;
}
}

if(!app.requirePluginToCustomizeApplication("ROS2")){
if(app.error() == cnoid::App::PluginNotFound){
auto message = app.errorMessage();
if(message.empty()){
std::cerr << "ROS2 plugin is not found." << std::endl;
} else {
std::cerr << "ROS2 plugin cannot be loaded.\n";
std::cerr << message << std::endl;
}
} else {
std::cerr << "ROS2 plugin does not work corerctly." << std::endl;
}
return 1;
}

rclcpp::init(argc, argv);

int ret = app.exec();

rclcpp::shutdown();

return ret;
}
Loading