Add Server Turtlebot3 Hood Waffle Foxy Tensorflow 20210615

From wikidb
Jump to: navigation, search

Goal

The goal is to create a new TensorFlow Object Detector by modifying Install Turtlebot3 Hood Waffle Foxy Tensorflow 20210615.

Sanity Test

Test Build

Build Passed

 $ cd tf_ws/

 $ colcon build --symlink-install
       Starting >>> ros2_tf_core
       Starting >>> tf_interfaces
       Finished <<< ros2_tf_core [1.46s]                                             
       Finished <<< tf_interfaces [2.40s]                     
       Starting >>> tf_classification_py
       Starting >>> tf_detection_py
       Finished <<< tf_detection_py [1.75s]                               
       Finished <<< tf_classification_py [1.79s]          
       Starting >>> ros2_tensorflow
       Finished <<< ros2_tensorflow [0.21s]                  

       Summary: 5 packages finished [4.66s]

Test Execution

Test Passed: Repeat Object Detection Task 2 in Install Turtlebot3 Hood Waffle Foxy Tensorflow 20210615 to make sure Foxy TensorFlow is not broken.

Add a New Server

Add the Server Code

Add a catsNdogs object detection server that does the same thing that the server does. It enables us to allows us to modify a new server without destroying any existing examples. We can then focus changes on the catsNdogs server.

 $ cd ~/tf_ws/src/ros2-tensorflow/tf_detection_py/tf_detection_py/examples

 $ cp server.py catsNdogs.py

Modify the Build Setup

 $ cd ../..

 $ cp setup.py setup.py.org

 $ emacs setup.py&

Add the catsNdoes detection server to the build. Do a diff to document the change.

 $ diff setup.py.org setup.py
       37a38
       >             'catsNdogs = tf_detection_py.examples.catsNdogs:main',

Test the Build

Check what servers are in the current install directory and check if the build adds the new object detection server.

 $ cd ~/tf_ws/install/tf_detection_py/lib/tf_detection_py/

 $ ls
       client_test  face_detection  server

 $ cd ~/tf_ws
 
 $ colcon build --symlink-install
       Starting >>> ros2_tf_core
       Starting >>> tf_interfaces
       Finished <<< tf_interfaces [1.26s]                                            
       Finished <<< ros2_tf_core [1.39s]          
       Starting >>> tf_classification_py
       Starting >>> tf_detection_py                       
       Finished <<< tf_classification_py [1.53s]                          
       Finished <<< tf_detection_py [1.53s]
       Starting >>> ros2_tensorflow
       Finished <<< ros2_tensorflow [0.20s]                  

       Summary: 5 packages finished [3.34s]

 $ cd ~/tf_ws/install/tf_detection_py/lib/tf_detection_py/

 $ ls
       catsNdogs  client_test  face_detection  server

Build still passed: The catsNdogs is added.

Test New Server

Terminal 1

 $ cd

 $ source tf_ws/install/local_setup.sh

 $ ros2 run tf_detection_py catsNdogs 
       2021-11-09 13:20:32.363541: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH:   /home/eepp/tf_ws/install/tf_interfaces/lib:/home/eepp/image_ws/install/stereo_image_proc/lib:/home/eepp/image_ws/install/realsense_ros/lib:/home/eepp/image_ws/install/realsense_msgs/lib:/home/eepp/image_ws/install/realsense_camera_msgs/lib:/home/eepp/image_ws/instal l/image_view/lib:/home/eepp/image_ws/install/image_rotate/lib:/home/eepp/image_ws/install/image_proc/lib:/home/eepp/image_ws/install/depth_image_proc/lib:/home/eepp/turtlebot3_ws/install/turtlebot3_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo- 11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
       2021-11-09 13:20:32.363576: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
       2021-11-09 13:20:36.545787: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/eepp/tf_ws/install/tf_interfaces/lib:/home/eepp/image_ws/install/stereo_image_proc/lib:/home/eepp/image_ws/install/realsense_ros/lib:/home/eepp/image_ws/install/realsense_msgs/lib:/home/eepp/image_ws/install/realsense_camera_msgs/lib:/home/eepp/image_ws/install/image_view/lib:/home/eepp/image_ws/install/image_rotate/lib:/home/eepp/image_ws/install/image_proc/lib:/home/eepp/image_ws/install/depth_image_proc/lib:/home/eepp/turtlebot3_ws/install/turtlebot3_msgs/lib:/usr/lib/x86_64-linux-gnu/gazebo-11/plugins:/opt/ros/foxy/opt/yaml_cpp_vendor/lib:/opt/ros/foxy/opt/rviz_ogre_vendor/lib:/opt/ros/foxy/lib/x86_64-linux-gnu:/opt/ros/foxy/lib
       2021-11-09 13:20:36.545819: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] failed call to cuInit: UNKNOWN ERROR (303)
       2021-11-09 13:20:36.545858: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (hood): /proc/driver/nvidia/version does not exist
       2021-11-09 13:20:36.546099: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
       To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
       2021-11-09 13:20:36.582899: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2)
       2021-11-09 13:20:36.600555: I tensorflow/core/platform/profile_utils/cpu_utils.cc:114] CPU Frequency: 1895600000 Hz
       [INFO] [1636482041.538843887] [detection_server]: Load model completed!
       [INFO] [1636482044.703658020] [detection_server]: Warmup completed! Ready to receive real images!

Terminal 2

 $ cd

 $ source tf_ws/install/local_setup.sh

 $ ros2 run image_tools cam2image --ros-args -p frequency:=2.0
       [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
       [INFO] [1636481898.473283660] [cam2image]: Publishing image #1
       [INFO] [1636481898.972056644] [cam2image]: Publishing image #2
       [INFO] [1636481899.472155372] [cam2image]: Publishing image #3
       [INFO] [1636481899.972165748] [cam2image]: Publishing image #4
       [INFO] [1636481900.472170231] [cam2image]: Publishing image #5
       [INFO] [1636481900.972209576] [cam2image]: Publishing image #6
       [INFO] [1636481901.472175511] [cam2image]: Publishing image #7
       [INFO] [1636481901.972180427] [cam2image]: Publishing image #8
       [INFO] [1636481902.472194537] [cam2image]: Publishing image #9
       [INFO] [1636481902.972204052] [cam2image]: Publishing image #10
       [INFO] [1636481903.472184911] [cam2image]: Publishing image #11
       [INFO] [1636481903.972215544] [cam2image]: Publishing image #12
       [INFO] [1636481904.472212017] [cam2image]: Publishing image #13

Terminal 3

 $ cd

 $ source tf_ws/install/local_setup.sh

 $ ros2 run image_tools showimage image:=detections_image
       [WARN] [1636481946.651601992] [rcl]: Found remap rule 'image:=detections_image'. This syntax is deprecated. Use '--ros-args --remap image:=detections_image' instead.
       [WARN] [1636481946.652138401] [rcl]: Found remap rule 'image:=detections_image'. This syntax is deprecated. Use '--ros-args --remap image:=detections_image' inst

Execution Test Passed: The catsNdogs object detection server works just like the server object detection server works.

Notes and Logs