2020import cv2
2121
2222import rclpy
23- from rclpy .qos import qos_profile_system_default , qos_profile_sensor_data
23+ from rclpy .qos import qos_profile_sensor_data , qos_profile_system_default
2424import sensor_msgs .msg
2525import std_msgs .msg
2626
2727
2828def mat2encoding (frame ):
29- '''
29+ """
30+ Convert an OpenCV matrix encoding type to a string format.
31+
3032 Convert an OpenCV matrix encoding type to a string format recognized by
31- sensor_msgs::msg::Image
32- '''
33+ sensor_msgs::msg::Image.
34+ """
3335 encoding = ''
3436
3537 encodings = {1 : 'mono' , 3 : 'bgr' , 4 : 'rgba' }
@@ -52,9 +54,7 @@ def mat2encoding(frame):
5254
5355
5456def convert_frame_to_message (frame , frame_id , msg ):
55- '''
56- Convert an OpenCV matrix to a ROS Image message.
57- '''
57+ """Convert an OpenCV matrix to a ROS Image message."""
5858 msg .height = frame .shape [0 ]
5959 msg .width = frame .shape [1 ]
6060 msg .encoding = mat2encoding (frame )
@@ -73,14 +73,14 @@ def main(args=None):
7373 '-b' , '--burger' , dest = 'burger_mode' , action = 'store_true' , default = False ,
7474 help = 'Produce images of burgers rather than connecting to a camera' )
7575 parser .add_argument (
76- '-d' , '--depth' , dest = 'depth' , action = 'store' , default = int ( qos_profile_system_default . depth ), type = int ,
77- help = 'Queue depth' )
76+ '-d' , '--depth' , dest = 'depth' , action = 'store' ,
77+ default = int ( qos_profile_system_default . depth ), type = int , help = 'Queue depth' )
7878 parser .add_argument (
7979 '-f' , '--frequency' , dest = 'frequency' , action = 'store' , default = 30 , type = int ,
8080 help = 'Publish frequency in Hz' )
8181 parser .add_argument (
82- '-k' , '--keep' , dest = 'history_policy' , action = 'store' , default = int ( qos_profile_system_default . history ),
83- type = int , choices = [0 , 1 ],
82+ '-k' , '--keep' , dest = 'history_policy' , action = 'store' ,
83+ default = int ( qos_profile_system_default . history ), type = int , choices = [0 , 1 ],
8484 help = 'History QoS setting, 0 - keep last sample, 1 - keep all the samples' )
8585 parser .add_argument (
8686 '-r' , '--reliability' , dest = 'reliability_policy' , action = 'store' ,
0 commit comments