`report_card` guide

The report_card package

Build Status: currently due to missing knowrob dependencies.

The report_card is a CRAM package that extends knowrob system and openEASE environment with functionality of generating a PDF file that contains easy to read (e.g. pie charts, bar charts, tables) robot experiment statistics.

Under the hood

This package is based on Prolog and its interpreter - the main log analysis and computations are done therein.
Once the data is prepared part of it is passed to R via real interface where its processed and needed graphs are prepared. R is also used to store statistics and dump them into CSV and RData formats for easy post-processing. Then, links to prepared figures and log statistics are passed via JPL to Java where they are prepared and injected into selected LaTeX templates with use of Nixo Soft JLR library.
Finally, the same library is used to generate a PDF based on prepared tex files. For details please refer to below figure.

`report_card` flow chart

Report card generation paradigm

To make the package the most universal the report card generation is based on two key concepts report card layout templates and section templates. This approach allows the user to choose the design of the report card and decide which sections should be placed within. Moreover, this design facilitates creating personalised section and including them in the report card without complex code alterations and rebuilding the whole package - see below.

layout

This templates specify overall design of the report card - please see report_card/report_card/tex_templates/reportCard.tex for an example. The most important part of it are \ifthenelse{ \equal{$section5}{} }{}{\input{$section5}} statements which include specified in Prolog sections. The default layout allows up to 10 sections.

sections

Section templates specify the structure of each section in the document - please see report_card/report_card/tex_templates/overview.tex for an example. There are 4 different types of variables that can be used in each section:

  • $argument# - argument in which all LaTeX critical characters will be escaped - for use in normal text;
  • $rawArgument# - argument which is not escaped - for use in verbatim environments and to pass file paths;
  • $seqArguments# - sequences of arguments which are escaped;
  • $rawSeqArguments# - sequences of arguments which are not escaped;

where # should be replaced with number 0 to 19 - currently up to 20 arguments of each type are allowed per section.
For details on using arguments in the LaTeX sections please consult JLR tutorial.

Adding custom section

To add your custom section to the report card please create a file named section_name.tex in the report_card/report_card/tex_templates directory. Use the arguments naming as described above - the order of the arguments is based on the order used in the Java call done within Prolog.

To generate your section from within Prolog add a new predicate to report_card/prolog/report_card.pl file:

generate_section_name(RcHomeOs, SectionPath) :-
  Section = 'section_name',

  code_to_get_all_statistics,

  jpl_datums_to_array([YourVariable1, YourVariable2], Strings),

  jpl_new('[Ljava.lang.String;', 0, RawStrings),

  jpl_datums_to_array([YourOtherVariable11, YourOtherVariable12], SeqStrings1),
  jpl_datums_to_array([YourOtherVariable21, YourOtherVariable22], SeqStrings2),
  jpl_datums_to_array([SeqStrings1, SeqStrings2], SeqStrings),

  jpl_new('[[Ljava.lang.String;', 0, RawSeqStrings),

  jpl_call( 'org.knowrob.report_card.Generator', section, [RcHomeOs, Section, Strings, RawStrings, SeqStrings, RawSeqStrings], SectionPath).

Where RcHomeOs is path to the temporary directory of current report card; Section is the section name (it MUST contain the exact name you gave to your section file without .tex extension), Strings and RawStrings are as described above and of type array of strings and finally, SeqStrings and RawSeqStrings are as described above and of type array of array of strings. If you have no data of specific type to be passed to the section creator you should generate empty array for the first two types e.g. jpl_new('[Ljava.lang.String;', 0, Strings) and empty array of arrays for latter two types e.g. jpl_new('[[Ljava.lang.String;', 0, SeqStrings).


Once your section generator is ready you either need to either alter the current report card generator or create your custom generator. You can also generate the report card manually: for details please see below.

Automated

To alter current generator please append your section to generate_report_card(card_type(default)) predicate as follows:

generate_report_card(card_type(default)) :-
  % initialisation
  rc_temporary_directory(RcTempDir),
  create_directory(RcTempDir),
  prolog_to_os_filename(RcTempDir, RcHomeOs),

  % report card content
  generate_overview(RcHomeOs, Introduction),
  generate_actions(RcHomeOs, Actions),
  generate_statistics(RcHomeOs, Statistics),
  generate_failures(RcHomeOs, Failures),
  generate_summary(RcHomeOs, Summary),

  get_experiment_info(experimentId  , TrialId),

  %%%% custom content
  generate_section_name(RcHomeOs, CustomSection),
  jpl_datums_to_array([Introduction, Actions, CustomSection, Statistics, Failures, Summary], Strings),
  %%%%

  jpl_call( 'org.knowrob.report_card.Generator', rc, [RcHomeOs, TrialId, Strings], RcPdf),

  % data exporting and information outputting
  export_data(data_format(csv)),
  export_data(data_format(r)),
  write('Your report card is available at:\n'),
  write(RcPdf), !.

