ROS教程1--创建节点

  1. 编写cpp文件
//example1_a.cpp
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>

int main(int argc, char **argv)
{
  ros::init(argc, argv, "example1_a");
  ros::NodeHandle n;
  ros::Publisher pub = n.advertise<std_msgs::String>("message",
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
抱歉,Ubuntu 23.04 并不是一个存在的 Ubuntu 版本。目前最新的 Ubuntu 版本是 21.10(Groovy Gorilla),而 ROS 的最新版本是 ROS Noetic,它支持的 Ubuntu 版本包括 Ubuntu 18.04、20.04、20.10 和 21.04。 以下是在 Ubuntu 20.04 上安装 ROS Noetic 的步骤: 1. 配置 Ubuntu 软件源: ``` sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' ``` 2. 添加 ROS GPG Key: ``` curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - ``` 3. 更新软件包列表: ``` sudo apt update ``` 4. 安装 ROS Noetic: ``` sudo apt install ros-noetic-desktop-full ``` 5. 初始化 ROS: ``` sudo rosdep init rosdep update echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc source ~/.bashrc ``` 现在,ROS Noetic 已经被成功安装在你的 Ubuntu 20.04 系统上了。你可以通过运行以下命令来验证是否安装成功: ``` roscore ``` 如果一切正常,你应该可以看到 ROS Master 节点成功启动,并输出以下信息: ``` ... logging to /home/username/.ros/log/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/roslaunch-ubuntu-xxxxx.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://ubuntu:xxxxx/ SUMMARY ======== PARAMETERS * /rosdistro: noetic * /rosversion: 1.15.9 NODES auto-starting new master process[master]: started with pid [xxxxx] ROS_MASTER_URI=http://ubuntu:xxxxx/ setting /run_id to xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx process[rosout-1]: started with pid [xxxxx] started core service [/rosout] ``` 如果你接下来要创建 ROS 工作空间,可以参考官方文档进行操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值