ROS2+Gazebo11+Car+OpenCV录制视觉数据和控制学习

举报
zhangrelay 发表于 2022/06/07 23:05:14 2022/06/07
【摘要】 录制视觉数据如下: 控制效果如下: 如上控制案例参考: 2019年的一篇旧文,大概三年前了。 不变的配方,熟悉的味道。  居中 注意前轮夹角和方向盘 左转 注意前轮夹角和方向盘   右转 注意前轮夹角和方向盘 部分记录: [INFO] [launch]...

录制视觉数据如下:


控制效果如下:


如上控制案例参考:

2019年的一篇旧文,大概三年前了。

不变的配方,熟悉的味道。 


居中

注意前轮夹角和方向盘

左转

注意前轮夹角和方向盘

 

右转

注意前轮夹角和方向盘


部分记录:


  
  1. [INFO] [launch]: All log files can be found below /home/zhangrelay/.ros/log/2022-06-06-21-44-07-338514-LAPTOP-5REQ7K1L-231
  2. [INFO] [launch]: Default logging verbosity is set to INFO
  3. [INFO] [gazebo-1]: process started with pid [232]
  4. [gazebo-1] Gazebo multi-robot simulator, version 11.10.2
  5. [gazebo-1] Copyright (C) 2012 Open Source Robotics Foundation.
  6. [gazebo-1] Released under the Apache 2 License.
  7. [gazebo-1] http://gazebosim.org
  8. [gazebo-1]
  9. [gazebo-1] Gazebo multi-robot simulator, version 11.10.2
  10. [gazebo-1] Copyright (C) 2012 Open Source Robotics Foundation.
  11. [gazebo-1] Released under the Apache 2 License.
  12. [gazebo-1] http://gazebosim.org
  13. [gazebo-1]
  14. [gazebo-1] [INFO] [1654523050.454070500] [gazebo_ros_node]: ROS was initialized without arguments.
  15. [gazebo-1] [INFO] [1654523050.942191900] [camera_driver]: Publishing camera info to [/camera/camera_info]
  16. [gazebo-1] [INFO] [1654523050.996281100] [ackermann_drive]: Subscribed to [/cmd_vel]
  17. [gazebo-1] [INFO] [1654523051.001757000] [ackermann_drive]: Advertise odometry on [/odom]
  18. [gazebo-1] [INFO] [1654523051.003020500] [ackermann_drive]: Advertise distance on [/distance]
  19. [gazebo-1] [INFO] [1654523051.010715300] [ackermann_drive]: Publishing odom transforms between [odom_demo] and [chassis]
  20. [gazebo-1] [INFO] [1654523051.010808800] [ackermann_drive]: Publishing wheel transforms between [chassis], [front_right_combined_joint] and [front_right_combined_joint]
  21. [gazebo-1] [INFO] [1654523051.010835300] [ackermann_drive]: Publishing wheel transforms between [chassis], [front_left_combined_joint] and [front_left_combined_joint]
  22. [gazebo-1] [INFO] [1654523051.010851200] [ackermann_drive]: Publishing wheel transforms between [chassis], [rear_right_wheel_joint] and [rear_right_wheel_joint]
  23. [gazebo-1] [INFO] [1654523051.010867400] [ackermann_drive]: Publishing wheel transforms between [chassis], [rear_left_wheel_joint] and [rear_left_wheel_joint]
  24. [gazebo-1] [INFO] [1654523051.010882500] [ackermann_drive]: Publishing wheel transforms between [chassis], [front_right_combined_joint] and [front_right_combined_joint]
  25. [gazebo-1] [INFO] [1654523051.010898800] [ackermann_drive]: Publishing wheel transforms between [chassis], [front_left_combined_joint] and [front_left_combined_joint]
  26. [gazebo-1] [INFO] [1654523051.010914600] [ackermann_drive]: Publishing wheel transforms between [chassis], [steering_joint] and [steering_joint]
  27. [gazebo-1] [Msg] Waiting for master.
  28. [gazebo-1] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
  29. [gazebo-1] [Msg] Publicized address: 172.29.155.116
  30. [gazebo-1] [Msg] Loading world file [/home/zhangrelay/ros_ws/ROS2-Ultimate-Mobile-Robotics-Course-for-Beginners-OpenCV-main/prius_line_following/src/world/prius_on_track.world]
  31. [gazebo-1] [Wrn] [OBJLoader.cc:79] Both `d` and `Tr` parameters defined for "Hybrid". Use the value of `d` for dissolve (line 8 in .mtl.)
  32. [gazebo-1] Both `d` and `Tr` parameters defined for "Wheels3". Use the value of `d` for dissolve (line 22 in .mtl.)
  33. [gazebo-1] Both `d` and `Tr` parameters defined for "Hybrid_Interior". Use the value of `d` for dissolve (line 36 in .mtl.)
  34. [gazebo-1] Both `d` and `Tr` parameters defined for "Windows". Use the value of `d` for dissolve (line 50 in .mtl.)
  35. [gazebo-1]
  36. [gazebo-1] [Msg] Waiting for master.
  37. [gazebo-1] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
  38. [gazebo-1] [Msg] Publicized address: 172.29.155.116
  39. [gazebo-1] [Wrn] [OBJLoader.cc:79] Both `d` and `Tr` parameters defined for "Hybrid". Use the value of `d` for dissolve (line 8 in .mtl.)
  40. [gazebo-1] Both `d` and `Tr` parameters defined for "Wheels3". Use the value of `d` for dissolve (line 22 in .mtl.)
  41. [gazebo-1] Both `d` and `Tr` parameters defined for "Hybrid_Interior". Use the value of `d` for dissolve (line 36 in .mtl.)
  42. [gazebo-1] Both `d` and `Tr` parameters defined for "Windows". Use the value of `d` for dissolve (line 50 in .mtl.)
  43. [gazebo-1]
  44. [gazebo-1] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/pose/local/info, deleting message. This warning is printed only once.
  45. [gazebo-1] [Wrn] [ModelDatabase.cc:212] Unable to connect to model database using [http://models.gazebosim.org//database.config]. Only locally installed models will be available.
  46. [gazebo-1]
  47. [gazebo-1] libcurl: (6) Could not resolve host: fuel.ignitionrobotics.org

录制视觉参考代码如下:


  
  1. import rclpy
  2. import cv2
  3. from rclpy.node import Node
  4. from cv_bridge import CvBridge
  5. from sensor_msgs.msg import Image
  6. class Video_get(Node):
  7. def __init__(self):
  8. super().__init__('video_subscriber')# node name
  9. ## Created a subscriber
  10. self.subscriber = self.create_subscription(Image,'/camera/image_raw',self.process_data,10)
  11. ## setting for writing the frames into a video
  12. self.out = cv2.VideoWriter('/home/zhangrelay/ros_ws/cardemo.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (640,480))
  13. self.bridge = CvBridge() # converting ros images to opencv data
  14. ## Subscriber callback function
  15. def process_data(self, data):
  16. # performing conversion
  17. frame = self.bridge.imgmsg_to_cv2(data)
  18. # write the frames to a video
  19. self.out.write(frame)
  20. # displaying what is being recorded
  21. cv2.imshow("output", frame)
  22. # will save video until it is interrupted
  23. cv2.waitKey(1)
  24. def main(args=None):
  25. rclpy.init(args=args)
  26. image_subscriber = Video_get()
  27. rclpy.spin(image_subscriber)
  28. rclpy.shutdown()
  29. if __name__ == '__main__':
  30. main()

  • source install/setup.sh
  • ros2 run prius_line_following video_saver
  • pip3 install opencv-python
  • pip3 install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
  • ros2 run prius_line_following video_saver
  • colcon build
  • ros2 run prius_line_following video_saver
  • ros2 launch prius_line_following car_on_track.launch.py
  • ros2 topic list 


文章来源: zhangrelay.blog.csdn.net,作者:zhangrelay,版权归原作者所有,如需转载,请联系作者。

原文链接:zhangrelay.blog.csdn.net/article/details/125155310

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。