CLOiSim 与 ROS2 仿真设备桥接包

该仓库提供 jazzy 版本的 ROS2 仿真设备包,用于连接基于 Unity3D 的多机器人模拟器 CLOiSim,内容涵盖构建、测试、远程桥接配置与启动方式。

# cloisim_ros (jazzy版本) (英语). ROS2模拟设备包可以连接CLOiSim(基于unity3D的多机器人模拟器). ## 下载 CLOiSim 模拟器 - 最新版本: [链接](https://github.com/lge-ros2/cloisim/releases/latest) - 所有发布 : [链接](https://github.com/lge-ros2/cloisim/releases) ## 安装 ROS2 爵士乐 遵循关于以下链接的准则。 <https://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debians.html> ## 先决条件 ```shell mkdir -p ~/cloisim_ws/src cd ~/cloisim_ws/src git clone --recursive https://github.com/lge-ros2/cloisim_ros.git -b jazzy sudo apt update sudo apt install -y python3-rosdep sudo rosdep init rosdep update rosdep install -y -r -q --from-paths src --ignore-src --rosdistro jazzy ``` ## 构建 首先设置 ROS2 环境 ```shell source /opt/ros2/jazzy/setup.bash cd ~/cloisim_ws colcon build --symlink-install --packages-up-to cloisim_ros_bringup ``` ## 测试 使用启用的测试构建并运行测试 : ```shell cd ~/cloisim_ws colcon build --cmake-args -DBUILD_TESTING=ON colcon test --event-handlers console_direct+ colcon test-result --all ``` 仅测试特定包: ```shell colcon build --packages-select cloisim_ros_lidar cloisim_ros_camera --cmake-args -DBUILD_TESTING=ON colcon test --packages-select cloisim_ros_lidar cloisim_ros_camera --event-handlers console_direct+ colcon test-result --all ``` ## 预推钩 要在测试失败时阻塞推力, 启用 repo- local git hook : ```shell git config core.hooksPath .githooks chmod +x .githooks/pre-push ``` 默认是钩子在运行 `auto` 模式。它检查被推的对等文件,将文件重新映射到colcon软件包,构建已更改的软件包及其依赖性,并且只对直接更改的软件包进行测试。 ```shell git config hooks.cloisimRosPrePushScope auto ``` 要强制实施一个单一的包: ```shell git config hooks.cloisimRosPrePushScope package git config hooks.cloisimRosPrePushPackage cloisim_ros_base ``` 该模式运行 : ```shell colcon build --packages-up-to cloisim_ros_base --cmake-args -DBUILD_TESTING=ON colcon test --packages-select cloisim_ros_base --event-handlers console_direct+ colcon test-result --verbose --test-result-base build/cloisim_ros_base ``` 强制全部工作空间验证 : ```shell git config hooks.cloisimRosPrePushScope workspace ``` 该模式运行 : ```shell colcon build --cmake-args -DBUILD_TESTING=ON colcon test --event-handlers console_direct+ colcon test-result --all --verbose ``` 使用( U) `workspace` 只有在您有意为每个软件包付费并接受阻碍推力的不相关的软件包故障时。 要切换回自动检测 : ```shell git config hooks.cloisimRosPrePushScope auto ``` 暂时绕过它: ```shell SKIP_CLOISIM_ROS_PRE_PUSH=1 git push ``` ## 使用量 设置环境变量, 如果服务器不是本地主机 ```shell export CLOISIM_BRIDGE_IP='xxx.xxx.xxx.xxx' export CLOISIM_SERVICE_PORT=8080 ``` 看这里 [细节](https://github.com/lge-ros2/cloisim_ros/tree/jazzy/cloisim_ros_bringup) 用于抚养指南 默认的最大重试号是 5, 如果您想要更改设置环境变量的话 。 ```shell export CLOISIM_CONNECTION_MAX_RETRY=10 ``` ### 运行 cloisim_ros(机器人+世界) #### 带有气旋dd的DDS 建议使用气旋DDS和配置文件 将配置的 XML 文件放置在您想要的位置, 并设置环境变量如下 : ```shell export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp export CYCLONEDDS_URI=file:///$PWD/cloisim_ros/cyclonedds_config.xml sudo sysctl -w net.core.rmem_max=16777216 \ -w net.core.rmem_default=16777216 \ -w net.core.wmem_max=16777216 \ -w net.core.wmem_default=16777216 ``` #### 与 FastRTPS 共享内存 DDS 它是cloisim_ros的实验特征. FASTRTPS_DEFAULT_PROFILES_FILE环境变量中使用绝对路径. 举例来说, ```shell export RMW_IMPLEMENTATION=rmw_fastrtps_cpp export FASTRTPS_DEFAULT_PROFILES_FILE=/home/cloi/src/cloisim_ros/fastrtps_shared_profile.xml ``` #### 关闭单一模式( =多机器人模式) 应用命名空间作为每个机器人作为多机器人模式. **强烈建议采用这种方法.** ```shell ros2 launch cloisim_ros_bringup bringup_launch.py ros2 launch cloisim_ros_bringup bringup_launch.py single_mode:=False ``` #### 打开单模式 它应该为机器人应用NOT的命名空间,并且机器人的数量必须在世界环境中的BE单数. ```shell ros2 launch cloisim_ros_bringup bringup_launch.py single_mode:=True ``` ## 运行 CLOiSim 它提供了方便运行的CLOiSim的脚本. ```shell ros2 launch cloisim_ros_bringup cloisim_launch.py sim_path:=/opt/CLOiSim/CLOiSim-2.2.0 world:=lg_seocho.world ``` ## 使用嵌入器 复制此寄存器( 此分支) 后运行于命令以下 。 ### 构建嵌入器图像 ```shell git clone https://github.com/lge-ros2/cloisim_ros.git -b jazzy cd cloisim_ros docker build -t cloisim_ros . ``` ### 正在运行的容器 您可以增加上述可能的参数。 ex) target_model, target_parts_type 或 target_parts_name #### 多机器人模式 ```shell docker run -it --rm --net=host -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID cloisim_ros ``` #### 单机器人模式 ```shell docker run -it --rm --net=host -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID cloisim_ros single_mode:=True ``` #### 带有默认网络驱动程序的多机器人模式( 桥) ```shell docker run -it --rm -e CLOISIM_BRIDGE_IP='192.168.0.125' -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID cloisim_ros ``` #### 带有默认网络驱动器的单机器人模式( 桥) ```shell docker run -it --rm -e CLOISIM_BRIDGE_IP='192.168.0.125' -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID cloisim_ros single_mode:=True ``` 您可以使用以下命令设置桥口 。 ```shell export CLOISIM_BRIDGE_IP=$(ip addr show dev docker0 | grep "inet" | awk 'NR==1{print $2}' | cut -d'/' -f 1) echo $CLOISIM_BRIDGE_IP docker run -it --rm -e CLOISIM_BRIDGE_IP=$CLOISIM_BRIDGE_IP -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID cloisim_ros ``` ## 版本信息 - 请参考您想要的 ROS2 反转录的每个分支 - [爵士乐](https://github.com/lge-ros2/cloisim_ros/tree/jazzy) - [谦卑](https://github.com/lge-ros2/cloisim_ros/tree/humble) - [帅哥](https://github.com/lge-ros2/cloisim_ros/tree/foxy) - [冲锋](https://github.com/lge-ros2/sim_device/tree/dashing)

查看原始来源