If you prefer to create custom report card generator first add type predicate to the already existing list: card_type(custom_card_type). and then create custom loader for created type:

generate_report_card(card_type(custom_card_type)) :-
  % initialisation
  rc_temporary_directory(RcTempDir),
  create_directory(RcTempDir),
  prolog_to_os_filename(RcTempDir, RcHomeOs),

  get_experiment_info(experimentId  , TrialId),

  % report card content
  generate_overview(RcHomeOs, Introduction),
  generate_actions(RcHomeOs, Actions),
  generate_statistics(RcHomeOs, Statistics),
  generate_failures(RcHomeOs, Failures),
  generate_summary(RcHomeOs, Summary),

  %%%% custom content
  generate_section_name1(RcHomeOs, Section1),
  generate_section_name2(RcHomeOs, Section2),
  generate_section_name3(RcHomeOs, Section3),
  jpl_datums_to_array([Section1, Section2, Section3], Strings),
  %%%%

  jpl_call( 'org.knowrob.report_card.Generator', rc, [RcHomeOs, TrialId, Strings], RcPdf),

  % data exporting and information outputting
  export_data(data_format(csv)),
  export_data(data_format(r)),
  write('Your report card is available at:\n'),
  write(RcPdf), !.

Manual

To manually generate the report card (using Prolog shell) please use the following sequence:

rc_temporary_directory(RcTempDir), create_directory(RcTempDir), prolog_to_os_filename(RcTempDir, RcHomeOs), get_experiment_info(experimentId  , TrialId), generate_section_name1(RcHomeOs, Section1), generate_section_name2(RcHomeOs, Section2), generate_section_name3(RcHomeOs, Section3), jpl_datums_to_array([Section1, Section2, Section3], Strings), jpl_call( 'org.knowrob.report_card.Generator', rc, [RcHomeOs, TrialId, Strings], RcPdf), export_data(data_format(csv)), export_data(data_format(r)).

Before generating a report card remember to load the data e.g. load_experiment('/home/ros/datasets/ds4/cram_log.owl').!

Using R commands within Prolog

To perform statistical computations R is accessed via real interface in Prolog. As a rough guide please see the example shown below.

Set two lists in Prolog and pass them to R;

A = [1, 2, 3, 4, 5, 6],
B = ['a', 'b', 'c', 'd', 'e', 'f'],
a <- A,
b <- B,

calculate mean of the first list, memorise the result in R variable and pass it back to Prolog;

'a.mean' <- mean(a),
Amean <- 'a.mean',
write(Amean),

and finally, plot a pie-chart to PDF based on the list A with labels B.

<- pdf(file = +"./filename.pdf"),
<- pie('a', labels = sprintf(+"%s of\n%s", 'a', 'b'), main = +"Pie-chart name"),
<- invisible('dev.off()').

Package requirements and installation

For details please refer to this location.

Contributions

Any section contributions are welcomed, please make a pull request with you custom report card generators predicates, report_card_type declarations, section.tex and all additional predicates extending report_card.pl.
Please document all your code and wrap it between %%%%section_name - author - <%%%% and %%%%section_name - author - >%%%%.

Installing KnowRob on ROS (Debian)

Install ROS from here, i.e.:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install ros-indigo-desktop-full
sudo rosdep init
rosdep update

but do not set it to your .bashrc simply source it for now

source /opt/ros/indigo/setup.bash

and finally install

sudo apt-get install python-rosinstall

The next step is to install rosjava in separate workspace according to wiki:

sudo apt-get install ros-indigo-catkin ros-indigo-rospack python-wstool
mkdir -p ~/workspace
wstool init -j4 ~/workspace/src https://raw.githubusercontent.com/rosjava/rosjava/indigo/rosjava.rosinstall
cd ~/workspace
rosdep update
rosdep install --from-paths src -i -y
catkin_make

Now install the catkin with my custom packages (inspired by this):

source ~/workspace/devel/setup.bash
mkdir -p ~/workspace_devel/src
rosdep update
cd ~/workspace_devel/src
catkin_init_workspace
cd ~/workspace_devel/
catkin_make

cd ~/workspace_devel/src
wstool init
wstool merge https://raw.githubusercontent.com/So-Cool/ReportCardGenerator/gh-pages/docs/custom.rosinstall
wstool update

rosdep install --ignore-src --from-paths ./knowrob

cd ~/workspace_devel
source ~/workspace_devel/devel/setup.bash
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
catkin_make

Finally, append these to the .bashrc (remember to verify the paths including <userName>):

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
source /home/<userName>/workspace_devel/devel/setup.bash
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/

alias rswipl='rosrun rosprolog rosprolog knowrob_cram'

alias rcswipl='rosrun rosprolog rosprolog report_card'
alias mim1='mongoimport --db roslog --collection tf tf.json'
alias mim2='mongoimport --db roslog --collection logged_designators logged_designators.json'
alias makeMe='catkin_make -DCATKIN_WHITELIST_PACKAGES="report_card"'

Now you’re ready to go.

source ~/.bashrc

