2021-05-22

本文章是准备ROS 2相关材料时,编写的一些辅助脚本,使得初学者在学习ROS 2 时不用做太多的操作。

例子将Talker 和listener的操作脚本话,便于以后的学习。

工具1:Windows PowerShell 集成脚本环境 (ISE) 是 Windows PowerShell 的主机应用程序。 在 ISE 中,可以在单个基于 Windows 的图形用户界面中运行命令并编写、测试和调试脚本。 ISE 提供多行编辑、Tab 自动补全、语法颜色设置、选择性执行、上下文相关帮助以及对从右到左语言的支持。 将菜单项和键盘快捷方式映射到许多将会在 Windows PowerShell 控制台中执行的相同任务。 例如,在 ISE 中调试脚本时,可以右键单击编辑窗格中的代码行来设置断点。

工具2: ROS 2 foxy: ros2-foxy-20201211-windows-AMD64.zip

下载地址:https://github.com/ros2/ros2/releases/download/release-foxy-20201211/ros2-foxy-20201211-windows-release.amd64.zip

工具3: Python 3.8.3

环境均能测试过去,Talker 和listener能够根据官方文档调试出需要的效果(下图已经是使用脚本,一键运行后的截图;和官方文档操作的表现稍有不同,可以自行比对):

具体的代码如下:

# Talker-listener test for ROS2 foxy
# 2021-5-22
#Start-Process powershell.exe -ArgumentList "-noexit"
#Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{Get-Location}"

# Require admin
if(!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
    exit
}
## start a new shell for talker
C:\dev\ros2_foxy\local_setup.ps1
Unblock-File C:\dev\ros2_foxy\local_setup.ps1
Start-Process powershell -ArgumentList "-noexit", "-noprofile", "ros2 run demo_nodes_cpp talker"


## start a new shell for listener
Start-Process powershell -ArgumentList "-noexit", "-noprofile", "ros2 run demo_nodes_py listener"

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值