ROS

参考资料

roslaunch/XML/rosparam - ROS Wiki

4.2.6 launch文件标签之rosparam · Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程

group

1
2
3
4
5
6
7
8
9
10
11
12
<launch>
<!-- 启动两对乌龟GUI -->
<group ns="first">
<node pkg="turtlesim" type="turtlesim_node" name="my_turtle" output="screen" />
<node pkg="turtlesim" type="turtle_teleop_key" name="my_key" output="screen" />
</group>

<group ns="second">
<node pkg="turtlesim" type="turtlesim_node" name="my_turtle" output="screen" />
<node pkg="turtlesim" type="turtle_teleop_key" name="my_key" output="screen" />
</group>
</launch>

arg

roslaunch/XML/arg - ROS Wiki

image-20230605150215637

image-20230605150243779

可以通过 include 以及 命令行 传递参数

image-20230605150409582

image-20230605151741944

先运行 included.launch 可以看到是默认值 “done”,再运行 args.launch,可以看到参数 “weaweawe” 传递给了 A 和 B

image-20230605152443028

Timer

(56条消息) ros timer(定时器)_九柳的博客-CSDN博客

image-20230605211216749

1
timer_ = nh_private.createTimer(ros::Duration(1.0/max(freq,1.0)),&OdomEstimationNode::spin, this);

&OdomEstimationNode::spin 获取对象的函数指针,调用入口,this指针说明这是哪个对象
因为cpp类中所有成员共享全部函数,所以入口只有一个,通过类名::函数名获取,区分对象用this指针(构造器中构造时使用),或者对象名

subscribe函数用于订阅topic并添加回调函数

1
cloud_subs_= nh_.subscribe<sensor_msgs::PointCloud2>("segmentation_result", 1,&RecognitionClass::cloudCallBack, this);
  • PointCloud2为订阅的消息类型
  • "segmentation_result"topic名,之后会重映射为真实的名称
  • 1为处理队列大小
  • &RecognitionClass::cloudCallBack是回调函数地址
  • this为回调函数所处的类,即当前类

image-20230605213906693

就是正常的发布话题

[roscpp/Overview/Publishers and Subscribers - ROS Wiki](https://wiki.ros.org/roscpp/Overview/Publishers and Subscribers)

(58条消息) 在ros中函数advertise()的作用_n.advertise_@晓凡的博客-CSDN博客

(58条消息) ROS 之 advertise 详解_ros中advertise_Dr. Qing的博客-CSDN博客

image-20230605215922473

image-20230605215907910

push_back 函数

函数将一个新的元素加到vector的最后面,位置为当前最后一个元素的下一个元素

Quaternion 四元数

[tf2/Tutorials/Quaternions - ROS Wiki](http://wiki.ros.org/tf2/Tutorials/Quaternions#:~:text=ROS uses quaternions to track and apply rotations.,like Eigen put w as the first number!).)

四元数——旋转 - 知乎 (zhihu.com)

(57条消息) ROS 四元数和RPY欧拉角转换_c++四元数转欧拉角_ZiTian_Shi的博客-CSDN博客

image-20230607204138476

cmd_vel

image-20230607205248458

src文件内多个main函数编译报错

单独添加

1
2
3
add_excutable;
add_depenpencies;
target_link_libraries;

雷达数据处理

(58条消息) ROS中激光雷达数据类型传递转换及自定义点云数据类型介绍_ros 自定义雷达消息_四海五湖百夜月的博客-CSDN博客

(58条消息) ROS小车——雷达的使用与SLAM建图(4)_robot_navigation_running snail szj的博客-CSDN博客

(58条消息) ros中激光雷达的消息类型(sensor_msgs/LaserScan Message)说明_ultimate1212的博客-CSDN博客

sensor_msgs/LaserScan Documentation (ros.org)

1.3.2 HelloWorld实现A(C++) · Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程

ros下python文件的使用

ROS/Tutorials/WritingPublisherSubscriber(python) - ROS Wiki

1.3.3 HelloWorld实现B(Python) · Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程

(58条消息) ROS使用Python编写的步骤_ros编译python文件_Believe yourself!!!的博客-CSDN博客

雷达滤波

(58条消息) 九、ROS小车闭环控制:使用laser_filters在ROS内对二维(2D)激光雷达数据进行基本滤波_orcasdli的博客-CSDN博客

(58条消息) ROS简单实现订阅/scan激光雷达的距离信息_ros scan_多年以后ls的博客-CSDN博客

void Transformer::transformPose ( const std::string & target_frame,
const ros::Time & target_time,
const Stamped< tf::Pose > & stamped_in,
const std::string & fixed_frame,
Stamped< tf::Pose > & stamped_out
) const

Transform a Stamped Pose into the target frame This can throw anything a lookupTransform can throw as well as tf::InvalidArgument.

Definition at line 558 of file tf.cpp.

geometry_msgs/Pose Documentation (ros.org)

# This contains the position of a point in free space
float64 x
float64 y
float64 z

Cmakelist

(70条消息) CMake系列讲解(入门篇)1.4 基础命令CMake-add_executable()_cmake add_ex_在下马农的博客-CSDN博客

1
2
3
add_executable(<name> [WIN32] [MACOSX_BUNDLE]
[EXCLUDE_FROM_ALL]
[source1] [source2 ...])

添加一个可执行文件目标,此目标:

  1. 由source列出的文件构建而来
  2. 名字为name

image-20230717162445706

关闭小车后停止运行

ros在关闭节点后发布消息 - 简书 (jianshu.com)

slam_karto - ROS Wiki

进程

子进程集 — Python 3.11.4 文档