Week 9 :

Creation of packagegroup-agl-ros2-ydlidar to simpfily embedding of meta-ros + YDLIDAR support

  • Create new packagegroup, packagegroup-agl-ros2-ydlidar with minimal list of ros packages for ydlidar.

    # Change into AGL feature directory
    $ cd $AGL_TOP/master/meta-agl/meta-agl-core/recipes-platform/packagegroups
      
    # Edit BB file to include minimal list of ros packages for ydlidar
    $ vim packagegroup-agl-ros2-ydlidar.bb
      
        DESCRIPTION = "The minimal set of packages required for ydlidar support with ROS2"
        LICENSE = "MIT"
    
        inherit packagegroup
    
        PACKAGES = "\
            packagegroup-agl-ros2-ydlidar \
            "
    
        ALLOW_EMPTY_${PN} = "1"
    
        RDEPENDS_${PN} += " \
              action-msgs \
              ament-cmake \
              ament-index-cpp \
              ament-index-python \
              ament-package \
              builtin-interfaces \
              class-loader \
              composition-interfaces \
              console-bridge-vendor \
              fastrtps \
              foonathan-memory-vendor \
              geometry-msgs \
              launch \
              launch-ros \
              libstatistics-collector \
              libyaml-vendor \
              lifecycle-msgs \
              message-filters \
              osrf-pycommon \
              rcl \
              rcl-action \
              rcl-interfaces \
              rcl-logging-spdlog \
              rcl-yaml-param-parser \
              rclcpp \
              rclcpp-action \
              rclcpp-components \
              rclpy \
              rcpputils \
              rcutils \
              rmw \
              rmw-dds-common \
              rmw-fastrtps-cpp \
              rmw-fastrtps-shared-cpp \
              rmw-implementation \
              rmw-implementation-cmake \
              ros-workspace \
              ros2cli \
              ros2launch \
              ros2pkg \
              ros2topic \
              rosgraph-msgs \
              rosidl-adapter \
              rosidl-cmake \
              rosidl-default-runtime \
              rosidl-generator-c \
              rosidl-generator-py \
              rosidl-parser \
              rosidl-runtime-c \
              rosidl-runtime-cpp \
              rosidl-runtime-py \
              rosidl-typesupport-c \
              rosidl-typesupport-cpp \
              rosidl-typesupport-fastrtps-c \
              rosidl-typesupport-fastrtps-cpp \
              rosidl-typesupport-interface \
              rosidl-typesupport-introspection-c \
              rosidl-typesupport-introspection-cpp \
              ydlidar-ros2-driver \
              rpyutils \
              sensor-msgs \
              spdlog-vendor \
              statistics-msgs \
              std-msgs \
              std-srvs \
              tf2 \
              tf2-msgs \
              tf2-py \
              tf2-ros \
              unique-identifier-msgs \
              visualization-msgs \   
          "
    
    # Change into AGL feature directory
    $ cd $AGL_TOP/master/meta-agl/templates/feature/agl-ros2-ydlidar/
    
    # Edit CONF file
    $ vim 50_local.conf.inc
    
      #meta-ros2-ydlidar                
    
      IMAGE_INSTALL_append = " packagegroup-ros-world-foxy"
    

Build master/x86: meta-ros + agl-image-weston + YDLIDAR support using updated agl-ros2-ydlidar feature to include packagegroup-agl-ros2-ydlidar

  • Kindly go through build process of AGL and building for x86 for detailed reference to setup and initialize AGL workspace.

    # Clone the meta-ros layer, skip if already cloned
    $ cd $AGL_TOP/master/external
    $ git clone https://github.com/ros/meta-ros.git
    $ cd meta-ros
    $ git checkout -b dunfell
    
    # Setup build directory
    $ cd $AGL_TOP/master/
    $ source meta-agl/scripts/aglsetup.sh -b new-build-x86-meta-ros-weston-agl-ros2-ydlidar agl-devel agl-ros2-ydlidar
    $ ln -sf $AGL_TOP/site.conf conf/
    $ ls -alh conf/
    
    # Edit the following conf files :
    
    $ vim conf/local.conf #add the following to the bottom, to save error logs for future debugging
    # local.conf
      INHERIT += "buildhistory"
      BUILDHISTORY_COMMIT = "1"
    
    # Build the image
    
    $ cd $AGL_TOP/master/new-build-x86-meta-ros-weston-agl-ros2-ydlidar/
    $ source agl-init-build-env #if not sourced
    $ bitbake -p ros-core #build ros-core first, to check all layers are added.
    $ time bitbake agl-image-weston #wait for the build process to finish.
    

