Skip to content

Commit

Permalink
[WIP] ROS2 migration of the cob_hardware_config package
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-nhg committed Mar 12, 2024
1 parent cc76524 commit 4154764
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 709 deletions.
37 changes: 12 additions & 25 deletions cob_hardware_config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.5)
project(cob_hardware_config)

find_package(catkin REQUIRED)
catkin_package()
find_package(ament_cmake REQUIRED)

### TESTING ###
if(CATKIN_ENABLE_TESTING)
find_package(cob_supported_robots REQUIRED)
find_package(roslaunch REQUIRED)
find_package(rostest REQUIRED)
# loop through list of robots for testing
foreach(robot ${cob_supported_robots_ROBOTLIST})
message("testing for robot: ${robot}")
roslaunch_add_file_check(upload_robot.launch robot:=${robot})
add_rostest(test/urdf.test ARGS robot:=${robot})
endforeach()
endif()

### INSTALL ###
install(DIRECTORY robots test
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
install(
DIRECTORY robots launch test
DESTINATION share/${PROJECT_NAME}
)

install(FILES upload_robot.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})

install(FILES display_robot.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
if(BUILD_TESTING)
find_package(ament_cmake_pytest REQUIRED)
ament_add_pytest_test(ur_urdf_xacro test/test_view_cob_launch.py)
endif()

ament_package()
27 changes: 0 additions & 27 deletions cob_hardware_config/display_robot.launch

This file was deleted.

96 changes: 96 additions & 0 deletions cob_hardware_config/launch/display_robot.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright 2024 Fraunhofer IPA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Nadia Hammoudeh Garcia

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
from ament_index_python.packages import get_package_share_directory
from launch_ros.parameters_type import ParameterValue
import os
import xacro
import subprocess

def generate_launch_description():
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"robot",
description="Robot name.",
choices=["cob4-25"],
)
)
declared_arguments.append(
DeclareLaunchArgument(
"pkg_hardware_config",
default_value="cob_hardware_config",
description="Name of the package that contains the robot configuration.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"description_file",
default_value=[LaunchConfiguration("robot"),".urdf.xacro"],
description="File containing the robot description.",
)
)

# Initialize Arguments
robot = LaunchConfiguration("robot")
pkg_hardware_config = LaunchConfiguration("pkg_hardware_config")
description_file = LaunchConfiguration("description_file")

xacro_file= os.path.join(get_package_share_directory("cob_hardware_config"),"robots","cob4-25","urdf","cob4-25.urdf.xacro")
doc = xacro.parse(open(xacro_file))
xacro.process_doc(doc)
robot_description = {'robot_description': doc.toxml()}

# xacro_command = [
# "xacro",
# PathJoinSubstitution([FindPackageShare(pkg_hardware_config), "robots", robot, "urdf", description_file]),
# ]
# robot_description = {"robot_description": Command(xacro_command)}

rviz_config_file = PathJoinSubstitution(
[FindPackageShare(pkg_hardware_config), "robots", robot, "view_robot.rviz"]
)

joint_state_publisher_node = Node(
package="joint_state_publisher_gui",
executable="joint_state_publisher_gui",
)
robot_state_publisher_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_config_file],
)

nodes_to_start = [
joint_state_publisher_node,
robot_state_publisher_node,
rviz_node,
]

return LaunchDescription(declared_arguments + nodes_to_start)
36 changes: 18 additions & 18 deletions cob_hardware_config/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@

<maintainer email="[email protected]">Felix Messmer</maintainer>
<author email="[email protected]">Felix Messmer</author>
<author email="[email protected]">Nadia Hammoudeh Garcia</author>
<author email="[email protected]">Florian Weisshardt</author>
<author email="[email protected]">Nadia Hammoudeh Garcia</author>

<buildtool_depend>catkin</buildtool_depend>

<buildtool_depend>ament_cmake</buildtool_depend>

<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>cob_calibration_data</exec_depend>
<exec_depend>cob_description</exec_depend>
<exec_depend>cob_omni_drive_controller</exec_depend>
<exec_depend>costmap_2d</exec_depend>
<exec_depend>diagnostic_aggregator</exec_depend>
<exec_depend>joint_state_controller</exec_depend>
<exec_depend>joint_state_publisher</exec_depend>
<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>joint_trajectory_controller</exec_depend>
<exec_depend>laser_filters</exec_depend>
<exec_depend>position_controllers</exec_depend>
<exec_depend>raw_description</exec_depend>

<exec_depend>launch</exec_depend>
<exec_depend>launch_ros</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>rviz</exec_depend>
<!--exec_depend>ur_description</exec_depend-->
<exec_depend>velocity_controllers</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>urdf</exec_depend>
<exec_depend>xacro</exec_depend>

<test_depend>cob_supported_robots</test_depend>
<test_depend>roslaunch</test_depend>
<test_depend>rostest</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>launch_testing_ament_cmake</test_depend>
<test_depend>launch_testing_ros</test_depend>
<test_depend>liburdfdom-tools</test_depend>
<test_depend>xacro</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>

</package>
Loading

0 comments on commit 4154764

Please sign in to comment.