|
| 1 | +# SSL Rust Tools |
| 2 | + |
| 3 | +This package contains a rust library for working with [SSL RoboCup log |
| 4 | +files](https://github.com/RoboCup-SSL/ssl-logtools) as well as a |
| 5 | +number of binaries for playing, filtering and labeling log file |
| 6 | +events. See the following sections for more information on the |
| 7 | +utilities included in this packages. |
| 8 | + |
| 9 | +## Building |
| 10 | + |
| 11 | +### Dependencies |
| 12 | + |
| 13 | +This package is written in rust and should work with rust 1.33 or |
| 14 | +later. To install rust visit |
| 15 | +<https://www.rust-lang.org/tools/install>. |
| 16 | + |
| 17 | +You will also need protobuf 3.6.1 or higher. You can install it via |
| 18 | +the system package manager, or you can use the provided |
| 19 | +`make_conan_venv.sh` script to create a locally installed version |
| 20 | +using [Conan](https://conan.io/). |
| 21 | + |
| 22 | +If using the script, install conan and then run the script. It will |
| 23 | +produce a folder called `venv`. To use the virtualenv run `source |
| 24 | +venv/activate_run.sh`. This will set the appropriate environment |
| 25 | +variables so that `protoc` and the protobuf libraries can be found |
| 26 | +during the build. Note: After building, the virtualenv is not needed |
| 27 | +to run as all libraries are statically linked. |
| 28 | + |
| 29 | +### Building |
| 30 | + |
| 31 | +In the root folder run: `cargo build --release`. This will build the |
| 32 | +core library and all command line utilities. |
| 33 | + |
| 34 | +If you want to build the labeling gui run `cargo build --release |
| 35 | +--features=gui`. |
| 36 | + |
| 37 | +## Command Line Utilities |
| 38 | + |
| 39 | +### play_log |
| 40 | + |
| 41 | +The `play_log` command will play an uncompressed log file so that it |
| 42 | +can be visualized by tools such as [SSL Vision |
| 43 | +Client](https://github.com/RoboCup-SSL/ssl-vision-client). |
| 44 | + |
| 45 | +### make_labeler_data_file |
| 46 | + |
| 47 | +This tool will pre-process a saved log file to prepare it for log |
| 48 | +event labeling. The output labeler data file is the format used in the |
| 49 | +[SSL RoboCup 2019 Technical |
| 50 | +Challenge](https://github.com/RoboCup-SSL/technical-challenge-rules). |
| 51 | + |
| 52 | +The log file must be uncompressed. If you have issues uncompressing a |
| 53 | +log file due to `unexpected EOF` errors from gzip then you can use the |
| 54 | +`zcat` utility to stream the extraction. |
| 55 | + |
| 56 | +Either save the zcat output to a file: |
| 57 | + |
| 58 | +``` shell |
| 59 | +zcat compressed_log_file.log.gz > uncompressed_log_file.log |
| 60 | +``` |
| 61 | + |
| 62 | +Or you can stream the zcat output directly to this tool using `-` to |
| 63 | +represent stdin on the input file argument. Like so: |
| 64 | + |
| 65 | +``` shell |
| 66 | +zcat compressed_log_file.log.gz | make_labeler_data_file - output.labeler |
| 67 | +``` |
| 68 | + |
| 69 | +Note: This filtering can take some time. If you use a saved file, the |
| 70 | +progress indicators will be more useful, as the total file size can be |
| 71 | +calculated up-front. |
| 72 | + |
| 73 | +More details about the output file format can be found below |
| 74 | + |
| 75 | +The filtering keeps only messages during ref stages that are running |
| 76 | +(i.e. NORMAL_FIRST_HALF, NORMAL_SECOND_HALF, EXTRA_FIRST_HALF, |
| 77 | +EXTRA_SECOND_HALF). As well as during ref commands that have actually |
| 78 | +started the game play (i.e. NORMAL_START, FORCE_START, |
| 79 | +DIRECT_FREE_YELLOW, DIRECT_FREE_BLUE, INDIRECT_FREE_YELLOW, |
| 80 | +INDIRECT_FREE_BLUE). |
| 81 | + |
| 82 | +When multiple cameras are running SSL Vision, the recorded messages |
| 83 | +are asynchronously sent. Therefore there is no global clock step that |
| 84 | +can be used for a frame. So instead frames are grouped together until |
| 85 | +a camera repeats in the log. This results in most frame messages |
| 86 | +containing a single message from each camera, however, in some cases |
| 87 | +one or more of the camera messages will be missing. |
| 88 | + |
| 89 | +Messages within a frame retain their original order according to their |
| 90 | +order in the log file. The frame just introduces an artificial |
| 91 | +timestep to the file so that labels can correspond to specific frames |
| 92 | +rather than arbitrary timestamps. |
| 93 | + |
| 94 | +### play_labeler_data_file |
| 95 | + |
| 96 | +Play a labeler data file. Similar to playing a normal log, but this |
| 97 | +contains only the filtered messages grouped into frames. |
| 98 | + |
| 99 | +### score_label_file |
| 100 | + |
| 101 | +Will output each label category score given a ground truth and a |
| 102 | +predicted label. Will be used to score the technical challenge during |
| 103 | +the competition. |
| 104 | + |
| 105 | +## Label Data GUI |
| 106 | + |
| 107 | +This package also contains a GUI tool for playing and labeling labeler |
| 108 | +data files. A screenshot is shown below. |
| 109 | + |
| 110 | + |
| 112 | + |
| 113 | +To start you must open a data file using the file menu. Use the file |
| 114 | +browser to find a labeler data file produced by the |
| 115 | +`make_labeler_data_file` program. If you already have a set of labels |
| 116 | +for this file you can open it for editing by using the "open label |
| 117 | +file** option in the file menu. Otherwise, a default label file will be |
| 118 | +produced. You can use the save menu items to save your label file as |
| 119 | +you go. |
| 120 | + |
| 121 | +*NOTE*: Saving will overwite the file that exists. Make sure you are |
| 122 | +saving to the right file before clicking the save buttons. |
| 123 | + |
| 124 | +The upper area contains playback tools. The top two widgets control |
| 125 | +playback speed. With higher numbers being faster. The next two widgets |
| 126 | +control the current frame being displayed. |
| 127 | + |
| 128 | +The player buttons below will change the playback mode. The rewind |
| 129 | +button will play backwards at the specified playback speed. The fast |
| 130 | +forward button will do the same, but forwards. The step back and step |
| 131 | +forward buttons will move one frame backwards or forwards |
| 132 | +respectively. The pause button will pause playback at the current |
| 133 | +frame. |
| 134 | + |
| 135 | +Below the player, is a tab for each type of event |
| 136 | +labeling. Instantaneous events show the label editing for the current |
| 137 | +frame according to the player. Duration events have a list on the left |
| 138 | +hand side. You can add and delete new duration events using the |
| 139 | +buttons above the list. Click on an item in the list to edit it or |
| 140 | +select it for deletion. A screenshot is shown below. |
| 141 | + |
| 142 | + |
| 145 | + |
| 146 | +## Labeler Data File |
| 147 | + |
| 148 | +Produced by the `make_labeler_data_file` utility (see above). |
| 149 | + |
| 150 | +The file is a binary format. All numeric values are written in |
| 151 | +BigEndian order. Each file starts with the following header: |
| 152 | + |
| 153 | +``` text |
| 154 | +1: String - File type ("SSL_LABELER_DATA") |
| 155 | +2: uint32 - Log file format version |
| 156 | +``` |
| 157 | + |
| 158 | +Then the actual frame messages follow. Each message starts with the |
| 159 | +message length, and then a serialized set of bytes for a Protobuf |
| 160 | +`log_labeler_data::LabelerFrameGroup` message. See the |
| 161 | +`log_labeler_data.proto` file for the exact message definition. |
| 162 | + |
| 163 | +``` text |
| 164 | +1: uint32 - Message length |
| 165 | +2: bytes - Binary log_labeler_data::LabelerFrameGroup protobuf message |
| 166 | +``` |
| 167 | + |
| 168 | +This file is designed to be easily seekable to specific messages. As |
| 169 | +such, the final bytes in the file contain metadata about where each |
| 170 | +message in the file starts. The last 4 bytes are the metadata message |
| 171 | +size. Then the proceeding byte string corresponds to a binary protobuf |
| 172 | +`log_labeler_data::LabelerMetadata` message. |
| 173 | + |
| 174 | +``` text |
| 175 | +1: bytes - Binary log_labeler_data::LabelerMetadata protobuf message |
| 176 | +2: uint32 - size of preceding metadata bytes |
| 177 | +``` |
| 178 | + |
| 179 | +## Label File |
| 180 | + |
| 181 | +This is the file produced by the `label_data` gui and scored by the |
| 182 | +`score_label_file` utility. It is just a binary protobuf |
| 183 | +`log_labels::Label` message. It contains a list of all event labels |
| 184 | +specified in the technical challenge rules. |
| 185 | + |
| 186 | +*Note*: that the duration event labels are sorted by start_frame. If |
| 187 | +you do not sort your output by start time you will receive an |
| 188 | +inaccurate score from the scoring program. |
0 commit comments