Run master/x86: meta-ros + agl-image-weston + YDLIDAR support using updated agl-ros2-ydlidar feature to include packagegroup-agl-ros2-ydlidar

  • Kindly use pre-built image agl-image-weston-qemux86-64, if you want to skip the building process.

  • Kindly go through using prebuilt x86 images for detailed reference to setup and initialize AGL workspace.

    # gdrive : https://drive.google.com/drive/folders/1gXNhTAFDtGlcTLpm4r0QdhqlkCHzHiM0?usp=sharing
    
    # Install the dependencies
    $ apt-get install qemu
    $ sudo apt install vinagre
    $ sudo apt install qemu-system-x86
    
    # Copy image and kernel files
    $ cp ~/Downloads/agl-image-weston-qemux86-64.ext4 ./
    $ cp ~/Downloads/bzImage ./
    $ sync
    
    # Run
    $ vim startup.sh
      # attach YDLIDAR to the host system.
      #-device usb-host,hostbus=1,hostport=1, change accordingly to ydlidar usb port `lsusb -t` 
    
      ( sleep 5 && vinagre --vnc-scale localhost ) > /tmp/vinagre.log 2>&1 &
          qemu-system-x86_64 -device virtio-net-pci,netdev=net0,mac=52:54:00:12:35:02 -netdev user,id=net0,hostfwd=tcp::2222-:22 \
          -drive file=agl-image-weston-qemux86-64.ext4,if=virtio,format=raw -show-cursor -usb -usbdevice tablet -device virtio-rng-pci \
          -device usb-host,hostbus=1,hostport=1 -vga virtio \
          -vnc :0 -soundhw hda -machine q35 -cpu kvm64 -cpu qemu64,+ssse3,+sse4.1,+sse4.2,+popcnt -enable-kvm \
          -m 2048 -serial mon:vc -serial mon:stdio -serial null -kernel bzImage \
    
    $ sudo ./startup.sh
    
    # Boots up
    qemu-system-x86_64: -usbdevice tablet: '-usbdevice' is deprecated, please use '-device usb-...' instead
    qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
    
    Automotive Grade Linux 11.91.0+snapshot qemux86-64 ttyS1
    
    qemux86-64 login: root
        
    ## Run ROS.
    root@qemux86-64:~# source /usr/bin/ros_setup.sh
    root@qemux86-64:/# echo $LD_LIBRARY_PATH
      /usr/lib/x86_64-linux-gnu:/usr/lib
    
    ## Run YDLIDAR.
    root@qemux86-64:/# cd /usr/share/ydlidar_ros2_driver/ 
    root@qemux86-64:/# vim params/ydlidar.yaml
    # Edit accordingly, for YDLIDAR X4 :
      ydlidar_ros2_driver_node:
        ros__parameters:
          port: /dev/ttyUSB0
          frame_id: laser_frame
          ignore_array: ""
          baudrate: 128000
          lidar_type: 1
          device_type: 0
          sample_rate: 5
          abnormal_check_count: 4
          resolution_fixed: true
          reversion: false
          inverted: true
          auto_reconnect: true
          isSingleChannel: false
          intensity: false
          support_motor_dtr: true
          angle_max: 180.0
          angle_min: -180.0
          range_max: 12.0
          range_min: 0.1
          frequency: 8.0
          invalid_range_is_inf: false
    
    root@qemux86-64:/usr/share/ydlidar_ros2_driver# ros2 launch launch/ydlidar_launch.py # YDLIDAR starts spinning
    
    # In a new terminal, ssh into qemu : $ ssh -p 2222 root@localhost
    root@qemux86-64:~# source /usr/bin/ros_setup.sh
    root@qemux86-64:/# echo $LD_LIBRARY_PATH
      /usr/lib/x86_64-linux-gnu:/usr/lib
    root@qemux86-64:~# ros2 topic list -t
      /parameter_events [rcl_interfaces/msg/ParameterEvent]
      /rosout [rcl_interfaces/msg/Log]
      /scan [sensor_msgs/msg/LaserScan]
      /tf_static [tf2_msgs/msg/TFMessage]
      /ydlidar_ros2_driver_node/transition_event [lifecycle_msgs/msg/TransitionEvent]
    root@qemux86-64:~# ros2 topic echo /scan # View data stream
        
    # In either terminal
    root@qemux86-64:/# poweroff #else, runs in background
    

Updating agl-ros2-ydlidar feature to add qt bits

  • Update agl-ros2-ydlidar feature template with qt packagegroup (packagegroup-agl-appfw-native-qt5).

    # Change into AGL feature directory
    $ cd $AGL_TOP/master/meta-agl/templates/feature/agl-ros2-ydlidar/
    
    # Edit CONF file
    $ vim 50_local.conf.inc
    
      #meta-ros2-ydlidar                
    
      IMAGE_INSTALL_append = " packagegroup-agl-ros2-ydlidar"
      IMAGE_INSTALL_append = " packagegroup-agl-appfw-native-qt5"
    

