Week 5 :

Build master/x86: agl-image-weston (barebone)

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

    # After setting up 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 build-x86-weston agl-devel
    $ 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"
    
    $ vim conf/bblayers.conf #Replace the following chunk
    # bblayers.conf
      AGL_META_NETWORKING ?= ""
      AGL_META_PYTHON = "${METADIR}/external/meta-openembedded/meta-python"
    
    # Build the image
    
    $ cd $AGL_TOP/master/build-x86-weston/
    $ source agl-init-build-env #if not sourced
    $ time bitbake agl-image-weston #wait for the build process to finish.
    

Run master/x86: agl-image-weston (barebone) and install core dependencies

  • 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.

  • The main motivation is to slim down meta-ros2-foxy layer to only contain the bare minimum required dependencies to support YDLIDAR-X4. Kindly download the necessary packages, configuration files from qemux86-ros-agl-weston-rpms.

    # gdrive (agl-image-weston barebone): https://drive.google.com/drive/folders/1lQBNWxHNzdRfxSCyUxMkAdkYX6hKH_CP?usp=sharing
    # gdrive (weston-rpms): https://drive.google.com/drive/folders/1Zf263H8egRh6dFjhlcVGyXBa-01LEMjv?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
    
    # Copy packages and config files
    $ cp -r ~/Downloads/*.rpm ./
    $ cp ~/Downloads/ros2-ydlidar-packages.txt ./
    $ cp ~/Downloads/ros_setup.sh ./
    
    # Run
    $ vim startup.sh
      # attach YDLIDAR to the host system.
      #-device usb-host,hostbus=1,hostport=4, 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=4 -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
      
    # Open new terminal and scp package and config files
    $ scp -P 2222 *.rpm root@localhost:~
    $ scp -P 2222 ros2-ydlidar-packages.txt root@localhost:~
    $ scp -P 2222 ros_setup.sh root@localhost:/usr/bin/
    
    # Return to the qemu terminal.
      
    ## Install other dependencies.
    root@qemux86-64:~# rpm --install $(cat ros2-ydlidar-packages.txt)
      
    ## 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:~# 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