<fix>​ Fix format errors in README, Add rviz configuration loading.​​

This commit is contained in:
manifoldsdk
2025-07-12 21:28:38 +08:00
parent 31bff6868b
commit 876cc931b4
14 changed files with 838 additions and 344 deletions
+44 -44
View File
@@ -1,117 +1,117 @@
#!/bin/bash
# 获取脚本所在目录(Odin_ROS_Driver 目录)
# Get the directory where the script is located (Odin_ROS_Driver directory)
PKG_DIR="$(cd "$(dirname "$0")/.."; pwd)"
# 计算工作空间根目录(包含 devel、build、src 的目录)
# Calculate the workspace root directory (contains devel, build, src)
WORKSPACE_ROOT="$(dirname "$(dirname "$PKG_DIR")")"
# 工作空间源码目录(包含所有包的 src)
# Workspace source directory (contains all packages)
WORKSPACE_SRC="${WORKSPACE_ROOT}/src"
PROJECT_NAME="odin_ros_driver"
# 定义颜色代码
# Define color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # 无颜色
NC='\033[0m'
# 清理函数
# Clean workspace function
clean_workspace() {
echo -e "${YELLOW}🧹 清理构建目录${NC}"
echo -e "${YELLOW}Cleaning build directories${NC}"
# 清理工作空间根目录下的构建产物
# Clean build artifacts in workspace
rm -rf "${WORKSPACE_ROOT}/build"
rm -rf "${WORKSPACE_ROOT}/install"
rm -rf "${WORKSPACE_ROOT}/log"
rm -rf "${WORKSPACE_ROOT}/devel"
echo -e "${GREEN}✅ 清理完成${NC}"
echo -e "${GREEN}Cleanup complete${NC}"
}
# 运行函数
# Run node function
run_node() {
echo -e "${YELLOW}🏃‍♂️‍➡️ 运行 ROS1 节点${NC}"
echo -e "${YELLOW}Running ROS1 node${NC}"
# 检查环境文件是否存在
# Check if environment file exists
if [ ! -f "${WORKSPACE_ROOT}/devel/setup.bash" ]; then
echo -e "${RED}❌ 找不到 devel/setup.bash,请先执行 ./build_ros1.sh 构建项目${NC}"
echo -e "${RED}Could not find devel/setup.bash, please build the project with ./build_ros1.sh first${NC}"
return 1
fi
# Source 环境并运行节点
# Source environment and run node
source "${WORKSPACE_ROOT}/devel/setup.bash"
}
# 构建函数
# Build workspace function
build_workspace() {
echo -e "${YELLOW}🔍 工作空间结构:${NC}"
echo " 工作空间根目录: ${WORKSPACE_ROOT}"
echo " 源码目录: ${WORKSPACE_SRC}"
echo " 包目录: ${PKG_DIR}"
echo " ROS版本: ROS1"
echo -e "${YELLOW}Workspace structure:${NC}"
echo " Workspace root: ${WORKSPACE_ROOT}"
echo " Source directory: ${WORKSPACE_SRC}"
echo " Package directory: ${PKG_DIR}"
echo " ROS version: ROS1"
echo -e "${YELLOW}🔧 开始构建 ROS1 工程...${NC}"
echo -e "${YELLOW}Starting ROS1 project build...${NC}"
# 清理
# Clean
cd $WS_DIR
rm -rf build devel install
# 确保 ROS1 环境已加载
# Ensure ROS1 environment is loaded
if [ -f "/opt/ros/noetic/setup.bash" ]; then
source "/opt/ros/noetic/setup.bash"
elif [ -f "/opt/ros/melodic/setup.bash" ]; then
source "/opt/ros/melodic/setup.bash"
else
echo -e "${RED}❌ 找不到 ROS1 的 setup.bash 文件。请确保 ROS1 已安装。${NC}"
echo -e "${RED}Could not find ROS1 setup.bash file. Please ensure ROS1 is installed.${NC}"
return 1
fi
# 创建临时 package.xml
# Create temporary package.xml
if [ -f "${PKG_DIR}/package_ros1.xml" ]; then
echo "🔄 创建临时 package.xml(使用 package_ros1.xml)"
echo "Creating temporary package.xml (using package_ros1.xml)"
cp "${PKG_DIR}/package_ros1.xml" "${PKG_DIR}/package.xml"
TEMP_PACKAGE=true
elif [ -f "${PKG_DIR}/package.xml" ]; then
echo "ℹ️ 使用现有的 package.xml"
echo "Using existing package.xml"
else
echo -e "${RED}❌ 在包目录中找不到 package.xml${NC}"
echo -e "${RED}Could not find package.xml in package directory${NC}"
return 1
fi
# 设置构建系统变量
# Set build system variable
export BUILD_SYSTEM=ROS1
# 切换到工作空间根目录并构建
# Switch to workspace root and build
cd "${WORKSPACE_ROOT}" || return 1
catkin_make -DBUILD_SYSTEM=ROS1 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -j$(nproc)
BUILD_RESULT=$?
# 构建成功,source 环境
# If build successful, source environment
if [[ $BUILD_RESULT -eq 0 ]]; then
echo -e "${GREEN}✅ ROS1 构建成功,载入环境变量:source devel/setup.bash${NC}"
echo -e "${GREEN}ROS1 build successful, loading environment: source devel/setup.bash${NC}"
source "${WORKSPACE_ROOT}/devel/setup.bash"
else
echo -e "${RED}❌ ROS1 构建失败,请检查错误日志${NC}"
echo -e "${RED}ROS1 build failed, please check error logs${NC}"
fi
}
# 帮助函数
# Help function
show_help() {
echo -e "${YELLOW}使用说明:${NC}"
echo " ./build_ros.sh # 构建项目"
echo " ./build_ros.sh -c # 清理构建产物"
echo " ./build_ros.sh -h # 显示帮助信息"
echo -e "${YELLOW}Usage:${NC}"
echo " ./build_ros.sh # Build project"
echo " ./build_ros.sh -c # Clean build artifacts"
echo " ./build_ros.sh -h # Show help information"
echo ""
echo -e "${YELLOW}当前配置:${NC}"
echo " 项目名称: ${PROJECT_NAME}"
echo " 包目录: ${PKG_DIR}"
echo " 工作空间根目录: ${WORKSPACE_ROOT}"
echo " 源码目录: ${WORKSPACE_SRC}"
echo -e "${YELLOW}Current configuration:${NC}"
echo " Project name: ${PROJECT_NAME}"
echo " Package directory: ${PKG_DIR}"
echo " Workspace root: ${WORKSPACE_ROOT}"
echo " Source directory: ${WORKSPACE_SRC}"
}
# 主程序
# Main
case "$1" in
-c|--clean)
clean_workspace