Skip to content

Latest commit

 

History

History
105 lines (74 loc) · 4.25 KB

README.org

File metadata and controls

105 lines (74 loc) · 4.25 KB

README smp_sphero / Sensorimotor learning experiments with the Sphero

Sensorimotor learning with the Sphero robot

05/2014 - 2017, Oswald Berthold

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

Preparation

This is built on top of the following stacks, make sure to have that installed (tested only on Ubuntu)

  • python-numpy, python-bluetooth, … Use apt-get / distro mechanism
  • ROS base install, use apt-get
  • sphero_ros driver from [fn:1], install via $ROSDISTRO_workspace catkin_make. See the ROS wiki how to set up a catkin workspace.
  • get smp_msgs [fn:3] and install it into your ROS workspace
  • get smp_base from https://github.com/x75/smp_base, then do
export PYTHONPATH=../smp_base:$PYTHONPATH

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

Scripts

When roscore and sphero.py are up and running, you can run ROS clients like e.g. sphero_joystick.py

rosrun joy joy_node

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

When that works, you could try the learning experiments, just to disentangle possible sources of errors.

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

[fn:1] https://github.com/x75/sphero_ros