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

[Modify]: add cyberdog_tf_publish launch file for visualizing the rob… #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions cyberdog_visual/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ find_package(tf2_eigen REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(gazebo_msgs REQUIRED)
find_package(lcm REQUIRED)
find_package(urdf REQUIRED)
set(dependencies
Expand All @@ -33,7 +32,6 @@ set(dependencies
tf2_geometry_msgs
tf2_ros
sensor_msgs
gazebo_msgs
urdf
lcm
Eigen3
Expand Down
80 changes: 80 additions & 0 deletions cyberdog_visual/launch/cyberdog_tf_publish.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os
import launch
import xacro
from launch.actions import DeclareLaunchArgument
from launch.actions import OpaqueFunction
from launch.substitutions import Command, LaunchConfiguration, PythonExpression
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare

def launch_setup(context, *args, **kwargs):
# config
hang_robot = LaunchConfiguration('hang_robot').perform(context)
use_lidar = LaunchConfiguration('use_lidar').perform(context)
rname = LaunchConfiguration('rname').perform(context)
use_sim_time=LaunchConfiguration('use_sim_time')

# path
description_share = FindPackageShare(
package=rname+'_description').find(rname+'_description')
visual_share = FindPackageShare(
package='cyberdog_visual').find('cyberdog_visual')

# urdf
xacro_path = os.path.join(description_share, 'xacro/robot.xacro')
urdf_contents = xacro.process_file(xacro_path, mappings={
'DEBUG': hang_robot, 'USE_LIDAR': use_lidar}).toprettyxml(indent=' ')

# joint_state_publisher
joint_state_node = Node(
package='cyberdog_visual',
executable='cyberdog_visual',
name='cyberdog_visual',
output='screen',
parameters=[{
'robot_description': urdf_contents,
'publish_frequency': 50.0,
'joint_state_topic': 'joint_states',
'use_sim_time': use_sim_time,
'use_state_estimator': False
}
]
)

# robot_state_publisher
robot_state_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
output='screen',
parameters=[
{
'robot_description': urdf_contents,
'publish_frequency': 50.0,
'use_sim_time': use_sim_time
}
]
)

return [joint_state_node, robot_state_node]

def generate_launch_description():
return launch.LaunchDescription([
DeclareLaunchArgument(
name='use_sim_time',
default_value='false'
),
DeclareLaunchArgument(
name='hang_robot',
default_value='false'
),
DeclareLaunchArgument(
name='use_lidar',
default_value='false'
),
DeclareLaunchArgument(
name='rname',
default_value='cyberdog'
),
OpaqueFunction(function=launch_setup)
])
1 change: 0 additions & 1 deletion cyberdog_visual/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<depend>tf2_ros</depend>
<depend>tf2_geometry_msgs</depend>
<depend>sensor_msgs</depend>
<depend>gazebo_msgs</depend>
<depend>urdf</depend>

<export>
Expand Down