Skip to content

Run Demo A Z

Chenhao Wu edited this page Aug 2, 2021 · 1 revision

Step 0: Preparation

  • **Connect the RoboMaster and Raspberry Pi according to the wiring configuration instructed in the README.md**

  • Ensure the connectivity of lamppost 258 259 and 260

    (the environment on these lamppost are all ready to go)

    • IP of 258: 10.30.183.12

    • IP of 259: 10.30.183.13

    • IP of 260: 10.30.183.14

    • ssh command:

      $ ssh nclab@${node_id} -p 5512
  • Clibrate the Camera to obtain an xml file like this file

    • Download and compile the program to calibration camera

    • Config the calibration_config.xml to adjust the calibration parameters

      The important parameters all <Input></Input>

      • If video stream are used:
      <Input>udp://0.0.0.0:[VIDEO_PORT]</Input>
      • If video file are used:

        <Input>"path to file"</Input>
    • Find the printed chessboard in Room 317B:

      Chessboard

    • If you want to calibrate the camera use live video

      1. Ensure the video stream is connectable and decodable

      2. Config calibration_configuration.xml

      3. Launch the calibration program:

      $ ./calibration_camera [path to calibration_configuration.xml]
      1. Press 'n' to start calibration
        • Hold up the chess board and stand in front of the camera so that the camera should shoot out the entire board;
        • Try different poses of chess board by rotating and moving further or closer to the camera;
        • Stop when the program indicating the calibration is finished
    • If you want to calibrate the camera use video file (recommended for calibrating on lampposts)

      1. Start recoding the video file:

        • Hold up the chessboard and stand in front of the camera so that the camera could shoot out the entire board;
        • Try different poses of chessboard by rotating and moving further or closer to the camera;
        • Record the video long enough (no less than 1 minutes) to ensure there are sufficient frames used for calibrating the camera;
        • Save the recorded video, e.g. /tmp/video.mp4
      2. Config calibration_configuration.xml

      3. Launch the calibration program:

        $ ./calibration_camera [path to calibration_configuration.xml]
    • When the program stops, a calibration file will be generated like this

    • More information about OpenCV camera calibration: OpenCV Camera Calibration Tutorial

  • Setup gpsref.xml

    • The gpsref.xml file consists of 3 sections:

      <?xml version="1.0"?>
      <RefPoints>
          <RefPoint>
              <aruco_id>10</aruco_id>
              <x>1.0</x>
              <y>0.0</y>
          </RefPoint>
          <Origin>
              <longitude>22.0</longitude>
              <latitude>114.0</latitude>
          </Origin>
          <Metric>
              <longitude_diff_in_xm>1.0</longitude_diff_in_xm>
              <longitude_diff_in_ym>0.0</longitude_diff_in_ym>
              <latitude_diff_in_xm>0.0</latitude_diff_in_xm>
              <latitude_diff_in_ym>1.0</latitude_diff_in_ym>
          </Metric>
      </RefPoints>
    • RefPoint: x,y coordinate of Roadblock to be used as reference roadblock

      • aruco_id: ID of ArUco marker on the roadblock
      • x: x coordinate
      • y: y coordinate
    • Origin: gps coordinate of the (0,0) point in the virtual coordinate system

    • Metric: to quantify how the longitude and latitude differs along x and y axis of the virtual coordinate system

Step 1: Setup BATS Network

The communication backbone of the lamppost are built up on BATS protocol: one can refer to wiki and

  • Basic Steps to initial a BATS Network

    • login to lamppost 258, 259, and 260;

    • move the current directory to /home/nclab/tmp/batspro2 where the latest version BATS Protocol locates in;

    • goto ${batspro2}/Setup and run

      # To start link controller
      $ linkctr-setup -n ${node-id}
      
      # To start bats protocol
      $ btp-setup -n ${node-id}
  • You can use send-recv test to ensure the BATS Network is correctly established;

  • MUST DO!!!: You must check the brt_table in ${batspro2}/Setup/brt_tables to guarantee the routing table is correct, otherwise the packet cannot be routed to the expected destination!

