Skip to content

Latest commit

 

History

History
110 lines (75 loc) · 4.59 KB

README.org

File metadata and controls

110 lines (75 loc) · 4.59 KB

smp_sphero - early sensorimotor learning experiments with ROS and Sphero

Sensorimotor learning with the Sphero robot

05/2014 - 2017, Oswald Berthold

Python code from the Closed-loop sphero behaviour paper [fn:2].

Installing dependencies

This is built on top of the following python stacks, make sure to have them installed, tested on Ubuntu.

  • numpy, usually from distro w/ apt install python3-numpy
  • bluetooth, the python bluetooth extension module. either apt install python3-bluetooth or pip install pybluez
  • ROS base install, cannot be covered here, please see the ROS installation instructions on https://ros.org/wiki
  • sphero_driver, ROS driver for sphero, clone https://github.com/x75/sphero_ros, install in $ROSDISTRO_workspace catkin_make. See the ROS wiki how to set up a catkin workspace.
  • smp_msgs from [fn:3], install into catkin workspace
  • smp_base, git clone https://github.com/x75/smp_base, cd smp_base, then do export PYTHONPATH=$PWD:$PYTHONPATH

Running the sphero node and testing installation

This is the launch sequence for the sphero ROS node

roscore    
python src/sphero_ros/sphero_node/nodes/sphero.py 

`sphero.py` accepts arguments such as sensorimotor loop frequency and also a BT target address to connect directly to a given device, if you know it. The experiments are tuned to 20 Hz sampling rate so we need to do

python src/sphero_ros/sphero_node/nodes/sphero.py --freq 20

or

python src/sphero_ros/sphero_node/nodes/sphero.py --freq 20 --target_addr sp:he:ro:sa:dd:re

When roscore and sphero.py are up and running from the previous step, the smp_sphero scripts can be run.

sphero_raw.py controller

python3 sphero_raw.py

sphero_joystick.py requires

rosrun joy joy_node
python3 sphero_joystick.py

A few of the utils/tests to check the basic communication is working

Utils
bluerssi.pyLog BT rssi values
sphero_colors.pyBasic color actuation with ros
sphero_joystick.pyControl sphero via ros joy_node
sphero_raw.pyMinimal test of raw communication protocol
sphero_simple_openloop.pySimple open-loop command test
sphero_test.pyAnother minimal test

Learning experiments

When that seems to work, the learning experiments can be tried.

Experiments
sphero_res_learner_1D.py
sphero_res_learner_2D_polar.py
sphero_res_learner_2D.py
sphero_res_learner_1D_analyze.py
sphero_data_recorder.py
hk2.pyHomeostasis and homeokinesis from lpzrobots,
Der & Martius, 201, Playful machines
python sphero_res_learner_1D.py --config default.cfg

You can copy the default.cfg and start editing it to play around with different targets and parameters.

Or try the homeokinesis example and play with self.*_gain parameters (in the code)

python hk2.py --mode hk --loop_time 0.05

Footnotes

[fn:3] https://github.com/x75/smp_msgs

[fn:2] Berthold and Hafner, 2015, Closed-loop acquisition of behaviour on the Sphero robot, https://mitpress.mit.edu/sites/default/files/titles/content/ecal2015/ch084.html