分类 ROS开发 下的文章
ROS2 Jazzy 采用docker方式安装
一、安装ROS2 Jazzy版本
1、下载包含Jazzy 的docker
docker pull osrf/ros:jazzy-desktop
2、以交互模式在容器中运行镜像
docker run -it osrf/ros:jazzy-desktop
3、查看ROS2已经安装的包
ros2 pkg list
4: 查看ROS2已经安装的可执行节点
ros2 pkg executables
二、安装Nav2
1、apt install ros-jazzy-navigation2
2、apt install ros-jazzy-nav2-bringup
三、启动已经存在的容器
采用启动+进入容器的方法,主要是为了在容器里面通过apt-get安装的软件包,下次还能用,否则会被清理掉.
1: docker start <容器ID或容器名称>
2: docker exec -it <container_id_or_name> /bin/bash
四、安装Nav2完成后的结果
ROS2 Navigation Stack 导航栈
http://dev.nav2.fishros.com/doc/index.html
树莓派5换国内源
#deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
#deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
#deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-free-firmware
# Uncomment deb-src lines below then 'apt-get update' to enable 'apt-get source'
#deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
#deb-src http://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
#deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
ROS Bag读写范例
1、rosbag 写
#include <rosbag/bag.h> #include <std_msgs/Int32.h> #include <std_msgs/String.h> rosbag::Bag bag; bag.open("test.bag", rosbag::bagmode::Write); std_msgs::String str; str.data = std::string("foo"); std_msgs::Int32 i; i.data = 42; bag.write("chatter", ros::Time::now(), str); bag.write("numbers", ros::Time::now(), i); bag.close();
2、rosbag读
#include <rosbag/bag.h> #include <rosbag/view.h> #include <std_msgs/Int32.h> #include <std_msgs/String.h> #include <boost/foreach.hpp> #define foreach BOOST_FOREACH rosbag::Bag bag; bag.open("test.bag", rosbag::bagmode::Read); std::vector<std::string> topics; topics.push_back(std::string("chatter")); topics.push_back(std::string("numbers")); rosbag::View view(bag, rosbag::TopicQuery(topics)); foreach(rosbag::MessageInstance const m, view) { std_msgs::String::ConstPtr s = m.instantiate<std_msgs::String>(); if (s != NULL) std::cout << s->data << std::endl; std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>(); if (i != NULL) std::cout << i->data << std::endl; } bag.close();
C++11版本
#include <rosbag/bag.h> #include <rosbag/view.h> #include <std_msgs/Int32.h> rosbag::Bag bag; bag.open("test.bag"); // BagMode is Read by default for(rosbag::MessageInstance const m: rosbag::View(bag)) { std_msgs::Int32::ConstPtr i = m.instantiate<std_msgs::Int32>(); if (i != nullptr) std::cout << i->data << std::endl; } bag.close();