Build master/x86: meta-ros + agl-image-weston + YDLIDAR + qt support using updated agl-ros2-ydlidar feature

  • Kindly go through build process of AGL and building for x86 for detailed reference to setup and initialize AGL workspace.

    # Clone the meta-ros layer, skip if already cloned
    $ cd $AGL_TOP/master/external
    $ git clone https://github.com/ros/meta-ros.git
    $ cd meta-ros
    $ git checkout -b dunfell
    
    # Setup build directory
    $ cd $AGL_TOP/master/
    $ source meta-agl/scripts/aglsetup.sh -b new-build-x86-meta-ros-weston-agl-ros2-ydlidar-qt agl-demo agl-devel agl-ros2-ydlidar
    $ ln -sf $AGL_TOP/site.conf conf/
    $ ls -alh conf/
    
    # Edit the following conf files :
    
    $ vim conf/local.conf #add the following to the bottom, to save error logs for future debugging
    # local.conf
      INHERIT += "buildhistory"
      BUILDHISTORY_COMMIT = "1"
    
    # Build the image
    
    $ cd $AGL_TOP/master/new-build-x86-meta-ros-weston-agl-ros2-ydlidar-qt/
    $ source agl-init-build-env #if not sourced
    $ bitbake -p ros-core #build ros-core first, to check all layers are added.
    $ time bitbake agl-image-weston #wait for the build process to finish.
    

Run master/x86: meta-ros + agl-image-weston + YDLIDAR + qt support using updated agl-ros2-ydlidar feature

  • Kindly use pre-built image agl-image-weston-qemux86-64, if you want to skip the building process.

  • Kindly go through using prebuilt x86 images for detailed reference to setup and initialize AGL workspace.

    # gdrive : https://drive.google.com/drive/folders/1t_hxaajfBRxmILnJQ0yQC1BUodNYpiz3?usp=sharing
    
    # Install the dependencies
    $ apt-get install qemu
    $ sudo apt install vinagre
    $ sudo apt install qemu-system-x86
    
    # Copy image and kernel files
    $ cp ~/Downloads/agl-image-weston-qemux86-64.ext4 ./
    $ cp ~/Downloads/bzImage ./
    $ sync
    
    # Run
    $ vim startup.sh
      # attach YDLIDAR to the host system.
      #-device usb-host,hostbus=1,hostport=1, change accordingly to ydlidar usb port `lsusb -t` 
    
      ( sleep 5 && vinagre --vnc-scale localhost ) > /tmp/vinagre.log 2>&1 &
          qemu-system-x86_64 -device virtio-net-pci,netdev=net0,mac=52:54:00:12:35:02 -netdev user,id=net0,hostfwd=tcp::2222-:22 \
          -drive file=agl-image-weston-qemux86-64.ext4,if=virtio,format=raw -show-cursor -usb -usbdevice tablet -device virtio-rng-pci \
          -device usb-host,hostbus=1,hostport=1 -vga virtio \
          -vnc :0 -soundhw hda -machine q35 -cpu kvm64 -cpu qemu64,+ssse3,+sse4.1,+sse4.2,+popcnt -enable-kvm \
          -m 2048 -serial mon:vc -serial mon:stdio -serial null -kernel bzImage \
    
    $ sudo ./startup.sh
    
    # Boots up
    qemu-system-x86_64: -usbdevice tablet: '-usbdevice' is deprecated, please use '-device usb-...' instead
    qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]
    
    Automotive Grade Linux 11.91.0+snapshot qemux86-64 ttyS1
    
    qemux86-64 login: root
        
    ## Run ROS.
    root@qemux86-64:~# source /usr/bin/ros_setup.sh
    root@qemux86-64:/# echo $LD_LIBRARY_PATH
      /usr/lib/x86_64-linux-gnu:/usr/lib
    
    ## Run YDLIDAR.
    root@qemux86-64:/# cd /usr/share/ydlidar_ros2_driver/ 
    root@qemux86-64:/# vim params/ydlidar.yaml
    # Edit accordingly, for YDLIDAR X4 :
      ydlidar_ros2_driver_node:
        ros__parameters:
          port: /dev/ttyUSB0
          frame_id: laser_frame
          ignore_array: ""
          baudrate: 128000
          lidar_type: 1
          device_type: 0
          sample_rate: 5
          abnormal_check_count: 4
          resolution_fixed: true
          reversion: false
          inverted: true
          auto_reconnect: true
          isSingleChannel: false
          intensity: false
          support_motor_dtr: true
          angle_max: 180.0
          angle_min: -180.0
          range_max: 12.0
          range_min: 0.1
          frequency: 8.0
          invalid_range_is_inf: false
    
    root@qemux86-64:/usr/share/ydlidar_ros2_driver# ros2 launch launch/ydlidar_launch.py # YDLIDAR starts spinning
    
    # In a new terminal, ssh into qemu : $ ssh -p 2222 root@localhost
    root@qemux86-64:~# source /usr/bin/ros_setup.sh
    root@qemux86-64:/# echo $LD_LIBRARY_PATH
      /usr/lib/x86_64-linux-gnu:/usr/lib
    root@qemux86-64:~# ros2 topic list -t
      /parameter_events [rcl_interfaces/msg/ParameterEvent]
      /rosout [rcl_interfaces/msg/Log]
      /scan [sensor_msgs/msg/LaserScan]
      /tf_static [tf2_msgs/msg/TFMessage]
      /ydlidar_ros2_driver_node/transition_event [lifecycle_msgs/msg/TransitionEvent]
    root@qemux86-64:~# ros2 topic echo /scan # View data stream
        
    # In either terminal
    root@qemux86-64:/# poweroff #else, runs in background