From f72dc3e583577d7f298a22fdbbf52d6bbf9fd7d8 Mon Sep 17 00:00:00 2001 From: Rooholla-KhorramBakht Date: Sat, 4 May 2024 15:45:27 -0400 Subject: [PATCH] robot description publisher service is added --- Makefile | 15 +- deploy/docker/Dockerfile.robot_description | 31 ++ deploy/docker/scripts/robot_description.sh | 4 + .../robot_description.launch.py} | 49 +- .../launch/visualize_go2.launch.py | 44 +- .../go2_description/xacro/robot.urdf | 469 ------------------ .../go2_description/xacro/robot.xacro | 28 +- .../xacro/robot_virtual_arm.xacro | 147 ------ deploy/ros2_nodes/unitree_api/CMakeLists.txt | 64 --- deploy/ros2_nodes/unitree_api/msg/Request.msg | 3 - .../unitree_api/msg/RequestHeader.msg | 3 - .../unitree_api/msg/RequestIdentity.msg | 2 - .../unitree_api/msg/RequestLease.msg | 1 - .../unitree_api/msg/RequestPolicy.msg | 2 - .../ros2_nodes/unitree_api/msg/Response.msg | 3 - .../unitree_api/msg/ResponseHeader.msg | 2 - .../unitree_api/msg/ResponseStatus.msg | 1 - deploy/ros2_nodes/unitree_api/package.xml | 23 - .../services/go2py-robot-description.service | 13 + 19 files changed, 98 insertions(+), 806 deletions(-) create mode 100644 deploy/docker/Dockerfile.robot_description create mode 100644 deploy/docker/scripts/robot_description.sh rename deploy/{ros2_nodes/go2_description/launch/visualize_go2_virtual_arm.launch.py => launch_files/robot_description.launch.py} (58%) delete mode 100644 deploy/ros2_nodes/go2_description/xacro/robot.urdf delete mode 100755 deploy/ros2_nodes/go2_description/xacro/robot_virtual_arm.xacro delete mode 100755 deploy/ros2_nodes/unitree_api/CMakeLists.txt delete mode 100755 deploy/ros2_nodes/unitree_api/msg/Request.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/RequestHeader.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/RequestIdentity.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/RequestLease.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/RequestPolicy.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/Response.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/ResponseHeader.msg delete mode 100755 deploy/ros2_nodes/unitree_api/msg/ResponseStatus.msg delete mode 100755 deploy/ros2_nodes/unitree_api/package.xml create mode 100644 deploy/services/go2py-robot-description.service diff --git a/Makefile b/Makefile index 6463e4a..a43de35 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ hesai: bridge: @cd deploy && docker build --no-cache --tag go2py_bridge:latest -f docker/Dockerfile.bridge . +robot_description: + @cd deploy && docker build --no-cache --tag go2py_description:latest -f docker/Dockerfile.robot_description . + hesai_install: @cp deploy/services/go2py-hesai.service /etc/systemd/system/ @systemctl enable go2py-hesai.service @@ -13,6 +16,11 @@ bridge_install: @cp deploy/services/go2py-bridge.service /etc/systemd/system/ @systemctl enable go2py-bridge.service @systemctl start go2py-bridge.service + +robot_description_install: + @cp deploy/services/go2py-robot-description.service /etc/systemd/system/ + @systemctl enable go2py-robot-description.service + @systemctl start go2py-robot-description.service hesai_uninstall: @systemctl disable go2py-hesai.service @@ -22,4 +30,9 @@ hesai_uninstall: bridge_uninstall: @systemctl disable go2py-bridge.service @systemctl stop go2py-bridge.service - @rm /etc/systemd/system/go2py-bridge.service \ No newline at end of file + @rm /etc/systemd/system/go2py-bridge.service + +robot_description_uninstall: + @systemctl disable go2py-robot-description.service + @systemctl stop go2py-robot-description.service + @rm /etc/systemd/system/go2py-robot-description.service \ No newline at end of file diff --git a/deploy/docker/Dockerfile.robot_description b/deploy/docker/Dockerfile.robot_description new file mode 100644 index 0000000..6929ec2 --- /dev/null +++ b/deploy/docker/Dockerfile.robot_description @@ -0,0 +1,31 @@ +# FROM isaac_ros_dev-aarch64 +FROM ros:humble +ENV DEBIAN_FRONTEND=noninteractive +SHELL ["/bin/bash", "-c"] +# uodate and install dependencies +RUN apt-get update && apt-get install -y \ + ros-humble-rmw-cyclonedds-cpp ros-humble-rosidl-generator-dds-idl \ + libyaml-cpp-dev \ + ros-humble-xacro \ + libboost-all-dev\ + build-essential \ + cmake \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Cheange the ROS2 RMW to CycloneDDS as instructed by Unitree +RUN cd / && git clone https://github.com/unitreerobotics/unitree_ros2 && cd /unitree_ros2/cyclonedds_ws/src && \ +git clone https://github.com/ros2/rmw_cyclonedds -b humble && git clone https://github.com/eclipse-cyclonedds/cyclonedds -b releases/0.10.x &&\ +cd .. && colcon build --packages-select cyclonedds && source /opt/ros/humble/setup.bash && colcon build + +# ros2 nodes +COPY ros2_nodes/go2_description /ros2_ws/src/go2_description +RUN cd /ros2_ws && source /opt/ros/humble/setup.bash && source /unitree_ros2/cyclonedds_ws/install/setup.bash && colcon build --symlink-install + +# Copy the script to start the nodes +COPY docker/scripts /root/scripts +COPY launch_files /root/launch + +# set the entrypoint to bash +#ENTRYPOINT ["/bin/bash"] +ENTRYPOINT ["/bin/bash", "/root/scripts/robot_description.sh"] diff --git a/deploy/docker/scripts/robot_description.sh b/deploy/docker/scripts/robot_description.sh new file mode 100644 index 0000000..e8f9482 --- /dev/null +++ b/deploy/docker/scripts/robot_description.sh @@ -0,0 +1,4 @@ +source /opt/ros/humble/setup.bash +source /unitree_ros2/cyclonedds_ws/install/setup.bash +export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp +source /ros2_ws/install/setup.bash && ros2 launch /root/launch/robot_description.launch.py \ No newline at end of file diff --git a/deploy/ros2_nodes/go2_description/launch/visualize_go2_virtual_arm.launch.py b/deploy/launch_files/robot_description.launch.py similarity index 58% rename from deploy/ros2_nodes/go2_description/launch/visualize_go2_virtual_arm.launch.py rename to deploy/launch_files/robot_description.launch.py index 4625cf1..1f7b2ed 100644 --- a/deploy/ros2_nodes/go2_description/launch/visualize_go2_virtual_arm.launch.py +++ b/deploy/launch_files/robot_description.launch.py @@ -1,38 +1,22 @@ +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import ThisLaunchFileDir +from launch_ros.actions import Node +from launch.substitutions import Command, FindExecutable, LaunchConfiguration +from ament_index_python.packages import get_package_share_directory import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument -from launch.substitutions import Command, FindExecutable, LaunchConfiguration -from launch_ros.actions import Node - - def generate_launch_description(): - user_debug_parameter_name = "user_debug" - user_debug = LaunchConfiguration(user_debug_parameter_name) - # prefix = LaunchConfiguration("prefix", default="go2/") - go2_xacro_file = os.path.join( - get_package_share_directory("go2_description"), - "xacro", - "robot_virtual_arm.xacro", + get_package_share_directory("go2_description"), "xacro", "robot.xacro" ) robot_description = Command( - [FindExecutable(name="xacro"), " ", go2_xacro_file, " DEBUG:=", user_debug] + [FindExecutable(name="xacro"), " ", go2_xacro_file, " DEBUG:=", 'false'] ) - rviz_file = os.path.join( - get_package_share_directory("go2_description"), "launch", "visualize_go2.rviz" - ) - - return LaunchDescription( - [ - DeclareLaunchArgument( - user_debug_parameter_name, - default_value="false", - description="debug or not", - ), - Node( + return LaunchDescription([ + Node( package="robot_state_publisher", executable="robot_state_publisher", name="robot_state_publisher", @@ -43,13 +27,7 @@ def generate_launch_description(): ("/robot_description", "/go2/robot_description"), ], ), - Node( - package="rviz2", - executable="rviz2", - name="rviz2", - arguments=["--display-config", rviz_file], - ), - Node( + Node( package="tf2_ros", executable="static_transform_publisher", arguments=[ @@ -65,5 +43,4 @@ def generate_launch_description(): ], name="static_tf_pub_trunk_to_lidar", ), - ] - ) + ]) \ No newline at end of file diff --git a/deploy/ros2_nodes/go2_description/launch/visualize_go2.launch.py b/deploy/ros2_nodes/go2_description/launch/visualize_go2.launch.py index 7826f97..50ecdd3 100644 --- a/deploy/ros2_nodes/go2_description/launch/visualize_go2.launch.py +++ b/deploy/ros2_nodes/go2_description/launch/visualize_go2.launch.py @@ -41,27 +41,27 @@ def generate_launch_description(): ("/robot_description", "/go2/robot_description"), ], ), - Node( - package="rviz2", - executable="rviz2", - name="rviz2", - arguments=["--display-config", rviz_file], - ), - Node( - package="tf2_ros", - executable="static_transform_publisher", - arguments=[ - "0.15", - "0", - "0.15", - "0", - "0", - "0.707107", - "0.707107", - "/trunk", - "/go2/hesai_lidar", - ], - name="static_tf_pub_trunk_to_lidar", - ), + # Node( + # package="rviz2", + # executable="rviz2", + # name="rviz2", + # arguments=["--display-config", rviz_file], + # ), + # Node( + # package="tf2_ros", + # executable="static_transform_publisher", + # arguments=[ + # "0.15", + # "0", + # "0.15", + # "0", + # "0", + # "0.707107", + # "0.707107", + # "/trunk", + # "/go2/hesai_lidar", + # ], + # name="static_tf_pub_trunk_to_lidar", + # ), ] ) diff --git a/deploy/ros2_nodes/go2_description/xacro/robot.urdf b/deploy/ros2_nodes/go2_description/xacro/robot.urdf deleted file mode 100644 index bcaacf2..0000000 --- a/deploy/ros2_nodes/go2_description/xacro/robot.urdf +++ /dev/null @@ -1,469 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deploy/ros2_nodes/go2_description/xacro/robot.xacro b/deploy/ros2_nodes/go2_description/xacro/robot.xacro index bbf43c5..7df040a 100755 --- a/deploy/ros2_nodes/go2_description/xacro/robot.xacro +++ b/deploy/ros2_nodes/go2_description/xacro/robot.xacro @@ -91,33 +91,7 @@ - + diff --git a/deploy/ros2_nodes/go2_description/xacro/robot_virtual_arm.xacro b/deploy/ros2_nodes/go2_description/xacro/robot_virtual_arm.xacro deleted file mode 100755 index 9119e85..0000000 --- a/deploy/ros2_nodes/go2_description/xacro/robot_virtual_arm.xacro +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deploy/ros2_nodes/unitree_api/CMakeLists.txt b/deploy/ros2_nodes/unitree_api/CMakeLists.txt deleted file mode 100755 index 4e7c4b9..0000000 --- a/deploy/ros2_nodes/unitree_api/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(unitree_api) - -# Default to C99 -if(NOT CMAKE_C_STANDARD) - set(CMAKE_C_STANDARD 99) -endif() - -# Default to C++14 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) - -find_package(geometry_msgs REQUIRED) -find_package(rosidl_default_generators REQUIRED) -find_package(rosidl_generator_dds_idl REQUIRED) - -rosidl_generate_interfaces(${PROJECT_NAME} - "msg/Request.msg" - "msg/RequestHeader.msg" - "msg/RequestIdentity.msg" - "msg/RequestLease.msg" - "msg/RequestPolicy.msg" - "msg/Response.msg" - "msg/ResponseHeader.msg" - "msg/ResponseStatus.msg" - - DEPENDENCIES geometry_msgs -) - -rosidl_generate_dds_interfaces( - ${rosidl_generate_interfaces_TARGET}__dds_connext_idl - IDL_TUPLES ${rosidl_generate_interfaces_IDL_TUPLES} - OUTPUT_SUBFOLDERS "dds_connext" -) -add_dependencies( - ${PROJECT_NAME} - ${PROJECT_NAME}__dds_connext_idl -) - - - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # uncomment the line when a copyright and license is not present in all source files - #set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # uncomment the line when this package is not in a git repo - #set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package() diff --git a/deploy/ros2_nodes/unitree_api/msg/Request.msg b/deploy/ros2_nodes/unitree_api/msg/Request.msg deleted file mode 100755 index b1df58a..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/Request.msg +++ /dev/null @@ -1,3 +0,0 @@ -RequestHeader header -string parameter -uint8[] binary \ No newline at end of file diff --git a/deploy/ros2_nodes/unitree_api/msg/RequestHeader.msg b/deploy/ros2_nodes/unitree_api/msg/RequestHeader.msg deleted file mode 100755 index 022161b..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/RequestHeader.msg +++ /dev/null @@ -1,3 +0,0 @@ -RequestIdentity identity -RequestLease lease -RequestPolicy policy \ No newline at end of file diff --git a/deploy/ros2_nodes/unitree_api/msg/RequestIdentity.msg b/deploy/ros2_nodes/unitree_api/msg/RequestIdentity.msg deleted file mode 100755 index 90011ff..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/RequestIdentity.msg +++ /dev/null @@ -1,2 +0,0 @@ -int64 id -int64 api_id \ No newline at end of file diff --git a/deploy/ros2_nodes/unitree_api/msg/RequestLease.msg b/deploy/ros2_nodes/unitree_api/msg/RequestLease.msg deleted file mode 100755 index 85f692f..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/RequestLease.msg +++ /dev/null @@ -1 +0,0 @@ -int64 id \ No newline at end of file diff --git a/deploy/ros2_nodes/unitree_api/msg/RequestPolicy.msg b/deploy/ros2_nodes/unitree_api/msg/RequestPolicy.msg deleted file mode 100755 index 89e00c2..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/RequestPolicy.msg +++ /dev/null @@ -1,2 +0,0 @@ -int32 priority -bool noreply \ No newline at end of file diff --git a/deploy/ros2_nodes/unitree_api/msg/Response.msg b/deploy/ros2_nodes/unitree_api/msg/Response.msg deleted file mode 100755 index 2036630..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/Response.msg +++ /dev/null @@ -1,3 +0,0 @@ -ResponseHeader header -string data -int8[] binary diff --git a/deploy/ros2_nodes/unitree_api/msg/ResponseHeader.msg b/deploy/ros2_nodes/unitree_api/msg/ResponseHeader.msg deleted file mode 100755 index 3d51649..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/ResponseHeader.msg +++ /dev/null @@ -1,2 +0,0 @@ -RequestIdentity identity -ResponseStatus status diff --git a/deploy/ros2_nodes/unitree_api/msg/ResponseStatus.msg b/deploy/ros2_nodes/unitree_api/msg/ResponseStatus.msg deleted file mode 100755 index 1d379fa..0000000 --- a/deploy/ros2_nodes/unitree_api/msg/ResponseStatus.msg +++ /dev/null @@ -1 +0,0 @@ -int32 code \ No newline at end of file diff --git a/deploy/ros2_nodes/unitree_api/package.xml b/deploy/ros2_nodes/unitree_api/package.xml deleted file mode 100755 index 915a946..0000000 --- a/deploy/ros2_nodes/unitree_api/package.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - unitree_api - 0.0.0 - TODO: Package description - czk - TODO: License declaration - - rosidl_default_generators - rosidl_default_runtime - rosidl_interface_packages - ament_cmake - - geometry_msgs - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/deploy/services/go2py-robot-description.service b/deploy/services/go2py-robot-description.service new file mode 100644 index 0000000..74e6cc2 --- /dev/null +++ b/deploy/services/go2py-robot-description.service @@ -0,0 +1,13 @@ +[Unit] +Description=ROS2 device driver container +Requires=multi-user.target +After=multi-user.target + +[Service] +Restart=always +ExecStartPre=/usr/bin/docker rm -f go2py_robot_description || true +ExecStart=/bin/bash -c '/usr/bin/docker run --rm --name go2py_robot_description --privileged --network host -v /home/unitree/locomotion:/home/locomotion -v /dev/*:/dev/* -v /etc/localtime:/etc/localtime:ro --runtime nvidia go2py_description:latest' +ExecStop=/usr/bin/docker stop -t 2 go2py_robot_description + +[Install] +WantedBy=default.target \ No newline at end of file