# zzrobot_ws **Repository Path**: cloudriver0226/zzrobot_ws ## Basic Information - **Project Name**: zzrobot_ws - **Description**: 医疗机器人项目ROS2开发 - **Primary Language**: C++ - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2024-01-15 - **Last Updated**: 2025-11-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: Cpp, Python ## README # 项目说明 ## 开发说明 根据自己的项目,大家创建一个文件夹"名称鲜明"地和共享的功能包区分开来。 共享的功能包,如Aimooe、UR5等模块大家可以一起开发; 自己的项目功能包自己维护,建议将这些功能包放在“usr_pkg”文件夹内,会自动屏蔽,不会上传。 ## 硬件的功能包说明 根据设备名称,建立有命名为“xx_pkg”的文件夹,内部通常包含多个功能包: “xx_msg”:为定义消息、动作、服务的功能包,也可以将设备的sdk放入其中,一起编译。 “xx_cpp”:为与硬件通信的功能包,并提供“消息-发布者”发布硬件信息,“服务-服务器”提供操作硬件的接口,“消息-订阅者”提供高频控制硬件的接口。还可以包含封装的函数,用于订阅消息、请求服务或者发布控制消息。 “xx_python”:为与硬件通信的功能包的python实现,与cpp功能包的功能相同。 ## 创建一个工作空间,并且下载的代码 - cd ~ - git clone https://gitee.com/cloudriver0226/zzrobot_ws.git ## 自动安装依赖 - sudo apt install -y python3-pip - sudo pip3 install rosdepc - sudo rosdepc init - rosdepc update - cd ~/zzrobot_ws - rosdepc install -i --from-path src --rosdistro humble -y ## 编译工作空间, 需要安装colcon - sudo apt install python3-colcon-ros - cd ~/zzrobot_ws/ - colcon build ## 设置环境变量 - source ~/zzrobot_ws/install/local_setup.sh # 仅在当前终端生效 - echo " source ~/zzrobot_ws/install/local_setup.sh" >> ~/.bashrc # 所有终端均生效(不建议) ## VScode推荐设置 tasks.json: { "version": "2.0.0", "tasks": [ { "label": "build ROS 2", "type": "shell", "command": "colcon", "args": [ "build", "--symlink-install", "--base-paths", "${workspaceFolder}", "--cmake-args", "-DCMAKE_BUILD_TYPE=RelWithDebInfo" ], "options": { "env": { "COLCON_SYMLINK_INSTALL": "1" } }, "group": { "kind": "build", "isDefault": true }, } ] } c_cpp_properties.json: { "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/install/**", "/opt/ros/humble/include/**", "/usr/include/python3.10", "/usr/include/pybind11", "/opt/ros/humble/include/rclcpp" ], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "c17", "cppStandard": "c++17", "compilerArgs": [ "-std=c++17" ], "intelliSenseMode": "linux-gcc-x64" } ], "version": 4 } ## 为VScode设置环境变量 - 推荐在终端运行`$ source install/setup.bash`和`$ code .`打开VScode, 能够自动加载当前工作空间环境变量. - 或者在~/zzrobot_ws/.vscode/ros2.env生成PYTHONPATH环境变量,以便vscode导入; 并在settings.json添加: "python.envFile": "${workspaceFolder}/.vscode/ros2.env" ## 检查环境变量 - echo $PYTHONPATH - echo $LD_LIBRARY_PATH ## 移除自己项目文件夹 1. git rm -r --cached src/my_pkg 2. 添加src/my_pkg到.gitignore 3. 提交