# cv_experiments **Repository Path**: Frederick_Y/cv_experiments ## Basic Information - **Project Name**: cv_experiments - **Description**: 基于OpenCV和ROS2的Tello与Robomaster EP视觉实验程序 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-03-12 - **Last Updated**: 2024-03-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cv_experiments ## 简介 基于OpenCV和ROS2的Tello与Robomaster EP实验程序 face_detection_node:用于Tello,实现跟随人脸功能 color_picker_node:用于EP,测量目标颜色 color_shape_detection_node:用于EP,实现跟随目标色块功能 ## 用法 首先clone本仓库到~/ros2_ws/src: ``` git clone https://gitee.com/Frederick_Y/cv_experiments.git ``` 然后在~/ros2_ws下编译: ``` cd ~/ros2_ws colcon build --packages-select cv_experiments ``` ### 1. EP跟随色块实验 首先启动EP驱动: ``` cd ~/ros2_ws source install/setup.bash ros2 launch robomaster_ros ep.launch conn_type:=ap video_resolution:=720 ``` 新建一个终端,然后启动color_picker_node: ``` cd ~/ros2_ws source install/setup.bash ros2 run cv_experiments color_picker_node ``` 测量目标颜色,然后修改color_shape_detection_node。修改完成后,需要重新编译这个ROS包: ``` colcon build --packages-select cv_experiments ``` 然后启动color_shape_detection_node: ``` ros2 run cv_experiments color_shape_detection_node ``` #### 注: 本程序需要一定算力,若运行时发现卡顿,首先可以将Ubuntu系统电源方案切换为性能模式。 还可以尝试降低图像分辨率至540p或360p(默认参数): ``` ros2 launch robomaster_ros ep.launch conn_type:=ap video_resolution:=540 ros2 launch robomaster_ros ep.launch conn_type:=ap ``` 还可以尝试安装PyAV(不确定是不是管用): ``` pip install PyAV ``` ### 2. Tello人脸跟随实验 首先启动Tello驱动节点: ``` cd ~/tello_ros_ws source install/setup.bash ros2 launch tello_driver teleop_launch.py ``` 新建一个终端,然后启动face_detection_node: ``` cd ~/ros2_ws source install/setup.bash ros2 run cv_experiments face_detection_node ``` 再新建一个终端,控制Tello起飞和降落: ``` cd ~/tello_ros_ws source install/setup.bash ros2 service call /tello_action tello_msgs/TelloAction "{cmd: 'takeoff'}" ros2 service call /tello_action tello_msgs/TelloAction "{cmd: 'land'}" ``` ## 附:其他指令(用不到) ``` colcon build --event-handlers console_direct+ --packages-skip tello_gazebo ros2 service call /tello_action tello_msgs/TelloAction "{cmd: 'rc 0 0 0 20'}" ros2 service call /tello_action tello_msgs/TelloAction "{cmd: 'battery?'}" ros2 topic pub /cmd_vel geometry_msgs/Twist # Sends rc 0 0 0 0 ros2 topic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.2}}" ```