Skip to content

Developer's Guide

Kian Wei Ng edited this page Jul 14, 2020 · 9 revisions

Welcome to the Wiki! A more detailed explanation of how things work under the hood will be explained here, for future developers to have an easier transition. Scroll to the bottom for a list of potential to-do items and suggestions.

Updated: 14/7/2020

Program breakdown

There are 4 scripts that are control the bulk of the experiment logic/flow, namely:

  1. postercombiner.py
  2. gui.py
  3. Experiment.py
  4. controller_joystick.py
  • postercombiner.py

Node:

  1. curr_posters

Subscribing to:

  1. poster - PoseStamped
  2. trigger_msgs - Int16
  3. file_name - String

Publishing to:

  1. poster_comb - PoseArray
  2. poster_comb_text - MarkerArray

Description:

This script mainly interfaces with Rviz to enable poster (reward zone) modification and visualization. It receives the file_name which is a csv file specified by the user in a drop down menu. The right csv file is then parsed and visualization info sent to Rviz with poster_comb and poster_comb_text.

It also receives new poster locations specified by the user in Rviz through the poster topic. Modifications will be made to the actual csv file specified by file_name, and updated visualization information sent through poster_comb and poster_comb_text.

The above behavior will continue until a locking mechanism get's toggled (so that users will not accidentally modify rewards during the actual experiment. The locking mechanism interfaces with the Experiment.py script, which publishes trigger_msgs. It stops updating when it receives any new messages from the topic, unless the message is 55, which indicates that the experiment has ended and reward modifications can resume.

  • gui.py

Node:

  1. gui_selection

Publishing to:

  1. file_name - String

Description:

This script uses QT framework to create a graphical interface, allowing users to set experiment parameters. Sends postercombiner.py the current csv file to edit through file_name topic. On clicking the start button, parameters are saved to a eparams.pkl file, and the Experiment.py script gets called.

  • Experiment.py

Node:

  1. triggers

Subscribing to:

  1. amcl_pose - PoseWithCovarianceStamped

Publishing to:

  1. current_poster - PoseStamped
  2. trigger_msgs - Int16

Description:

This script mainly controls the actual experiment and trials. Experiment parameters are read in from eparams.pkl. Recording of data is also controlled here - rosbag with ros timing, csv with psychopy timing. It publishes a number to trigger_msgs to denote different stages of the experiment. The tens digit signify trial stage (cue onset, cue offset, end of trial, end of experiment), and the ones digit codes for reward ID.

On each new trial, the new selected poster location is sent to Rviz through current_poster for displaying purposes. A message is also sent through ./tcp-server to the iPad/iPhone to display the target poster. Trial timings are tracked using psychopy timers. The script listens to key-presses (p, r, t, y, n) for user interaction.

  • controller_joystick.py

Node:

  1. base_scan

Subscribing to:

  1. base_scan - LaserScan
  2. joy - Joy
  3. trigger_msgs - Int16

Publishing to:

  1. RosAria/cmd_vel - Twist

Description:

Maps secondary joystick input (joy) and controls whether it is allowed to actually move the platform. Speed is (see to-do) throttled based on distance to wall, determined by LIDAR base_scan. It also listens to trigger_msgs to lock the secondary joystick during the cue-onset period.

To-do

  1. flags in controller_joystick.py -> update_flag() and move() may be slightly broken now (previously modified for ease of testing)
  2. Improve AMCL localization (physical environment modification, physical platform modification, or AMCL parameter tweaking)
  3. Check that the parameters, loading and saving in gui.py are all working fine (as of last update, only the maze parameters page has been rigorously tested)
  4. Set up hardware connection for Ripple (LPT) and Eyelink (ethernet)
  5. Insert script into existing code for Ripple (trigger recording and saving around Experiment.py)
  6. Insert script to allow for optional eyelink calibration stage, triggered on Start button, to be run before Experiment.py
  7. Experiment script now does not account for poster direction and platform direction. Both sets of information available, just that checking function isn't implemented. Success should only be triggered if platform is in a cone area in front of poster, and is pointed toward the poster.
  8. Reward definition stage hard-codes number of rewards to 6, in postercombiner.py, to_store variable [QOL improvement]
  9. Now unable to create new csv files from gui.py [QOL improvement]
  10. Some paths still need to be fixed to be relative [QOL improvement]
  11. Catch improper experiment termination, killing rosbags etc properly [QOL improvement]

Clone this wiki locally