Skip to content
James Edmondson edited this page Jan 22, 2019 · 10 revisions

Live Plotting Tool

Lets observing data plots in live mode or from a saved file

Make sure GAMS and MADARA are built with python

Tool is developed in Python and is using 'yaml' file for configs and plotting values


Table of Contents


Yaml config file

Create a yaml file to configure the tool. This will be passed to the tool input when starting

Specifying data source

Key for data source is data_source. There are two types of data sources that can be used in yaml file: stk files and live plot from a Knowledge Base.

Plotting Offline from an stk file

Key to specify the file is stk_file. Simply path to the stk file needs to be specified e.g.

data_source:
  stk_file: '/path/to/mystk.stk'
  schemas: '/path/to/schemas/folder'

Plotting Live From a Network Transport

Transport needs to be specified for real knowledge base with the following subkeys in transport key transport: transport_type: specifies transport type and can be ZMQ or UDP or MULTICAST or BROADCAST. Currently only ZMQ and UDP were tested.

hosts: specifies KB hosts with ports, queue_length: transport queue length, read_threads: reading threads, read_thread_hertz: thread reading frequency, kb_name: name for knowledge base. e.g.

data_source:
  transport:
    transport_type: ZMQ
    hosts: ['tcp://127.0.0.1:52502', 'tcp://127.0.0.1:52500']
    queue_length: 100000000
    read_threads: 1
    read_thread_hertz: 1000
    kb_name: nothing
  schemas: '/path/to/schemas/folder'

in both cases if there is capnp data which needs to be plotted its schemas folder needs to be specified.

Specifying Variables to Plot

There are 3 types of keys to be specified

  1. If you want Reference Frames to be plotted, you need to specify them under frame_types key. Specify name of the key, e.g. p1_base_link: and under it reference_frame: as an array, e.g. ['p1_odom', 'p1_base_link']

  2. If you want to 'Any' types to be plotted, use any_types key. They are usually used for capnp types and are in maps.

  3. Other types can be specified directly without putting under mentioned above keys.


Additional Notes on Plots

  1. plot_<number> to specify certain subplots for the given key. For each axes you need to specify also the index and the name, e.g. 0: 'x' and 1: 'y' or 0: 'x' -1: 'time' (-1 index means plotting the key against time), here first plots x against y.

  2. points_per_plot defines the number of points to keep in the plot, and is defined as a number

  3. 3D defines if the key needs to plotted as 3d or as 2d. If the value has more than 1 subvalues they all will be plotted against time. If 3D is set to True then the key will be attemped to plot in 3D graph.

  4. If the type is a map (it is appearing for capnp types defined in any_types), subplots can be specified with subkeys, e.g. position.x: 'x' and position.y: 'y'. In this case full path to the exact subkey in the map can be passed using ., e.g. position.x subkey for pose_in_map key points to pose_in_map[position][x] in the map. If any of the values in the map is an array, it can be accessed by putting the index, e.g. 'key1.key2.[3].key3', where [3] shows that key2 is an array where we take index 3.

  5. You can also leave the content empty and it will be plotted. If you don't mentioned the plot axes, all the keys are being plotted against time.


Example Config File

# config.yaml

data_source:

  stk_file: '/media/sedrak/OS/SET/projects/test.stk'
  schemas: '/media/sedrak/OS/SET/projects/capnp_schemas'

knowledge_record_subkeys: 

  # will plot 'sensors.imu.index' key against toi, as it is 
  sensors.imu.index:

  # frames
  frame_types:     
  
    # Default: Use if reference frame is geo and would like to plot full 
    # pose (position and orientation)  
    'p1_base_link':

    
    # First entry should be upstream reference frame
    'p1_base_link': 
      reference_frame: ['geo', 'p1_base_link']
      points_per_plot: 200
    
    #'p1_base_footprint':
    #  points_per_plot: 50
      #3D: True

    # Use if you would like to map specific position/orientation indices 
    # to x, y, or z axes. Value on lhs of colon indicates index of pose array
    # and rhs indicates label for axis. Plot_1, etc. indicate subplots in figure
    'p1_base_link': 
      reference_frame: ['p1_odom', 'p1_base_link']
      plot_1: 
        0: 'x'
        1: 'y'
      plot_2: 
        -1: 'time'
        0: 'x'
      plot_3:
        -1: 'time'
        1: 'y'
      plot_4: 
        2: 'z'
        -1: 'time'
      points_per_plot: 25

    'p1_base_footprint':
      3D: True

  #Any data types
  any_types:

    'state_estimation.pose_graph.pose_in_map.1':
       plot_1:
         pose.position.x: 'x'
         pose.position.y: 'y'
       plot_2:
         pose.position.x: 'x'
         pose.position.z: 'z'

    'state_estimation.pose_graph.pose_in_map.2':
       3D: True
       plot_1:
         pose.position


Running the Plotting Tool

After configuring the yaml file, you can run the plotting tool by calling: python $GAMS_ROOT/port/python/tools/plotting_sample.py <path_to_config.yaml>

Clone this wiki locally