• ROS播包可视化


    ROS播包可视化

    1. 循环播放rosbag

    一个终端启动roscore

    roscore
    
    • 1

    另一个终端播放rosbag

    rosbag play 2022-01-24.bag -l
    
    rosbag play 2022-01-24.bag -l
    [ INFO] [1656915294.661470192]: Opening 2022-01-24.bag
    
    Waiting 0.2 seconds after advertising topics... done.
    
    Hit space to toggle paused, or 's' to step.
     [RUNNING]  Bag Time: 1517156370.912962   Duration: 2.746406 / 2.873530 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    2.rviz打开

    点击Add->添加topic

    会显示fixed frame不正确,来看看该rosbag包中frame_id是什么,并且定义是什么?

    查看rosbag对应topic的fixed frame

    qiancj@qianchengjun:~$ rostopic echo /front/M1/rslidar_points | grep frame_id
      frame_id: "/rslidar"
      frame_id: "/rslidar"
      frame_id: "/rslidar"
      frame_id: "/rslidar"
      frame_id: "/rslidar"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Fixed Frame

    The Fixed Frame/固定参考系

    The more-important of the two frames is the fixed frame. The fixed frame is the reference frame used to denote the “world” frame. This is usually the “map”, or “world”, or something similar, but can also be, for example, your odometry frame.

    If the fixed frame is erroneously set to, say, the base of the robot, then all the objects the robot has ever seen will appear in front of the robot, at the position relative to the robot at which they were detected.

    For correct results, the fixed frame should not be moving relative to the world.
    If you change the fixed frame, all data currently being shown is cleared rather than re-transformed.

    The Target Frame
    The target frame is the reference frame for the camera view. For example, if your target frame is the map, you’ll see the robot driving around the map. If your target frame is the base of the robot, the robot will stay in the same place while everything else moves relative to it.

    消息的头std_msgs/Header header中通常会有该信息。

    标准头信息主要包括:

    • seq是消息的顺序标识,不需要手动设置,发布节点在发布消息时,会自动累加。
    • timestamp是消息中与数据相关联的时间戳,例如激光数据中,时间戳对应激光数据的采集时间点。
    • frame_id 是消息中与数据相关联的参考系id,例如在在激光数据中,frame_id对应激光数据采集的参考系。

    例如LaserScan消息结构:

    std_msgs/Header header    #   标准头信息
    uint32 seq
    time stamp           
    string frame_id        # in frame frame_id, angles are measured around  the positive Z axis (counterclockwise, if Z is up) with zero angle being forward along the x axis                              
    float32 angle_min        # start angle of the scan [rad]
    float32 angle_max        # end angle of the scan [rad]
    float32 angle_increment  # angular distance between measurements [rad]
    float32 time_increment   # time between measurements [seconds] - if your scanner
                             # is moving, this will be used in interpolating position of 3d points
    float32 scan_time        # time between scans [seconds
    float32 range_min        # minimum range value [m]
    float32 range_max        # maximum range value [m]
    float32[] ranges         # range data [m] (Note: values < range_min or > range_max should be discarded)
    float32[] intensities    # intensity data [device-specific units].  If your device does not provide intensities, please leave the array empty.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    修改为正确的frame_id, 然后就能正确显示啦:

    代码播报

    #include "ros/ros.h"
    #include"std_msgs/Int32.h"
    #include 
    
    int main(int argc, char **argv)
    {
        ros::init(argc, argv, "demo_topic_publisher");
        ros::NodeHandle node_obj;
        ros::Publisher number_publisher = node_obj.advertise("/numbers",10); // topic
        ros::Rate loop_rate(10);
    
        int number_count = 0;
        while(ros::ok()) {
            std_msgs::Int32 msg;
            msg.data = number_count;
            ROS_INFO("%d",msg.data);
            number_publisher.publish(msg);
            ros::spinOnce();
            loop_rate.sleep();
            ++number_count;
        }
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    ros会一直播数字

    [ INFO] [1657537136.415226386]: 977
    [ INFO] [1657537136.515237562]: 978
    [ INFO] [1657537136.615177688]: 979
    [ INFO] [1657537136.715232163]: 980
    [ INFO] [1657537136.815237120]: 981
    [ INFO] [1657537136.915179913]: 982
    [ INFO] [1657537137.015181264]: 983
    [ INFO] [1657537137.115259284]: 984
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    查看topic及信息

    $ rostopic list
    /clock
    /numbers
    /points_raw
    /pose
    /rosout
    /rosout_agg
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    $ rostopic echo  /numbers
    data: 388
    ---
    data: 389
    ---
    data: 390
    ---
    data: 391
    ---
    data: 392
    ---
    data: 393
    ---
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    Reference

    • http://wiki.ros.org/rviz/UserGuide#Coordinate_Frames
    • The frame_id in a message specifies the point of reference for data contained in that message: https://blog.csdn.net/xu_fengyu/article/details/86562827
  • 相关阅读:
    Spring简单例子引入Spring要点
    【RbMQ】RabbitMQ概念辨析
    如何写一篇吊炸天的竞品分析
    TPD4E05U06DQAR功能和参数及如何正确安装使用
    ssm在线学习系统毕业设计-附源码211707
    大学毕业去什么样的公司工作不后悔?
    2.1.3 面向对象:类的方法(一)(Python)
    云原生系列 二【轻松入门容器基础操作】
    A. Spell Check
    C/C++模板类模板与函数模板区别,以及用法详解
  • 原文地址:https://blog.csdn.net/moneymyone/article/details/126017212