cd ~/workspace_devel
mkdir data
cd data
wget http://www.robots-doing-things.com/incoming/log-packaged-2014-12-30-16-10-37.tar.gz
mkdir log1
tar -zxvf log-packaged-2014-12-30-16-10-37.tar.gz -C ./log1

and

cd ~/workspace_devel/data/log1
mim1
mim2
rcswipl

and load data in Prolog

?- load_experiment('/home/<userName>/workspace_devel/data/log1/cram_log.owl').

done.


To use Real: R interface in Prolog install r-base, r-base-dev and the newest version of SWI-Prolog (tested on 7.2.0) - the one shipped with Ubuntu is too old (6.4.0):

sudo add-apt-repository "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/“
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update

sudo apt-get install r-base
sudo apt-get install r-base-dev


sudo apt-get install software-properties-common
sudo apt-add-repository ppa:swi-prolog/stable
sudo apt-get update

sudo apt-get install swi-prolog

run SWI-Prolog:

swipl

and inside Prolog install Real:

?- pack_install( real ).

KnowRob Local Setup

The more elaborate guide is not quite there yet, but here are the rough steps you need in order to get knowrob_vis running locally (thats the component underlying OpenEASE).

I assume that you do not have a ROS workspace sourced at the moment (as that might result in conflicts of resources when compiling the workspace).

Also, I assume that you’re running a Ubuntu 14.04, and will be using ROS Indigo. If you choose to change one of those, the guide might not necessarily work. Let me know when something fails for you, as I don’t know your exact setup.

Please read the KnowRob installation docs before starting to follow this guide; it will clear up some questions that might come up later (especially concerning rosjava).

  • Follow the steps in the official ROS setup tutorial for setting up Indigo.

  • You will need rosjava, as KnowRob is built on top of it. This guide will require you to create a second workspace, just follow the steps.

  • Now you’ll need to check out KnowRob. That’s described in the link I inserted before; you’ll need the Basic KnowRob version only for now (that’s the top-most option in their guide).

If everything works as expected, you should be able to run

$ roslaunch knowrob_vis knowrob_vis.launch

after everything was set up. If this works (and doesn’t fail with a big red error message), we can go on to the next steps. If it does, please let me know what went wrong.

Current State

I talked to my colleague managing the OpenEASE server instance. He’s looking into getting the real module on the server.

The report card should initially display information about the fetch and place experiments. This is a defined environment for development and testing of the report functionalities. Later on, this can be extended to other experiments.

I’d like to talk about the information that will be included in the reports on a pretty high level tomorrow; to define an overview of expectations. This would include:

  • Most important actions during the experiment: This can be based on a list of important task types

  • General statistics: How long did the experiment take, how much time was spent on motion planning, how much on navigation/perception etc. This should be limited to those high level concepts to allow a quick glimpse on the “quality” of the currently used algorithms during the experiment.

  • Special failure display: The robot couldn’t grasp an object when tried (and out of what reason it failed). The logs include information about failures thrown by the robot. If an action failed, but no failure was attached, this is considered an anomaly and identifies a problem in the plans.

This is not an exhaustive list, but just a set of ideas. We can discuss those on a high level to decide on a direction to take. Let me know about your thoughts on that tomorrow (and also about more concrete ideas you had so far).

Week 0 schedule

  • PlDoc - use native Prolog documentation system.
  • Install real on server.
  • Fork the repository.
  • Get up and running with the system.
  • Prepare sample Prolog code.
  • Prepare LaTeX template.
  • Prepare agenda the day before each meeting.
  • Put proposal timeline into the Google calendar.

Preliminary information & background

  1. openEASE: this is where the result of your coding efforts will be deployed.
  2. Paper: an overview paper about openEASE.
  3. Here: prolog/knowrob_vis.pl holds the predicates currently available for displaying information on openEASE.
  4. Here: the MongoDB interface for KnowRob (the underlying knowledge base “for robots”). Here, sub-symbolic (sensor) information from the log files is saved. prolog/knowrob_mongo.pl lets you look at the predicates currently available for getting sub-symbolic information from a log.
  5. Here: access to the symbolic information extracted from logs; prolog/knowrob_plan_logs.pl holds the main predicates.

Running openEASE locally

Here: pick and place experiments. It includes:

  • an OWL file cram_log.owl, reflecting the semantic structure of the experiment,
  • a couple of .json files holding sub-symbolic information (TF, tf.json) and description entities (Designators, logged_designators.json); import them to MongoDB:
mongoimport --db roslog --collection tf < tf.json
mongoimport --db roslog --collection logged_designators < logged_designators.json
  • pictures taken by the robot during some actions, referenced in the OWL file.

Now install the OpenEASE and KnowRob locally via Docker. This should already contain a sample pick and place experiment; for importing new ones, you will need to rebuild the Docker containers here.

For forked GitHub repository the dev files are here on the indigo-devel branch. knowrob/docker and knowrob_webtools, both master branch, are also needed. All the rest is as described here.