diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6030f9..453fab5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,5 +62,10 @@ if(DEFINED ENV{ROS_VERSION})
)
elseif($ENV{ROS_VERSION} EQUAL 2)
ament_package()
+
+ install(DIRECTORY
+ launch/ros2
+ DESTINATION share/${PROJECT_NAME}/launch
+ )
endif()
endif()
diff --git a/launch/ros2/choreonoid.launch.xml b/launch/ros2/choreonoid.launch.xml
new file mode 100644
index 0000000..b872dd1
--- /dev/null
+++ b/launch/ros2/choreonoid.launch.xml
@@ -0,0 +1,5 @@
+
+
+
+
diff --git a/src/node/choreonoid_ros2.cpp b/src/node/choreonoid_ros2.cpp
index 3b710dc..65e40ec 100644
--- a/src/node/choreonoid_ros2.cpp
+++ b/src/node/choreonoid_ros2.cpp
@@ -1,15 +1,35 @@
#include
+#include
+
#include
#include
#include
#include
#include
#include
+
+#include
+#include
#include
int main(int argc, char** argv)
{
- cnoid::App app(argc, argv, "Choreonoid-ROS2", "Choreonoid");
+ // removes ros-dependent arguments
+ // rclcpp::remove_ros_arguments throws an error if it fails parsing
+ std::vector 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 plugin_manager = cnoid::PluginManager::instance();