• 【航天物流组参赛ReadMe.md】


    请按照规范操作,应该不会有问题

    我们采用的ROS多机通信的方案,自己的笔记本电脑上面运行的是一些耗费算力的应用,小车上面主要运行一些比较简单的节点,比如驱动车辆运行的还有激光雷达的驱动节点

    第一次编译这个工作空间建议将build和devel都删掉然后再进行编译,就在这个readme文档的文件夹下面,打开命令行使用catkin_make进行编译,或者最好自己新建一个工作空间,将src和scripts文件夹放进去然后再进行编译
    编译不通过的话查看一下命令行里面的报错,是不是有什么功能包没有装,自己安装一下,CSDN上面应该有一个博客是教大家怎么通过一句命令自动安装工作空间中缺少的功能包,可以自己找一下,然后装好所有缺少的功能包之后再进行编译,由于有一个编译的先后问题,所以即使所有的功能包都装好了也不一定能一次编译通过,多编译几次就好了,但如果进度一直卡在一个地方,那就应该是你的功能包少装了
    然后这个工作空间中我们的定位功能是通过cartographer实现的,这就需要大家自己在自己的电脑上面把cartographer装好,保证能正常运行,而且cartographer本身的源码也有一些地方需要改动。参考这个博客链接,绝对能装好,而且速度非常快:极速安装cartographer链接
    运行的话直接运行在scripts文件夹下面的all_start.py文件,里面使用代码启动了主机所有的节点,实现了和另一台笔记本电脑的socket通信

    #!/usr/bin/python3
    import rospy
    from std_msgs.msg import String
    import os, commands
    
    twice = 0
    os.system("gnome-terminal -e roscore")
    os.system("gnome-terminal -e 'python /home/lijinzhe/ros_ws/scripts/my_socker.py'")
    
    
    def callback(msg):
        global twice
        string_load = msg.data
        if string_load == 'load':
            if twice >= 1:
                print(string_load)
                # kill cartographer node
                result = commands.getoutput("ps a | grep my_backpack_2d.launch")
                result_list = result.split(" ")
                cartographer_ros_ID = result_list[0]
                print("cartographer_ros_ID", cartographer_ros_ID)
                os.system("gnome-terminal -e 'kill -9 {}'".format(cartographer_ros_ID))
                print("cartographer_ros_ID killed")
                # kill car_nav node
                # result = commands.getoutput("ps a | grep car_nav.launch")
                # result_list = result.split(" ")
                # car_nav_ID = result_list[0]
                # print("car_nav_ID", car_nav_ID)
                # os.system("gnome-terminal -e 'kill -9 {}'".format(car_nav_ID))
                # print("car_nav_ID killed")
    
                # os.system("gnome-terminal -e 'roslaunch mbot_navigation car_nav.launch'")
                os.system("gnome-terminal -e 'roslaunch cartographer_ros my_backpack_2d.launch'")
            twice = twice + 1
        elif string_load == 'start':
            print(string_load)
            os.system("gnome-terminal -e 'roslaunch mbot_navigation rviz_display.launch'")
            os.system("gnome-terminal -e 'roslaunch mbot_navigation car_nav.launch'")
            os.system("gnome-terminal -e 'roslaunch cartographer_ros my_backpack_2d.launch'")
            os.system("gnome-terminal -e 'python /home/lijinzhe/ros_ws/scripts/notime_nav.py'")
            os.system("gnome-terminal -e 'rostopic echo /pose_data'")
        elif string_load == "restart":
            print(string_load)
            # kill notime_nav python node
            result = commands.getoutput("ps a | grep notime")
            result_list = result.split(" ")
            notime_ID = result_list[0]
            print("notime_ID", notime_ID)
            os.system("kill -9 {}".format(notime_ID))
            print("notime_ID killed")
            # kill cartographer node
    
            result = commands.getoutput("ps a | grep my_backpack_2d.launch")
            result_list = result.split(" ")
            cartographer_ros_ID = result_list[0]
            print("cartographer_ros_ID", cartographer_ros_ID)
            os.system("gnome-terminal -e 'kill -9 {}'".format(cartographer_ros_ID))
            print("cartographer_ros_ID killed")
    
            # kill car_nav node
            result = commands.getoutput("ps a | grep car_nav.launch")
            result_list = result.split(" ")
            car_nav_ID = result_list[0]
            print("car_nav_ID", car_nav_ID)
            os.system("gnome-terminal -e 'kill -9 {}'".format(car_nav_ID))
            print("car_nav_ID killed")
    
            os.system("gnome-terminal -e 'roslaunch cartographer_ros my_backpack_2d.launch'")
            os.system("gnome-terminal -e 'roslaunch mbot_navigation car_nav.launch'")
            os.system("gnome-terminal -e 'python /home/lijinzhe/ros_ws/scripts/notime_nav.py'")
    
    
    def listener():
        # In ROS, nodes are uniquely named. If two nodes with the same
        # name are launched, the previous one is kicked off. The
        # anonymous=True flag means that rospy will choose a unique
        # name for our 'listener' node so that multiple listeners can
        # run simultaneously.
        rospy.init_node('carto_start_listener', anonymous=True)
    
        rospy.Subscriber("/finial_goal", String, callback)
    
        # spin() simply keeps python from exiting until this node is stopped
        rospy.spin()
    
    
    if __name__ == '__main__':
        listener()
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
  • 相关阅读:
    WEB漏洞-文件操作之文件包含漏洞
    Define event types in Splunk Web
    Spark Core之RDD
    弹性蛋白酶中英文说明书
    dedecms tag 伪静态 数字版本
    数据科学中常见的9种距离度量方法,内含欧氏距离、切比雪夫距离等
    c++builder 6.0中OnCliked= fun实现的原理
    基于Mybatis-Plus的多租户架构下的数据隔离解决方案
    Hdu2022 多校训练(5) BBQ
    C语言的缺陷与陷阱
  • 原文地址:https://blog.csdn.net/Black__Jacket/article/details/126612462