Step 2: Run Lamppost Host Program

  • Fetch the lateset Infra-Autopilot-Assitant Repository follow the instructions

  • Write configuration file

    • For node 260, which is selected as a root node:

      [Networking]
      LocalBATSAddr = 0.0.1.4
      RootBATSAddr = 0.0.1.4
      RootBATSPort = 100
      IsRootNode = 1
      
      [RBDetection]
      Camera1 = udp://0.0.0.0:8000/
      Camera2 = udp://0.0.0.0:8001/
      Cam1RefMarker = 10
      Cam2RefMarker = 10
      MarkerSize = 0.5
      FrameIncrement = 100
      CalibrationFile = _config/webcam_640x480.xml
      GPSReferenceFile = _config/gpsref.xml
      
      [Robot]
      CtrlPan = 0
      CtrlAddr = 1
      RootPan = 0
      RootAddr = 0
      
      [Database]
      Host = 10.26.1.16
      User = lamppost-autopilot
      Database = lamppost_runtime
      Password = *****
      
      [Arena]
      Width = 20.0
      Height = 20.0
      GridSize = 0.1

      The sample file is available at https://github.com/Vito-Swift/Infra-Autopilot-Assistant/blob/dev/_config/lamp260.ini

    • For node 258 and 259, which is selected as slave nodes:

      [Networking]
      LocalBATSAddr = 0.0.1.2
      RootBATSAddr = 0.0.1.4
      RootBATSPort = 100
      
      [RBDetection]
      Camera1 = udp://0.0.0.0:8000/
      Camera2 = udp://0.0.0.0:8001/
      Cam1RefMarker = 10
      Cam2RefMarker = 10
      MarkerSize = 0.5
      FrameIncrement = 100
      CalibrationFile = _config/webcam_640x480.xml
      GPSReferenceFile = _config/gpsref.xml

      The sample file is available at:

  • Run the Lamppost Program

    > ./LamppostHost --config_file ${CONFIG_FILE}
  • You can examine whether the host program launched successfully by querying the backend database (specified in [DATABASE] section in the ini file on the ROOT program)

    $ mysql -u lamppost-autopilot -p
    
    mysql> select * from Lamppost;
    +---------+---------------------+--------+
    | addr    | last_seen           | row_id |
    +---------+---------------------+--------+
    | 0.0.1.3 | 2021-07-23 15:47:25 | 119594 |
    | 0.0.1.4 | 2021-07-23 15:47:25 | 119595 |
    | 0.0.1.3 | 2021-07-23 15:47:26 | 119596 |
    | 0.0.1.4 | 2021-07-23 15:47:26 | 119597 |
    | 0.0.1.3 | 2021-07-23 15:47:27 | 119598 |
    | 0.0.1.4 | 2021-07-23 15:47:27 | 119599 |
    | 0.0.1.3 | 2021-07-23 15:47:28 | 119600 |
    | 0.0.1.4 | 2021-07-23 15:47:28 | 119601 |
    | 0.0.1.3 | 2021-07-23 15:47:29 | 119602 |
    | 0.0.1.4 | 2021-07-23 15:47:29 | 119603 |
    | 0.0.1.3 | 2021-07-23 15:47:30 | 119604 |
    | 0.0.1.4 | 2021-07-23 15:47:30 | 119605 |
    
    ......

Step 3: Control the lamppost host program in root by using lmphostctl

  • Command 1: Stop all the lamppost Host Programs

    ./lmphostctl --service stop
  • Command 2: Start demostration

    ./lmphostctl --service demo --dest_x 0.0 --dest_y 0.0 --config ${PATH_TO_INI_FILE}
  • Command 3: Show statistics

    ./lmphostctl --service stat
  • Command 4: Show log

    ./lmphostctl --service log

Clone this wiki locally