Wednesday, August 31, 2016

Summer Research Weeks 7+8 Homework


AR Drone Guide Notes
Chapter 7 - Incoming Data Steam

  1. Navigation Data - navdata also known as navigation data is given an application continuously to keep up with the condition of the drone. 
    1. Navigation Data Stream
      1. navdata sent from UDP Port 5554
      2. information is stored in a binary format
      3. made up of many data called options
        1. each option = 2 bytes (header)
      4. important options are
        1. navdata_demo_t
        2. navdata_cks_t
        3. navdata_host_angles_t
        4. navdata_vision_detect_t
      5. content is found in C structure primarily in navdata_common.h
    2. Initiating the reception of Navigation data
      1. to receive navigation data 
        1. drone is in BOOTSTRAP mode when starting
          1. status and sequence counter set only
          2. to exit BOOTSTRAP mode, send AT command to modify the default settings on drone
            1. AT*CONFIG=\"general:navdata_demo\", \"TRUE\"\\r
              1. AT*CTRL=0
        2. drone is always started and navdata demos are send
    3. Augmented reality data stream
      1. drone detects up to four tags or oriented roundel
  2. The AR. Drone 1.0 video stream 
    1. Image Structure
      1. image is split into group of blocks (GOB)
        1. split into Macroblocks to make a 16x16 image
    2. UVLC codec overview, UVLC codec close to JPEG
      1. P264 codec Review
      2. I Frames are complete frames, and it does not need any other frames to decode. 
      3. P Frame use previous frames to predict
        1. use other frames as a reference to build upon
          1. best reference will be sent from the reference picture to the new image or P-picture
    3. Initiating the video stream
        1. client needs to send UDP packet on drone video port
          1. starts to stream
          2. if there is no connection between the client and drone
            1. stream ends
        2. The AR.Drone 2.0 video stream
          1. uses H264 (MPEG4.10 AVC) to video stream 
            1. FPS, frames per second, 15 ~ 30
            2. Bitrate, 250 kbps and 4Mbps
            3. Resolution: 360p (640x360) or 720p (1280x720)
          2. On Apple products it will change
          3. Default 720p, 30FPS, 4Mbps
          4. Live stream uses MPEG4.2 Visual encoder
            1. can be adjusted between 15 to 30 fps and 250 kbps to 1Mbps
        3. video frames are sent with custom headers which informs the user about the frames
          1. headers can be found on page 68
        4. Network transmission of video stream
          1. transmitted on TCP socket 5555
          2. Drone immediately sends frames when connected to socket
          3. Since the frame can be sent in numerous TCP packets
            1. reassemble it by application before doing
            2. In ARDroneTool done within Video/video_stage_tcp.c file
        5. Latency reduction mecanism
          1. latency arises when TCP transmission permits application to all frames
            1. latency reduction mecanism from Video/video_stage_tcp.c file remove the older frames and send the newer ones to the decoder
        6. Video record stream
          1. uses TCP socket 5553 to send out H264-720p frames
            1. stream will not run if application is not running either
          2. converts H264 stream into files that are more accessible like .mov or .mp4 is done by Video/video_stage_encoded_recorder.c file
            1. uses utils/ardrone_video_atoms and utils/ardrone_video_encapsuler

    Chapter 8 - Drone Configuration
    1. With ARDroneTool
      1. include <ardrone_tool/ardrone_tool_configuration.h> file into code to access ardrone_control_config structure
        1. has the configuration of drone
    2. Without ARDroneTool
      1. to get drone configuration without ARDroneTool, send AT*CRTL command with a mode parameter equaling 4
        1. sends on control communication port (TCP port 5559)
    3. Setting the drone configuration
      1. With ARDroneTool
        1. ARDRONE_TOOL_CONFIGURATION_ADDEVENT
          1. set configuration parameters
          2. allows the drone to understand new adjustments
        2. First parameter = name
          1. Second is a pointer of the new value that will be sent to drone
            1. Third is a callback saying that signals completion
              1. if success, 1 -  if fail, 0 and repeats eventually 
        3. From the Control Engine for iPhone
      2. Without ARDroneTool
        1. AT*CONFIG with correct sequence #, parameter note between double-quotes, and parameter value between double-quote to configure drone
      3. Multiconfiguration
        1. share AR.Drone with different configurations
          1. Configuration Keys:
            1. CAT_COMMON - default, all application
              1. holds config keys common to all applications and users
            2. CAT_APPLI - setting saved for current application
              1. application specific configuration
                1. video encoding & navdata_options
            3. CAT_USER - setting saved for current user
              1. switch active users at runtime for applications
            4. CAT_SESSION - setting saved for whole flight
              1. current flight settings
              2. active video camera & detection
              3. default setting after reboot or disconnect
        2. With ARDRoneTool
          1. ardrone_tool_init function takes 2 string pointers to application name and user
            1. sets ardrone_config_t structure called ardrone_application_default_config which holds default configuration
              1. sent to AR.Drone and overwrites default configuration
        3. Without ARDroneTool
          1. if new configuration, AR.Drone requires AT*CONFIG_IDS identifiers that match the default configuration before AT*CONFIG to change settings
      4. General Configuration - GENERAL:
        1. CAT_COMMON, read only
          1. num_version_config - congiuration subsystem version
          2. num_version_mb - drone motherboard hardware version
          3. num_version_soft - drone firmware version
          4. drone_serial - drone serial number
          5. soft_build_date - drone firmware compilation date
          6. motor1_soft - motor 1 board software version, applicable to other motors
          7. motor1_hard - motor 1 board hardware version, applicable to other motors
          8. motor1_supplier - motor 1 board supplier version, applicable to other motors 
          9. flying_time - how long the drone spend flying in seconds
          10. vbat_min - minimum battery life before AR.Drone shutting down
        2. CAT_COMMON, read/write 
          1. ardrone_name - name of AR.Drone 
            1. AT command example: AT*CONFIG=605,"general:ardrone_name","My ARDrone Name"
            2. API use example: ARDRONE_TOOL_CONFIGURATION_ADDEVENT (ardrone_name, "My ARDrone Name", myCallback);
          2. navdata_demo - send navdata to clients or all available information that may or may not contain irrelevant information
            1. TRUE = reduced
            2. FALSE = all data
            3. AT command example: AT*CONFIG=605,"gneeral:navdata_demo","TRUE"
            4. API use example:
              bool_t value = TRUE
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (navdata_demo, &value, myCallback); 
          3. com_watchdog - how long the drone can wait without being commanded by a client program, if exceeds then Com Watchdog triggered state (hovering)
            1. disabled at the moment
          4. video_enable - TRUE default, should not be FALSE (not implemented)
          5. vision_enable - TRUE default, should not be FALSE (not implemented)
        3. CAT_APPLI, read/write
          1. navdata_options - application asks for navdata packets, all navdata packets are found in navdata_common.h file
            1. AT command example: AT*CONFIG=605,"general:navdata_options","105971713"
      5. Control Configuration - CONTROL:
        1. CAT_COMMON, read only
          1. accs_offset - AR.Drone accelerometers offsets
          2. accs_gains - AR.Drone accelerometers gains
          3. gyros_offset - AR.Drone gyrometers offsets
          4. gyros_gains - AR.Drone gyrometers gains
          5. gyros110_offset - 
          6. gryos110_gains -
          7. magneto_offset - 
          8. magneto_radius - 
          9. gyro_offset_thr_x - also for y and z axis
          10. pwm_ref_gyros - 
          11. osctun-value - 
          12. osctun_test -
            *All are Parrot internal debug informations*
        2. CAT_APPLI, read/write
          1. control_level - how drone interprets progressive commands from user
          2. Bit 0 is global enable bit, should be active
          3. Bit 1 is combined yaw mode, roll commands make roll+yaw based turns, good for racing
          4. AT command example: AT*CONFIG=605,"control:control_level","3"
        3. CAT_USER, read/write
          1. euler_angle_max - maximum bending angle in radians for pitch&roll angles
            1. prefer ardrone_at_set_progress_cmd_with_magneto for AR.Drone 2.0, AT command: AT*PCMD_MAG
            2. parameter is a value between 0 to 0.52
            3. AT*CONFIG=605,"control:euler_angle_max",".25"
          2. control_iphone_tilt
            1. angle in radians for iPhone acelerometer command
              1. on AR.FreeFlight, progressive command sent is between 0 and 1 for angles going from 0 to 90.
            2. AT command example: AT*CONFIG=605,"control:control_iphone_tilt",".25"
            3. API use example:
              float iTiltMax = .25;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (control_iphone_tilt, &iTiltMax, myCallback);
          3. control-vz_max
            1. maximum vertical speed of AR.Drone, millimeters per second, 200~2000
            2. AT command example: AT*CONFIG=605,"control:control_vz_max","1000"
            3. API use example:
              uint32_t vzMax = 1000;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (control_vz_max, &vzMax, myCallback);
          4. control_yaw - maximum yaw speed of AR.Drone in radians per second, .7 rads/s to 6.11 rads/s
            1. AT command example: AT*CONFIG=605,"control:control_yaw","3.0"
            2. API use example:
              float yawSpeed = 3.0;
              ARDRONE_TOOL_CONFIGURATION-ADDEVENT (control_yaw, &yawSpeed, myCallback);
          5. indoor_euler_angle_max - used when CONTROl:outdoor is false
          6. indoor_control_vz_max - used when CONTROL:outdoor is false
          7. indoor_control_yaw - used when CONTROL:outdoor is false
          8. outdoor_euler_angle_max - used when CONTROL:outdoor is true
          9. outdoor_control_vz_max - used when CONTROL:outdoor is true
          10. outdoor_control_yaw - used when CONTROl:outdoor is true 
        4. CAT_COMMON, read/write
          1. altitude_min - minimum drone altitude in millimeters
            1. AT command example: AT*CONFIG=605,"control:altitude_min","50"
            2. API use example:
              uint32_t altMin = 50;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (altitude_min, &altMin, myCallback);
          2. altitude_max - maximum drone altitude in millimeters
            1. AT command example: AT*CONFIG=605, "control:altitude_max","3000"
            2. API use example:
              uint32_t altMax = 3000;
              ARDRONE_TOOL-CONFIGURATION_ADDEVENT (altitude_max, &altMax, myCallback); 
          3. outdoor - tells control loop that AR.Drone is flying outside, adjusts to outdoor or indoor settings
            1. AT command example: AT*CONFIG=605,"control:outdoor","TRUE"
            2. API use example:
              boot_t isOutdoor = TRUE;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (outdoor, &isOutdoor, myCallback);
          4. flight_without_shell - tells control loop that AR.Drone is using outdoor hull, turn off when indoor hull different than outdoor setting and matches with setting for outdoor hull
            1. AT command example: AT*CONFIG=605,"control:flight_without_shell","TRUE"
            2. API use example:
              boot_t withoutShell = TRUE;
              ARDRONE_TOOL_CONFIGURATION-ADDEVENT (flight_without_shell, &withoutShell, myCallback);
          5. autonomous_flight - no longer useful but previously used to put drone on autonomous flight mode
          6. flight_anim - launch drone animations, animations can be found in config.h file
            1. MAYDAY_TIMEOUT contains default duration for each flight animation
            2. AT command example: AT*CONFIG=605,"control:flight_anim","3,2"
        5. CAT_USER, read only
          1. manual_trim - should be only used if drone is using manual trims, should not be used - put FALSE setting
        6. CAT_SESSION, read/write
          1. flying_mode - has two flight modes which is either
            1. legacy FreeFlight mode where user controls the drone
            2. semi-autonomous mode, "HOVER_ON_TOP_OF_ROUNDEL" hover on top of ground tag
          2. AT command example: AT*CONFIG=605,"control:flying_mode","0"
          3. API use example:
            FLYING_MODE fMode = FLYING_MODE_FREE_FLIGHT;
            ARDRONE_TOOL_CONFIGURATION-ADDEVENT (flying_mode, &fMode, myCallback);
          4. hovering_range - used when flying mode is "HOVER_ON_TOP_OF_(ORIENTED_)ROUNDEL"
      6. Network Configuration -  NETWORK:
        1. CAT_COMMON, read/write
          1. ssid_single_player - applied when rebooted
            1. AT command example: AT*CONFIG=605,"network:ssid_single_player","myArdroneNetwork"
            2. API use example:
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (ssid_single_player, "myArdroneNetwork", myCallback);
          2. ssid_multi_player - not usable
          3. wifi_mode - adjusts WiFi network, should not be changed
            1. 0  - drone is access point
            2. 1 - drone creates or joins network in Ad-Hoc mode
            3. 2 - drone join network as station
          4. wifi_rate - debug configuration, should not be modified
          5. owner_mac - MAC address pair with AR.Drone
            1. reset by 00:00:00:00:00:00
            2. AT command example: AT*CONFIG=605,"network:owner_mac","01:23:45:67:89:ab"
            3. API use example:
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (owner_mac, "cd:ef:01:23:45:67", myCallback);
      7. Nav-board Configuration - PIC:
        1. CAT_COMMON, read/write
          1. ultrasound_freq
            1. frequency of ultrasound measures for altitude
            2. 22.22Hz or 25 Hz
            3. AT command example: AT*CONFIG=605,"pic:ultrasound_freq","7"
            4. API use example:
              ADC_COMMANDS uFreq = ADC_CMD_SELECT_ULTRASOUND_22Hz;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (ultrasound_freq, &uFreq, myCallback);
            5. values are found in ardrone_common_config.h file
          2. ultrasound_watchdog - should not be modified
        2. CAT_COMMON, read only
          1. pic_version - software version of Nav-board
      8. Video Configuration - VIDEO:
        1. CAT_COMMON, read only
          1. camif_fps - FPS of video interface, may differ from actual framerate
          2. camif_buffers - buffer depth for video interface
          3. num_trackers - number of tracking point for the speed estimation
          4. video_storage_space - size of wifi video record buffer
        2. CAT_COMMON, read/write
          1. codec_fps - current FPS of live video codec, max 30
            1. AT command example: AT*CONFIG=605,"video:codec_fps","30"
            2. API use example:
              uint32_t codecFps = 30;
              ARDRONE_TOOL_CONFIGURATION-ADDEVENT (codec_fps, &codecFps, myCallback);
          2. video_on_usb - TRUE with USB key more than 100 MB of space, video stream will be placed there
            1. AT command example: AT*CONFIG=605,"video:video_on_usb","TRUE"
            2. API use example:
              bool_t recordonUSB = TRUE;
              ARDRONE_TOOL-CONFIGURATION_ADDEVENT (video_on_usb, &recordOnUsb, myCallback);
          3. video_file_index - AR.Drone 2.0 number on last recorded video on USB key
            1. application should not adjust the value on key
        3. CAT_SESSION, read/write
          1. video_codec - current video codec of AR.Drone
            1. AR.Drone 2.0, start/stop record stream
            2. MP4_360P_CODEC - live stream with MPEG4.2 soft encoder, no record stream
            3. H264_360P_CODEC  - live sream with H264 hardware encoder in 360p, no record stream
            4. MP4_360P_H264_720P_CODEC - live stream with MPEG4.2 soft encoder, record stream with H264 hardware encoder in 720p
            5. H264_720P_CODEC - live stream with H264 hardware encoder in 720p, no record stream
            6. MP4_360P_H264_360P_CODEC - live stream with MPEG4.2 soft encoder, record stream with H264 hardware encorder in 360p
            7. AT command example: AT*CONFIG=605,"video:video_codec","129"
            8. API use example:
              codec_type_t newCodec = H264_360P_CODEC;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_codec, &newCodec, myCallback);
          2. video_slices - should not be modified
          3. video_live_socket - should not be modified
        4. CAT_APPLI, read only, multiconfig - read/write
          1. bitrate - when using bitrate control in "VBC_MANUAL", bitrate of video transmission in kilobits per second (500~4000kbps)
            1. different when in VBC_MODE_DYNAMIC, will change kbps dynamically
            2. AT command example: AT*CONFIG=605,"video:bitrate","1000"
            3. API use example:
              uint32_t newBitrate = 4000;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (bitrate, &newBitrate, myCallback);
          2. bitrate_control_mode - enables automatic bitrate control of video stream and also enables configuration to reduce bandwith used by video stream under bad WiFi
        5. CAT_SESSION, read only, multiconfig - read/write
          1. bitrate_control_mode - maximum bitrate a device can handle
            1. VBC_MANUAL, maximum bitrate ignored
            2. VBC_MODE_DISABLED, maximum bitrate applied
            3. AT command example: AT*CONFIG=605,"video:max_bitrate","1000"
            4. API use example:
              uint32_t newMaxBitrate = 4000;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (max_bitrate, &maxNewBitrate, myCallback);
        6. CAT_APPLI, read/write
          1. bitrate_storage - for AR.Drone 2.0 Bitrate *kps) of recording stream
              1. both USB and WiFi record
        7. CAT_SESSION, read/write
          1. video_channel - video channel that will be sent to controller
            1. ZAP_CHANNEL_HORI
            2. ZAP_CHANNEL_VERT
          2. AT command example: AT*CONFIG=605,"video:video_channel","2"
          3. API use example:
            ZAP_VIDEO_CHANNEL nextChannel = ZAP_CHANNEL_HORI;
            ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_channel, &nextChannel, myCallback);
      9. Leds Configuration - LEDS:
        1. CAT_COMMON, read/write
          1. use to launch leds animations
            1. animation names found in led_animation.h file
          2. animation number, frequency, duration
          3. AT command example: AT*CONFIG=605,"leds:leds_anim","3,1073741824,2"
      10. Detection Configuration - DETECT:
        1. CAT_COMMON, read/write
          1. enemy_colors - what color hulls you want to detect: green, yellow, blue - 1,2,3
            1. AT command example: AT*CONFIG=605,"detect:enemy_colors","2"
            2. API use example:
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (enemy_colors, &enemyColors, myCallback);
          2. enemy_without_shell - to detect outdoor hulls, deactivate for indoor hulls
            1. AT command example: AT*CONFIG=605,"detect:enemy_without_shell","1"
            2. API use example:
              uint32_t activated = 0;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (enemy_without_shell, &activated, myCallback);
        2. CAT_SESSION, read/write
          1. detect_type - active tag detection, values at ardrone_api.h
            1. CAD_TYPE_NONE - no detection
            2. CAD_TYPE_MULTIPLE_DETECTION_MODE - configure detection on camera
            3. CAD_TYPE_ORIENTED_COCARDE_BW - black and white oriented roundel detected on bottom facing camera 
            4. CAD_TYPE_VISION_V2 - standard tag detection
            5. AT command example: AT*CONFIG=605,"detect:detect_type","10"
            6. API use example:
              CAD_TYPE detectType = CAD_TYPE_MULTIPLE_DETECTION_MODE;
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (detect_type, &detectType, myCallback);
          2. detections_select_h - bitfields to select detection that should be enabled on horizontal camera, values at ardrone_api.h
            1. TAG_TYPE_NONE - no tag detection
            2. TAG_TYPE_SHELL_TAG_V2 - standard indoor and outdoor hulls tag
            3. TAG_TYPE_BLACK_ROUNDEL - black and white oriented roundel
            4. AT command example: AT*CONFIG=605,"detect:detections_select_h","1"
            5. API use example:
              uint32_t detectH = TAG_TYPE_MASK (TAG_TYPE_SHELL_TAG);
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (detections_select_h, &detectH, myCallback);
          3. detections_select_v_hsync - bitfields to select detection that should be enabled on vertical camera
            1. syncs with hsync mode, 30fps which reduces CPU load 
            2. AT command example: AT*CONFIG=605,"detect:detections_select_v_hsync","2"
            3. API use example:
              uint32_t detectVhsync = TAG_TYPE_MASK (TAG_TYPE_ROUNDEL);
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (detections_select_v_hsync, &detectVhsync, myCallback);
          4. detections_select_v - same as previous point but without the hsync mode
            1. runs at 60 Hz instead of 30 fps
            2. heavier on CPU
            3. should not be used with previous point
            4. AT command example: AT*CONFIG=605,"detect:detections_select_v","2"
            5. API use example:
              uint32_t detectV = TAG_TYPE_MASK (TAG_TYPE_ROUNDEL);
              ARDRONE_TOOL_CONFIGURATION_ADDEVENT (detections_select_v, &detectV, myCallback);
      11. USERBOX section - save navigation data from drone during a time period and take photos
        1. USERBOX:userbox_cmd
        2. USERBOX_CMD_STOP - stop userbox, no parameter
        3. USERBOX_CMD_CANCEL - cancel userbox, deletes content in userbox as well
        4. USERBOX_CMD_START - start userbox, uses date as a string parameter
        5. USERBOX_CMD_SCREENSHOT - takes photo from AR.Drone, 3 parameter
          1. delay - delay between each screenshot
          2. number of burst - # of screenshots
          3. current date - date of screenshot
        6. AT command example: AT*CONFIG=605,"userbox:userbox_cmd","0"
      12. GPS section - GPS: 
        1. CAT_SESSION, read/write
        2. latitude - GPS Latitude sent by device
          1. used for media tagging and userbox recording
          2. AT command example: AT*CONFIG=605,"gps:latitude","4631107791820423168"
          3. API use example:
            double gpsLatitutde = 42.0;
            ARDRONE_TOOL-CONFIGURATION_ADDEVENT (latitude, &gpsLatitude, myCallback);
        3. longitude - GPS Longitude sent by device
          1. used for media tagging and userbox recording
          2. AT command example: AT*CONFIG=605,"gps:longitude","461107791820423168"
          3. API use example:
            double gpsLongitude = 42.0;
            ARDRONE_TOOL_CONFIGURATION_ADDEVENT (longitude, &gpsLongitude, myCallback);
        4. altitude - GPS Altitude sent by device
          1. used for media tagging and userbox recording
          2. AT command: example: AT*CONFIG=605,"gps:altitude","461107791820423168"
          3. API use example:
            double gpsAltitude = 42.0;
            ARDRONE_TOOL_CONFIGURATION_ADDEVENT (altitude, &gpsAltitude, myCallback);
    We remembered how you mentioned that the previous group had trouble with flight control and processing time, so we decided to read the latter chapters of the guide. These two chapters a lot of information about the drone in general. We learned how to configure many settings in the drone - not necessarily the flight control or navigation data - and we think that it could help us in the future.

    No comments:

    Post a Comment