别人克隆后没有 install,source 会直接失败。把展开后的 install 放进仓库,符号链接和指向本机 build 的 egg-link 收成真实文件,Python 入口改走当前环境的解释器,这样不用先 colcon build 也能启动。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
arm_dev
2026-10-15 11:04:43 +08:00
parent 3c86441fb0
commit 926a7f9796
1492 changed files with 1302154 additions and 2 deletions
@@ -0,0 +1 @@
flexiv_description;robot_state_publisher;joint_state_publisher;joint_state_publisher_gui;xacro;rviz2
@@ -0,0 +1 @@
/home/cc/ros2/install/flexiv_bringup:/home/cc/ros2/install/flexiv_test_nodes:/home/cc/ros2/install/flexiv_robot_states_broadcaster:/home/cc/ros2/install/flexiv_gripper:/home/cc/ros2/install/flexiv_msgs:/home/cc/ros2/install/flexiv_hardware:/home/cc/ros2/install/arm_bringup:/home/cc/ros2/install/arm_moveit_config:/home/cc/ros2/install/arm_description:/home/cc/ros2/install/flexiv_description:/home/cc/ros2/install/arm_driver_flexiv:/home/cc/ros2/install/arm_control:/home/cc/ros2/install/arm_application:/home/cc/ros2/install/arm_msgs:/home/cc/ros2/install/arm_kinematics:/home/cc/ros2/install/arm_interfaces:/home/cc/anaconda3/envs/ros_flexiv
@@ -0,0 +1,14 @@
# generated from ament/cmake/core/templates/nameConfig-version.cmake.in
set(PACKAGE_VERSION "0.1.0")
set(PACKAGE_VERSION_EXACT False)
set(PACKAGE_VERSION_COMPATIBLE False)
if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_EXACT True)
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
if("${PACKAGE_FIND_VERSION}" VERSION_LESS "${PACKAGE_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE True)
endif()
@@ -0,0 +1,42 @@
# generated from ament/cmake/core/templates/nameConfig.cmake.in
# prevent multiple inclusion
if(_arm_description_CONFIG_INCLUDED)
# ensure to keep the found flag the same
if(NOT DEFINED arm_description_FOUND)
# explicitly set it to FALSE, otherwise CMake will set it to TRUE
set(arm_description_FOUND FALSE)
elseif(NOT arm_description_FOUND)
# use separate condition to avoid uninitialized variable warning
set(arm_description_FOUND FALSE)
endif()
return()
endif()
set(_arm_description_CONFIG_INCLUDED TRUE)
# output package information
if(NOT arm_description_FIND_QUIETLY)
message(STATUS "Found arm_description: 0.1.0 (${arm_description_DIR})")
endif()
# warn when using a deprecated package
if(NOT "" STREQUAL "")
set(_msg "Package 'arm_description' is deprecated")
# append custom deprecation text if available
if(NOT "" STREQUAL "TRUE")
set(_msg "${_msg} ()")
endif()
# optionally quiet the deprecation message
if(NOT ${arm_description_DEPRECATED_QUIET})
message(DEPRECATION "${_msg}")
endif()
endif()
# flag package as ament-based to distinguish it after being find_package()-ed
set(arm_description_FOUND_AMENT_PACKAGE TRUE)
# include all config extra files
set(_extras "")
foreach(_extra ${_extras})
include("${arm_description_DIR}/${_extra}")
endforeach()
@@ -0,0 +1,21 @@
# Flexiv Rizon 4 — site robot Rizon4-063989
robot_model: Rizon4
robot_sn: Rizon4-063989
dof: 7
load_gripper: false
# Official flexiv_description: SN hyphen is kept in the prefix
joint_prefix: "Rizon4-063989_"
joint_names:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
- joint7
base_frame: base_link
ee_frame: tcp
flange_frame: flange
@@ -0,0 +1 @@
prepend-non-duplicate;AMENT_PREFIX_PATH;
@@ -0,0 +1,4 @@
# copied from
# ament_cmake_core/cmake/environment_hooks/environment/ament_prefix_path.sh
ament_prepend_unique_value AMENT_PREFIX_PATH "$AMENT_CURRENT_PREFIX"
@@ -0,0 +1 @@
prepend-non-duplicate-if-exists;PATH;bin
@@ -0,0 +1,5 @@
# copied from ament_cmake_core/cmake/environment_hooks/environment/path.sh
if [ -d "$AMENT_CURRENT_PREFIX/bin" ]; then
ament_prepend_unique_value PATH "$AMENT_CURRENT_PREFIX/bin"
fi
@@ -0,0 +1 @@
prepend-non-duplicate;CMAKE_PREFIX_PATH;
@@ -0,0 +1,3 @@
# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em
colcon_prepend_unique_value CMAKE_PREFIX_PATH "$env:COLCON_CURRENT_PREFIX"
@@ -0,0 +1,3 @@
# generated from colcon_core/shell/template/hook_prepend_value.sh.em
_colcon_prepend_unique_value CMAKE_PREFIX_PATH "$COLCON_CURRENT_PREFIX"
@@ -0,0 +1,75 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import Command, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue
from launch_ros.substitutions import FindPackageShare
import os
def generate_launch_description():
use_gui = LaunchConfiguration('use_gui')
use_rviz = LaunchConfiguration('use_rviz')
robot_sn = LaunchConfiguration('robot_sn')
rizon_type = LaunchConfiguration('rizon_type')
load_gripper = LaunchConfiguration('load_gripper')
urdf_path = PathJoinSubstitution(
[FindPackageShare('arm_description'), 'urdf', 'arm.urdf.xacro']
)
rviz_config = PathJoinSubstitution(
[FindPackageShare('flexiv_description'), 'rviz', 'view_rizon.rviz']
)
robot_description = ParameterValue(
Command([
'xacro ', urdf_path,
' robot_sn:=', robot_sn,
' rizon_type:=', rizon_type,
' load_gripper:=', load_gripper,
]),
value_type=str,
)
return LaunchDescription([
DeclareLaunchArgument('use_gui', default_value='true'),
DeclareLaunchArgument('use_rviz', default_value='true'),
# 默认取当前臂(scripts/env.sh 已导出);不再写死某个 SN。
DeclareLaunchArgument(
'robot_sn',
default_value=os.environ.get('SITE_ROBOT_SN', '').strip(),
),
DeclareLaunchArgument('rizon_type', default_value='Rizon4'),
DeclareLaunchArgument('load_gripper', default_value='false'),
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
parameters=[{'robot_description': robot_description}],
output='screen',
),
Node(
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui',
name='joint_state_publisher_gui',
condition=IfCondition(use_gui),
output='screen',
),
Node(
package='joint_state_publisher',
executable='joint_state_publisher',
name='joint_state_publisher',
condition=UnlessCondition(use_gui),
output='screen',
),
Node(
package='rviz2',
executable='rviz2',
name='rviz2',
arguments=['-d', rviz_config],
condition=IfCondition(use_rviz),
output='screen',
),
])
@@ -0,0 +1,46 @@
# generated from ament_package/template/package_level/local_setup.bash.in
# source local_setup.sh from same directory as this file
_this_path=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" && pwd)
# provide AMENT_CURRENT_PREFIX to shell script
AMENT_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." && pwd)
# store AMENT_CURRENT_PREFIX to restore it before each environment hook
_package_local_setup_AMENT_CURRENT_PREFIX=$AMENT_CURRENT_PREFIX
# trace output
if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then
echo "# . \"$_this_path/local_setup.sh\""
fi
. "$_this_path/local_setup.sh"
unset _this_path
# unset AMENT_ENVIRONMENT_HOOKS
# if not appending to them for return
if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then
unset AMENT_ENVIRONMENT_HOOKS
fi
# restore AMENT_CURRENT_PREFIX before evaluating the environment hooks
AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX
# list all environment hooks of this package
# source all shell-specific environment hooks of this package
# if not returning them
if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then
_package_local_setup_IFS=$IFS
IFS=":"
for _hook in $AMENT_ENVIRONMENT_HOOKS; do
# restore AMENT_CURRENT_PREFIX for each environment hook
AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX
# restore IFS before sourcing other files
IFS=$_package_local_setup_IFS
. "$_hook"
done
unset _hook
IFS=$_package_local_setup_IFS
unset _package_local_setup_IFS
unset AMENT_ENVIRONMENT_HOOKS
fi
unset _package_local_setup_AMENT_CURRENT_PREFIX
unset AMENT_CURRENT_PREFIX
@@ -0,0 +1,2 @@
source;share/arm_description/environment/ament_prefix_path.sh
source;share/arm_description/environment/path.sh
@@ -0,0 +1,184 @@
# generated from ament_package/template/package_level/local_setup.sh.in
# since this file is sourced use either the provided AMENT_CURRENT_PREFIX
# or fall back to the destination set at configure time
: ${AMENT_CURRENT_PREFIX:="/home/cc/ros2/install/arm_description"}
if [ ! -d "$AMENT_CURRENT_PREFIX" ]; then
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
echo "The compile time prefix path '$AMENT_CURRENT_PREFIX' doesn't " \
"exist. Consider sourcing a different extension than '.sh'." 1>&2
else
AMENT_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX"
fi
fi
# function to append values to environment variables
# using colons as separators and avoiding leading separators
ament_append_value() {
# arguments
_listname="$1"
_value="$2"
#echo "listname $_listname"
#eval echo "list value \$$_listname"
#echo "value $_value"
# avoid leading separator
eval _values=\"\$$_listname\"
if [ -z "$_values" ]; then
eval export $_listname=\"$_value\"
#eval echo "set list \$$_listname"
else
# field separator must not be a colon
_ament_append_value_IFS=$IFS
unset IFS
eval export $_listname=\"\$$_listname:$_value\"
#eval echo "append list \$$_listname"
IFS=$_ament_append_value_IFS
unset _ament_append_value_IFS
fi
unset _values
unset _value
unset _listname
}
# function to append non-duplicate values to environment variables
# using colons as separators and avoiding leading separators
ament_append_unique_value() {
# arguments
_listname=$1
_value=$2
#echo "listname $_listname"
#eval echo "list value \$$_listname"
#echo "value $_value"
# check if the list contains the value
eval _values=\$$_listname
_duplicate=
_ament_append_unique_value_IFS=$IFS
IFS=":"
if [ "$AMENT_SHELL" = "zsh" ]; then
ament_zsh_to_array _values
fi
for _item in $_values; do
# ignore empty strings
if [ -z "$_item" ]; then
continue
fi
if [ $_item = $_value ]; then
_duplicate=1
fi
done
unset _item
# append only non-duplicates
if [ -z "$_duplicate" ]; then
# avoid leading separator
if [ -z "$_values" ]; then
eval $_listname=\"$_value\"
#eval echo "set list \$$_listname"
else
# field separator must not be a colon
unset IFS
eval $_listname=\"\$$_listname:$_value\"
#eval echo "append list \$$_listname"
fi
fi
IFS=$_ament_append_unique_value_IFS
unset _ament_append_unique_value_IFS
unset _duplicate
unset _values
unset _value
unset _listname
}
# function to prepend non-duplicate values to environment variables
# using colons as separators and avoiding trailing separators
ament_prepend_unique_value() {
# arguments
_listname="$1"
_value="$2"
#echo "listname $_listname"
#eval echo "list value \$$_listname"
#echo "value $_value"
# check if the list contains the value
eval _values=\"\$$_listname\"
_duplicate=
_ament_prepend_unique_value_IFS=$IFS
IFS=":"
if [ "$AMENT_SHELL" = "zsh" ]; then
ament_zsh_to_array _values
fi
for _item in $_values; do
# ignore empty strings
if [ -z "$_item" ]; then
continue
fi
if [ "$_item" = "$_value" ]; then
_duplicate=1
fi
done
unset _item
# prepend only non-duplicates
if [ -z "$_duplicate" ]; then
# avoid trailing separator
if [ -z "$_values" ]; then
eval export $_listname=\"$_value\"
#eval echo "set list \$$_listname"
else
# field separator must not be a colon
unset IFS
eval export $_listname=\"$_value:\$$_listname\"
#eval echo "prepend list \$$_listname"
fi
fi
IFS=$_ament_prepend_unique_value_IFS
unset _ament_prepend_unique_value_IFS
unset _duplicate
unset _values
unset _value
unset _listname
}
# unset AMENT_ENVIRONMENT_HOOKS
# if not appending to them for return
if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then
unset AMENT_ENVIRONMENT_HOOKS
fi
# list all environment hooks of this package
ament_append_value AMENT_ENVIRONMENT_HOOKS "$AMENT_CURRENT_PREFIX/share/arm_description/environment/ament_prefix_path.sh"
ament_append_value AMENT_ENVIRONMENT_HOOKS "$AMENT_CURRENT_PREFIX/share/arm_description/environment/path.sh"
# source all shell-specific environment hooks of this package
# if not returning them
if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then
_package_local_setup_IFS=$IFS
IFS=":"
if [ "$AMENT_SHELL" = "zsh" ]; then
ament_zsh_to_array AMENT_ENVIRONMENT_HOOKS
fi
for _hook in $AMENT_ENVIRONMENT_HOOKS; do
if [ -f "$_hook" ]; then
# restore IFS before sourcing other files
IFS=$_package_local_setup_IFS
# trace output
if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then
echo "# . \"$_hook\""
fi
. "$_hook"
fi
done
unset _hook
IFS=$_package_local_setup_IFS
unset _package_local_setup_IFS
unset AMENT_ENVIRONMENT_HOOKS
fi
# reset AMENT_CURRENT_PREFIX after each package
# allowing to source multiple package-level setup files
unset AMENT_CURRENT_PREFIX
@@ -0,0 +1,59 @@
# generated from ament_package/template/package_level/local_setup.zsh.in
AMENT_SHELL=zsh
# source local_setup.sh from same directory as this file
_this_path=$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd)
# provide AMENT_CURRENT_PREFIX to shell script
AMENT_CURRENT_PREFIX=$(builtin cd -q "`dirname "${(%):-%N}"`/../.." > /dev/null && pwd)
# store AMENT_CURRENT_PREFIX to restore it before each environment hook
_package_local_setup_AMENT_CURRENT_PREFIX=$AMENT_CURRENT_PREFIX
# function to convert array-like strings into arrays
# to wordaround SH_WORD_SPLIT not being set
ament_zsh_to_array() {
local _listname=$1
local _dollar="$"
local _split="{="
local _to_array="(\"$_dollar$_split$_listname}\")"
eval $_listname=$_to_array
}
# trace output
if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then
echo "# . \"$_this_path/local_setup.sh\""
fi
# the package-level local_setup file unsets AMENT_CURRENT_PREFIX
. "$_this_path/local_setup.sh"
unset _this_path
# unset AMENT_ENVIRONMENT_HOOKS
# if not appending to them for return
if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then
unset AMENT_ENVIRONMENT_HOOKS
fi
# restore AMENT_CURRENT_PREFIX before evaluating the environment hooks
AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX
# list all environment hooks of this package
# source all shell-specific environment hooks of this package
# if not returning them
if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then
_package_local_setup_IFS=$IFS
IFS=":"
for _hook in $AMENT_ENVIRONMENT_HOOKS; do
# restore AMENT_CURRENT_PREFIX for each environment hook
AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX
# restore IFS before sourcing other files
IFS=$_package_local_setup_IFS
. "$_hook"
done
unset _hook
IFS=$_package_local_setup_IFS
unset _package_local_setup_IFS
unset AMENT_ENVIRONMENT_HOOKS
fi
unset _package_local_setup_AMENT_CURRENT_PREFIX
unset AMENT_CURRENT_PREFIX
@@ -0,0 +1,2 @@
# Placeholder: put STL/DAE meshes here and reference them from URDF, e.g.:
# package://arm_description/meshes/link1.stl
@@ -0,0 +1,39 @@
# generated from colcon_bash/shell/template/package.bash.em
# This script extends the environment for this package.
# a bash script is able to determine its own path if necessary
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
# the prefix is two levels up from the package specific share directory
_colcon_package_bash_COLCON_CURRENT_PREFIX="$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." > /dev/null && pwd)"
else
_colcon_package_bash_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX"
fi
# function to source another script with conditional trace output
# first argument: the path of the script
# additional arguments: arguments to the script
_colcon_package_bash_source_script() {
if [ -f "$1" ]; then
if [ -n "$COLCON_TRACE" ]; then
echo "# . \"$1\""
fi
. "$@"
else
echo "not found: \"$1\"" 1>&2
fi
}
# source sh script of this package
_colcon_package_bash_source_script "$_colcon_package_bash_COLCON_CURRENT_PREFIX/share/arm_description/package.sh"
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced scripts
COLCON_CURRENT_PREFIX="$_colcon_package_bash_COLCON_CURRENT_PREFIX"
# source bash hooks
_colcon_package_bash_source_script "$COLCON_CURRENT_PREFIX/share/arm_description/local_setup.bash"
unset COLCON_CURRENT_PREFIX
unset _colcon_package_bash_source_script
unset _colcon_package_bash_COLCON_CURRENT_PREFIX
@@ -0,0 +1,8 @@
source;share/arm_description/hook/cmake_prefix_path.ps1
source;share/arm_description/hook/cmake_prefix_path.dsv
source;share/arm_description/hook/cmake_prefix_path.sh
source;share/arm_description/local_setup.bash
source;share/arm_description/local_setup.dsv
source;share/arm_description/local_setup.ps1
source;share/arm_description/local_setup.sh
source;share/arm_description/local_setup.zsh
@@ -0,0 +1,116 @@
# generated from colcon_powershell/shell/template/package.ps1.em
# function to append a value to a variable
# which uses colons as separators
# duplicates as well as leading separators are avoided
# first argument: the name of the result variable
# second argument: the value to be prepended
function colcon_append_unique_value {
param (
$_listname,
$_value
)
# get values from variable
if (Test-Path Env:$_listname) {
$_values=(Get-Item env:$_listname).Value
} else {
$_values=""
}
$_duplicate=""
# start with no values
$_all_values=""
# iterate over existing values in the variable
if ($_values) {
$_values.Split(":") | ForEach {
# not an empty string
if ($_) {
# not a duplicate of _value
if ($_ -eq $_value) {
$_duplicate="1"
}
if ($_all_values) {
$_all_values="${_all_values}:$_"
} else {
$_all_values="$_"
}
}
}
}
# append only non-duplicates
if (!$_duplicate) {
# avoid leading separator
if ($_all_values) {
$_all_values="${_all_values}:${_value}"
} else {
$_all_values="${_value}"
}
}
# export the updated variable
Set-Item env:\$_listname -Value "$_all_values"
}
# function to prepend a value to a variable
# which uses colons as separators
# duplicates as well as trailing separators are avoided
# first argument: the name of the result variable
# second argument: the value to be prepended
function colcon_prepend_unique_value {
param (
$_listname,
$_value
)
# get values from variable
if (Test-Path Env:$_listname) {
$_values=(Get-Item env:$_listname).Value
} else {
$_values=""
}
# start with the new value
$_all_values="$_value"
# iterate over existing values in the variable
if ($_values) {
$_values.Split(":") | ForEach {
# not an empty string
if ($_) {
# not a duplicate of _value
if ($_ -ne $_value) {
# keep non-duplicate values
$_all_values="${_all_values}:$_"
}
}
}
}
# export the updated variable
Set-Item env:\$_listname -Value "$_all_values"
}
# function to source another script with conditional trace output
# first argument: the path of the script
# additional arguments: arguments to the script
function colcon_package_source_powershell_script {
param (
$_colcon_package_source_powershell_script
)
# source script with conditional trace output
if (Test-Path $_colcon_package_source_powershell_script) {
if ($env:COLCON_TRACE) {
echo ". '$_colcon_package_source_powershell_script'"
}
. "$_colcon_package_source_powershell_script"
} else {
Write-Error "not found: '$_colcon_package_source_powershell_script'"
}
}
# a powershell script is able to determine its own path
# the prefix is two levels up from the package specific share directory
$env:COLCON_CURRENT_PREFIX=(Get-Item $PSCommandPath).Directory.Parent.Parent.FullName
colcon_package_source_powershell_script "$env:COLCON_CURRENT_PREFIX/share/arm_description/hook/cmake_prefix_path.ps1"
colcon_package_source_powershell_script "$env:COLCON_CURRENT_PREFIX/share/arm_description/local_setup.ps1"
Remove-Item Env:\COLCON_CURRENT_PREFIX
@@ -0,0 +1,87 @@
# generated from colcon_core/shell/template/package.sh.em
# This script extends the environment for this package.
# function to prepend a value to a variable
# which uses colons as separators
# duplicates as well as trailing separators are avoided
# first argument: the name of the result variable
# second argument: the value to be prepended
_colcon_prepend_unique_value() {
# arguments
_listname="$1"
_value="$2"
# get values from variable
eval _values=\"\$$_listname\"
# backup the field separator
_colcon_prepend_unique_value_IFS=$IFS
IFS=":"
# start with the new value
_all_values="$_value"
# workaround SH_WORD_SPLIT not being set in zsh
if [ "$(command -v colcon_zsh_convert_to_array)" ]; then
colcon_zsh_convert_to_array _values
fi
# iterate over existing values in the variable
for _item in $_values; do
# ignore empty strings
if [ -z "$_item" ]; then
continue
fi
# ignore duplicates of _value
if [ "$_item" = "$_value" ]; then
continue
fi
# keep non-duplicate values
_all_values="$_all_values:$_item"
done
unset _item
# restore the field separator
IFS=$_colcon_prepend_unique_value_IFS
unset _colcon_prepend_unique_value_IFS
# export the updated variable
eval export $_listname=\"$_all_values\"
unset _all_values
unset _values
unset _value
unset _listname
}
# since a plain shell script can't determine its own path when being sourced
# either use the provided COLCON_CURRENT_PREFIX
# or fall back to the build time prefix (if it exists)
_colcon_package_sh_COLCON_CURRENT_PREFIX="/home/cc/ros2/install/arm_description"
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
if [ ! -d "$_colcon_package_sh_COLCON_CURRENT_PREFIX" ]; then
echo "The build time path \"$_colcon_package_sh_COLCON_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"COLCON_CURRENT_PREFIX\" explicitly." 1>&2
unset _colcon_package_sh_COLCON_CURRENT_PREFIX
return 1
fi
COLCON_CURRENT_PREFIX="$_colcon_package_sh_COLCON_CURRENT_PREFIX"
fi
unset _colcon_package_sh_COLCON_CURRENT_PREFIX
# function to source another script with conditional trace output
# first argument: the path of the script
# additional arguments: arguments to the script
_colcon_package_sh_source_script() {
if [ -f "$1" ]; then
if [ -n "$COLCON_TRACE" ]; then
echo "# . \"$1\""
fi
. "$@"
else
echo "not found: \"$1\"" 1>&2
fi
}
# source sh hooks
_colcon_package_sh_source_script "$COLCON_CURRENT_PREFIX/share/arm_description/hook/cmake_prefix_path.sh"
_colcon_package_sh_source_script "$COLCON_CURRENT_PREFIX/share/arm_description/local_setup.sh"
unset _colcon_package_sh_source_script
unset COLCON_CURRENT_PREFIX
# do not unset _colcon_prepend_unique_value since it might be used by non-primary shell hooks
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>arm_description</name>
<version>0.1.0</version>
<description>URDF/Xacro wrapper for Flexiv Rizon 4 via flexiv_description.</description>
<maintainer email="dev@example.com">arm_dev</maintainer>
<license>Apache-2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>flexiv_description</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>joint_state_publisher</exec_depend>
<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>xacro</exec_depend>
<exec_depend>rviz2</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
@@ -0,0 +1,50 @@
# generated from colcon_zsh/shell/template/package.zsh.em
# This script extends the environment for this package.
# a zsh script is able to determine its own path if necessary
if [ -z "$COLCON_CURRENT_PREFIX" ]; then
# the prefix is two levels up from the package specific share directory
_colcon_package_zsh_COLCON_CURRENT_PREFIX="$(builtin cd -q "`dirname "${(%):-%N}"`/../.." > /dev/null && pwd)"
else
_colcon_package_zsh_COLCON_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX"
fi
# function to source another script with conditional trace output
# first argument: the path of the script
# additional arguments: arguments to the script
_colcon_package_zsh_source_script() {
if [ -f "$1" ]; then
if [ -n "$COLCON_TRACE" ]; then
echo "# . \"$1\""
fi
. "$@"
else
echo "not found: \"$1\"" 1>&2
fi
}
# function to convert array-like strings into arrays
# to workaround SH_WORD_SPLIT not being set
colcon_zsh_convert_to_array() {
local _listname=$1
local _dollar="$"
local _split="{="
local _to_array="(\"$_dollar$_split$_listname}\")"
eval $_listname=$_to_array
}
# source sh script of this package
_colcon_package_zsh_source_script "$_colcon_package_zsh_COLCON_CURRENT_PREFIX/share/arm_description/package.sh"
unset convert_zsh_to_array
# setting COLCON_CURRENT_PREFIX avoids determining the prefix in the sourced scripts
COLCON_CURRENT_PREFIX="$_colcon_package_zsh_COLCON_CURRENT_PREFIX"
# source zsh hooks
_colcon_package_zsh_source_script "$COLCON_CURRENT_PREFIX/share/arm_description/local_setup.zsh"
unset COLCON_CURRENT_PREFIX
unset _colcon_package_zsh_source_script
unset _colcon_package_zsh_COLCON_CURRENT_PREFIX
@@ -0,0 +1,58 @@
Panels:
Displays:
class: rviz_common/Displays
name: Displays
displays:
- class: rviz_default_plugins/Grid
name: Grid
enabled: true
Cell Size: 0.25
Reference Frame: <Fixed Frame>
- class: rviz_default_plugins/RobotModel
name: RobotModel
enabled: true
Description Source: Topic
Description Topic:
Value: /robot_description
Visual Enabled: true
Collision Enabled: false
Alpha: 1
- class: rviz_default_plugins/TF
name: TF
enabled: true
Show Names: true
Show Axes: true
Frame Timeout: 15
Marker Scale: 0.15
Views:
class: rviz_common/Views
name: Views
Current:
class: rviz_default_plugins/Orbit
name: Current View
Distance: 2.2
Focal Point:
X: 0.25
Y: 0.0
Z: 0.35
Pitch: 0.45
Yaw: 0.85
Visualization Manager:
class: ""
displays: ~
tools:
- class: rviz_default_plugins/Interact
- class: rviz_default_plugins/MoveCamera
- class: rviz_default_plugins/Select
- class: rviz_default_plugins/FocusCamera
views:
current:
class: rviz_default_plugins/Orbit
Global Options:
Background Color: 48; 48; 48
# Official flexiv_description Fixed Frame (or Rizon4-063989_base_link)
Fixed Frame: world
Frame Rate: 30
Window Geometry:
Height: 800
Width: 1200
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:macro name="arm_gazebo" params="prefix">
<gazebo reference="${prefix}base_link">
<material>Gazebo/DarkGrey</material>
</gazebo>
<gazebo reference="${prefix}link1">
<material>Gazebo/Red</material>
</gazebo>
<gazebo reference="${prefix}link2">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="${prefix}link3">
<material>Gazebo/Green</material>
</gazebo>
<gazebo reference="${prefix}link4">
<material>Gazebo/Yellow</material>
</gazebo>
<gazebo reference="${prefix}link5">
<material>Gazebo/Orange</material>
</gazebo>
<gazebo reference="${prefix}link6">
<material>Gazebo/Purple</material>
</gazebo>
<gazebo reference="${prefix}link7">
<material>Gazebo/Grey</material>
</gazebo>
</xacro:macro>
</robot>
@@ -0,0 +1,204 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!--
Flexiv Rizon 4 的轻量级 7 自由度运动学替身。
若需要精确的网格 / 运动学,请安装官方 flexiv_description,
并通过 arm_bringup 启动(使用 flexiv_description / flexiv_bringup)。
关节命名遵循 Flexiv 约定:{prefix}joint1 .. {prefix}joint7,
其中 prefix 通常是 robot_sn 把 '-' 换成 '_',例如 Rizon4_123456_
-->
<xacro:macro name="arm_inertial_box" params="mass x y z">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="${mass}"/>
<inertia
ixx="${(1/12)*mass*(y*y+z*z)}" ixy="0.0" ixz="0.0"
iyy="${(1/12)*mass*(x*x+z*z)}" iyz="0.0"
izz="${(1/12)*mass*(x*x+y*y)}"/>
</inertial>
</xacro:macro>
<xacro:macro name="arm_visual_cylinder" params="length radius rgba">
<visual>
<origin xyz="0 0 ${length/2}" rpy="0 0 0"/>
<geometry>
<cylinder length="${length}" radius="${radius}"/>
</geometry>
<material name="">
<color rgba="${rgba}"/>
</material>
</visual>
</xacro:macro>
<xacro:macro name="arm_collision_cylinder" params="length radius">
<collision>
<origin xyz="0 0 ${length/2}" rpy="0 0 0"/>
<geometry>
<cylinder length="${length}" radius="${radius}"/>
</geometry>
</collision>
</xacro:macro>
<!-- 近似的连杆长度(m);生产使用请替换为官方 URDF -->
<xacro:property name="L1" value="0.15"/>
<xacro:property name="L2" value="0.36"/>
<xacro:property name="L3" value="0.12"/>
<xacro:property name="L4" value="0.31"/>
<xacro:property name="L5" value="0.10"/>
<xacro:property name="L6" value="0.08"/>
<xacro:property name="L7" value="0.07"/>
<xacro:macro name="arm_robot" params="prefix">
<link name="${prefix}base_link">
<visual>
<origin xyz="0 0 0.06" rpy="0 0 0"/>
<geometry><cylinder length="0.12" radius="0.09"/></geometry>
<material name=""><color rgba="0.15 0.15 0.18 1"/></material>
</visual>
<collision>
<origin xyz="0 0 0.06" rpy="0 0 0"/>
<geometry><cylinder length="0.12" radius="0.09"/></geometry>
</collision>
<xacro:arm_inertial_box mass="3.0" x="0.18" y="0.18" z="0.12"/>
</link>
<!-- joint1:底座偏航(±165°) -->
<joint name="${prefix}joint1" type="revolute">
<parent link="${prefix}base_link"/>
<child link="${prefix}link1"/>
<origin xyz="0 0 0.12" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<limit lower="-2.8798" upper="2.8798" effort="123" velocity="2.0944"/>
<dynamics damping="0.1" friction="0.05"/>
</joint>
<link name="${prefix}link1">
<xacro:arm_visual_cylinder length="${L1}" radius="0.05" rgba="0.85 0.25 0.2 1"/>
<xacro:arm_collision_cylinder length="${L1}" radius="0.05"/>
<xacro:arm_inertial_box mass="2.0" x="0.1" y="0.1" z="${L1}"/>
</link>
<!-- joint2 -->
<joint name="${prefix}joint2" type="revolute">
<parent link="${prefix}link1"/>
<child link="${prefix}link2"/>
<origin xyz="0 0 ${L1}" rpy="0 ${pi/2} 0"/>
<axis xyz="0 0 1"/>
<limit lower="-2.3562" upper="2.3562" effort="123" velocity="2.0944"/>
<dynamics damping="0.1" friction="0.05"/>
</joint>
<link name="${prefix}link2">
<xacro:arm_visual_cylinder length="${L2}" radius="0.045" rgba="0.2 0.55 0.85 1"/>
<xacro:arm_collision_cylinder length="${L2}" radius="0.045"/>
<xacro:arm_inertial_box mass="2.5" x="0.09" y="0.09" z="${L2}"/>
</link>
<!-- joint3 -->
<joint name="${prefix}joint3" type="revolute">
<parent link="${prefix}link2"/>
<child link="${prefix}link3"/>
<origin xyz="0 0 ${L2}" rpy="0 0 0"/>
<axis xyz="0 0 1"/>
<limit lower="-3.0543" upper="3.0543" effort="64" velocity="2.4435"/>
<dynamics damping="0.08" friction="0.04"/>
</joint>
<link name="${prefix}link3">
<xacro:arm_visual_cylinder length="${L3}" radius="0.04" rgba="0.2 0.75 0.45 1"/>
<xacro:arm_collision_cylinder length="${L3}" radius="0.04"/>
<xacro:arm_inertial_box mass="1.2" x="0.08" y="0.08" z="${L3}"/>
</link>
<!-- joint4 -->
<joint name="${prefix}joint4" type="revolute">
<parent link="${prefix}link3"/>
<child link="${prefix}link4"/>
<origin xyz="0 0 ${L3}" rpy="0 ${pi/2} 0"/>
<axis xyz="0 0 1"/>
<limit lower="-1.9548" upper="2.7751" effort="64" velocity="2.4435"/>
<dynamics damping="0.08" friction="0.04"/>
</joint>
<link name="${prefix}link4">
<xacro:arm_visual_cylinder length="${L4}" radius="0.038" rgba="0.9 0.7 0.2 1"/>
<xacro:arm_collision_cylinder length="${L4}" radius="0.038"/>
<xacro:arm_inertial_box mass="1.8" x="0.076" y="0.076" z="${L4}"/>
</link>
<!-- joint5 -->
<joint name="${prefix}joint5" type="revolute">
<parent link="${prefix}link4"/>
<child link="${prefix}link5"/>
<origin xyz="0 0 ${L4}" rpy="0 ${-pi/2} 0"/>
<axis xyz="0 0 1"/>
<limit lower="-3.0543" upper="3.0543" effort="39" velocity="4.8869"/>
<dynamics damping="0.05" friction="0.02"/>
</joint>
<link name="${prefix}link5">
<xacro:arm_visual_cylinder length="${L5}" radius="0.032" rgba="0.6 0.35 0.85 1"/>
<xacro:arm_collision_cylinder length="${L5}" radius="0.032"/>
<xacro:arm_inertial_box mass="0.8" x="0.064" y="0.064" z="${L5}"/>
</link>
<!-- joint6 -->
<joint name="${prefix}joint6" type="revolute">
<parent link="${prefix}link5"/>
<child link="${prefix}link6"/>
<origin xyz="0 0 ${L5}" rpy="0 ${pi/2} 0"/>
<axis xyz="0 0 1"/>
<limit lower="-1.4835" upper="4.6251" effort="39" velocity="4.8869"/>
<dynamics damping="0.05" friction="0.02"/>
</joint>
<link name="${prefix}link6">
<xacro:arm_visual_cylinder length="${L6}" radius="0.03" rgba="0.35 0.75 0.75 1"/>
<xacro:arm_collision_cylinder length="${L6}" radius="0.03"/>
<xacro:arm_inertial_box mass="0.5" x="0.06" y="0.06" z="${L6}"/>
</link>
<!-- joint7:法兰偏航 -->
<joint name="${prefix}joint7" type="revolute">
<parent link="${prefix}link6"/>
<child link="${prefix}link7"/>
<origin xyz="0 0 ${L6}" rpy="0 ${-pi/2} 0"/>
<axis xyz="0 0 1"/>
<limit lower="-3.0543" upper="3.0543" effort="39" velocity="4.8869"/>
<dynamics damping="0.03" friction="0.01"/>
</joint>
<link name="${prefix}link7">
<visual>
<origin xyz="0 0 ${L7/2}" rpy="0 0 0"/>
<geometry><cylinder length="${L7}" radius="0.035"/></geometry>
<material name=""><color rgba="0.25 0.25 0.28 1"/></material>
</visual>
<collision>
<origin xyz="0 0 ${L7/2}" rpy="0 0 0"/>
<geometry><cylinder length="${L7}" radius="0.035"/></geometry>
</collision>
<xacro:arm_inertial_box mass="0.3" x="0.07" y="0.07" z="${L7}"/>
</link>
<!-- TCP / 法兰(Flexiv 使用 flange + tcp 两个坐标系) -->
<joint name="${prefix}flange_joint" type="fixed">
<parent link="${prefix}link7"/>
<child link="${prefix}flange"/>
<origin xyz="0 0 ${L7}" rpy="0 0 0"/>
</joint>
<link name="${prefix}flange"/>
<joint name="${prefix}tcp_joint" type="fixed">
<parent link="${prefix}flange"/>
<child link="${prefix}tcp"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
</joint>
<link name="${prefix}tcp"/>
<!-- 应用层使用的别名 -->
<joint name="${prefix}tool0_joint" type="fixed">
<parent link="${prefix}tcp"/>
<child link="${prefix}tool0"/>
<origin xyz="0 0 0" rpy="0 0 0"/>
</joint>
<link name="${prefix}tool0"/>
</xacro:macro>
</robot>
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:macro name="arm_ros2_control" params="prefix use_fake_hardware:=true">
<ros2_control name="Rizon4System" type="system">
<hardware>
<xacro:if value="${use_fake_hardware}">
<plugin>mock_components/GenericSystem</plugin>
</xacro:if>
<xacro:unless value="${use_fake_hardware}">
<!-- 官方 Flexiv 硬件插件(需要 flexiv_hardware) -->
<plugin>flexiv_hardware/FlexivHardwareInterface</plugin>
</xacro:unless>
</hardware>
<joint name="${prefix}joint1">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="${prefix}joint2">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="${prefix}joint3">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="${prefix}joint4">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="${prefix}joint5">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="${prefix}joint6">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
<joint name="${prefix}joint7">
<command_interface name="position"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
</ros2_control>
</xacro:macro>
</robot>
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Project wrapper: official flexiv_description + tcp/tool0. -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="$(arg rizon_type)">
<!-- rizon_type: Rizon4, Rizon4s, Rizon4M, Rizon4R, Rizon10, Rizon10s -->
<xacro:arg name="rizon_type" default="Rizon4"/>
<xacro:include filename="$(find flexiv_description)/urdf/common/rizon_robot.xacro"/>
<xacro:arg name="arm_prefix" default=""/>
<!-- 必须由 launch 传入真实 SN(mock_control / ros2_control / display 都会传)。
这里刻意留一个**明显是占位符**的默认值,而不是某台臂的真实 SN:
默认成真实 SN 的话,忘记传参时会安静地去驱动上一台臂的关节名,
而 <prefix> 变成 UNSET_ARM_SN_ 至少能让控制器报错信息里带着它。 -->
<xacro:arg name="robot_sn" default="UNSET_ARM_SN"/>
<xacro:arg name="joint_limits_parameters_file"
default="$(find flexiv_description)/config/$(arg rizon_type)/joint_limits.yaml"/>
<xacro:arg name="kinematics_parameters_file"
default="$(find flexiv_description)/config/$(arg rizon_type)/default_kinematics.yaml"/>
<xacro:arg name="inertia_parameters_file"
default="$(find flexiv_description)/config/$(arg rizon_type)/inertia_parameters.yaml"/>
<xacro:arg name="visual_parameters_file"
default="$(find flexiv_description)/config/$(arg rizon_type)/visual_parameters.yaml"/>
<xacro:arg name="load_gripper" default="false"/>
<xacro:arg name="gripper_name" default="Flexiv-GN01"/>
<xacro:arg name="load_mounted_ft_sensor" default="false"/>
<xacro:arg name="ros2_control" default="false"/>
<xacro:arg name="rdk_control_mode" default="joint_position"/>
<xacro:arg name="use_fake_hardware" default="true"/>
<xacro:arg name="fake_sensor_commands" default="false"/>
<xacro:arg name="initial_positions_file"
default="$(find flexiv_description)/config/initial_positions.yaml"/>
<xacro:arg name="mounting_file"
default="$(find flexiv_description)/config/single_robot_mounting.yaml"/>
<xacro:property name="mounting" value="${xacro.load_yaml('$(arg mounting_file)')}"/>
<xacro:property name="sn" value="$(arg robot_sn)"/>
<xacro:property name="ap" value="$(arg arm_prefix)"/>
<xacro:property name="prefix"
value="${(ap + '_' + sn + '_') if ap != '' and sn != '' else (ap + sn + '_') if (ap + sn) != '' else ''}"/>
<xacro:rizon_robot
rizon_type="$(arg rizon_type)"
robot_sn="$(arg robot_sn)"
joint_limits_parameters_file="$(arg joint_limits_parameters_file)"
kinematics_parameters_file="$(arg kinematics_parameters_file)"
inertia_parameters_file="$(arg inertia_parameters_file)"
visual_parameters_file="$(arg visual_parameters_file)"
arm_prefix="$(arg arm_prefix)"
load_gripper="$(arg load_gripper)"
gripper_name="$(arg gripper_name)"
load_mounted_ft_sensor="$(arg load_mounted_ft_sensor)"
ros2_control="$(arg ros2_control)"
rdk_control_mode="$(arg rdk_control_mode)"
use_fake_hardware="$(arg use_fake_hardware)"
fake_sensor_commands="$(arg fake_sensor_commands)"
initial_positions_file="$(arg initial_positions_file)"
base_rpy="${radians(mounting['orientation']['rx'])} ${radians(mounting['orientation']['ry'])} ${radians(mounting['orientation']['rz'])}"/>
<joint name="${prefix}tcp_joint" type="fixed">
<parent link="${prefix}flange"/>
<child link="${prefix}tcp"/>
</joint>
<link name="${prefix}tcp"/>
<joint name="${prefix}tool0_joint" type="fixed">
<parent link="${prefix}tcp"/>
<child link="${prefix}tool0"/>
</joint>
<link name="${prefix}tool0"/>
</robot>
@@ -0,0 +1 @@
flexiv_description:joint_state_publisher:joint_state_publisher_gui:robot_state_publisher:rviz2:xacro