《ROS机器人程序设计》期中测评试卷 (ROS2)

课程以ROS2-F/G版讲解为主。



文字版:

一、单选题(本大题共6小题, 每小题4分, 共24分。)
1、ROS2默认支持的操作系统平台不包括(  )。
A. windows;    B. linux;     C. macos;      D. aliyun
2、ROS2主要使用的C++标准为(  )。
A. C++03;  B. C++11;   C. C++14;    D. C++17
3、ROS2中编译功能包主要使用命令是(  )
 A. catkin_make;         B. ament build; 
 C. colcon build;         D. catkin build
4、C++中uint8_t对应的ROS2的类型是(  )。
A. bool;B. byte;C. int8;D. char
5、ROS2中QoS重要的功能包括(  )。
A.建立通信; B. 防止死机; C. 避免“过时”数据;  D. 监控节点
6、下面命名不符合ROS2规范的是(  )。
A.abc; B.abc123;C.123;D._abc

二、判断题(每小题4分, 5题共20分。

1、(  )ROS2支持在嵌入式系统上(如STM32/ESP32等)运行。

2、(  )ROS2支持主流编程语言进行代码编写如C++和Python等。

3、(  )ROS2使用ROS_DOMAIN_ID避免同一网络不同组计算机之间干扰。

4、(  )ROS2客户端库包括rclcpp和rclpy。

5、(  )一个需要长时间运行的任务通常采用行动(action)方式实现。

三、多选题(每小题4分, 5题共20分。

1、ROS2的DDS安全特性包括(  )。

A、身份验证 B、加密记录 C、访问控制 D、数据标记

2ROS2常用命令有(  )。

A、roscore  B、rqt  C、rviz2  D、colcon

3、ROS2源代码编译后,所在文件夹下有哪些目录(  )。

A、src  B、devel  C、build  D、install

4、下面代码哪些可以关闭ROS2程序(  )。

A、rclcpp::shutdown(); B、rclpy.shutdown() C、exit() D、end()

5、ROS2的CLI包含(  )。

A、ros2 component B、ros2 launch C、ros2 pkg D、ros2 security

程序题(36

阅读如下代码,在划线处给出注释(12分),结合图片说明程序实现的功能(12分),如何改变图中三维点云(12分)。

import numpy as np
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import PointCloud2
from sensor_msgs.msg import PointField
from sensor_msgs_py import point_cloud2
from std_msgs.msg import Header          ————————————————

class PointCloudPublisher(Node): 
    rate = 30
    moving = True
    width = 100
    height = 100                        ————————————————
    header = Header()
    header.frame_id = 'map'
    dtype = PointField.FLOAT32
    point_step = 16
    fields = [PointField(name='x', offset=0, datatype=dtype, count=1),
              PointField(name='y', offset=4, datatype=dtype, count=1),
              PointField(name='z', offset=8, datatype=dtype, count=1),
              PointField(name='intensity', offset=12, datatype=dtype, count=1)]
 
    def __init__(self):
        super().__init__('pc_publisher')
        self.publisher_ = self.create_publisher(PointCloud2, 'test_cloud', 10)
        timer_period = 1 / self.rate
        self.timer = self.create_timer(timer_period, self.timer_callback)
        self.counter = 0
                                      ——————————————————
    def timer_callback(self):
        self.header.stamp = self.get_clock().now().to_msg()
        x, y = np.meshgrid(np.linspace(-2, 2, self.width), np.linspace(-2, 2, self.height))
        z = 0.5 * np.sin(2*x-self.counter/10.0) * np.sin(2*y)
        points = np.array([x, y, z, z]).reshape(4, -1).T
        pc2_msg = point_cloud2.create_cloud(self.header, self.fields, points)
        self.publisher_.publish(pc2_msg)
        if self.moving:
            self.counter += 1
                                      ——————————————————
def main(args=None):
    rclpy.init(args=args)
    pc_publisher = PointCloudPublisher()
    rclpy.spin(pc_publisher)
    pc_publisher.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()


本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>