ROS2 Windows10 跑跑小乌龟

一、使用coco原生安装ROS2

1.以管理员身份启动Windows PowerShell,执行以下命令:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

2.输入coco输出如下:

Chocolatey v0.10.15
Please run 'choco -?' or 'choco <command> -?' for help menu.

3.安装设置:

mkdir c:\opt\chocolatey
set PYTHONNOUSERSITE=1
set ChocolateyInstall=c:\opt\chocolatey
choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1

4.执行安装命令,就可以自动下载安装ROS2了:

choco upgrade ros-foxy-desktop -y --execution-timeout=0

二、跑跑小乌龟

1.打cmd执行turtesim_node:

call C:\opt\ros\foxy\x64\local_setup.bat
ros2 run turtlesim turtlesim_node

弹出模拟小乌龟模拟界面:

 2.打开cmd执行turtle_teleop_key:

call C:\opt\ros\foxy\x64\local_setup.bat
ros2 run turtlesim turtle_teleop_key

显示操控界面:

通过上下(前后移动)左右(旋转方向)箭头就可以操控小乌龟了。 

 注意:焦点要保持在操控的cmd窗口上(该窗口接收来自键盘按键的输入)


原文链接:https://zhuanlan.zhihu.com/p/411118025

回答: 在Windows上使用ROS Action控制小乌龟的过程如下: 1. 首先,在功能包目录下创建一个名为"action"的文件夹。可以使用命令"mkdir action"来创建该文件夹。 2. 进入"action"文件夹,可以使用命令"cd action"来进入该文件夹。 3. 创建一个名为"turtleMove.action"的文件,可以使用命令"touch turtleMove.action"来创建该文件。 4. 使用文本编辑器(如gedit)打开"turtleMove.action"文件,并编写以下代码: ``` # Define the goal float64 turtle_target_x # Specify Turtle's target position float64 turtle_target_y float64 turtle_target_theta --- # Define the result float64 turtle_final_x # Define the final position of the turtle float64 turtle_final_y float64 turtle_final_theta --- # Define a feedback message float64 present_turtle_x # Define the current position of the turtle float64 present_turtle_y float64 present_turtle_theta ``` 这段代码定义了一个ROS Action的消息类型,包含了目标位置、最终位置和反馈信息。 通过以上步骤,你已经成功创建了一个ROS Action文件,并定义了相应的消息类型。接下来,你可以在Windows上使用ROS来控制小乌龟,实现目标位置的控制和实时反馈信息的获取。 #### 引用[.reference_title] - *1* *2* [ROS通信模式编程及分布式通信控制小乌龟](https://blog.csdn.net/qq_57160761/article/details/129508062)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [ROS学习-小乌龟解析](https://blog.csdn.net/qq_43419705/article/details/103098756)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值