Thymio Yoga Ball Balance

Activity:

Using Thymio’s accelerometer to detect changes in slope, and it’s wheels to adjust back to a level position, the robot is able to balance on top of a large ball, such as a yoga ball.  When the yoga is rotated slowly, Thymio can move to adjust to rest on top of the yoga ball so it does not fall.

 

How to:

  1. Copy and paste this code to Aseba Studio to achieve the balancing behavior:
var accBuffer0[4] = 0,0,0,0
var accBufferPos0 = 0
var accBuffer1[4] = 0,0,0,0
var accBufferPos1 = 0
var sumacc0
var sumacc1

onevent acc
  accBuffer0[accBufferPos0] = acc[0]-2  #measure lateral tilt
  accBufferPos0 = (accBufferPos0 + 1) % 4
  sumacc0 = accBuffer0[0] + accBuffer0[1] + accBuffer0[2] + accBuffer0[3]
  accBuffer1[accBufferPos1] = acc[1]     #measure front tilt
  accBufferPos1 = (accBufferPos1 + 1) % 4
  sumacc1 = accBuffer1[0] + accBuffer1[1] + accBuffer1[2] + accBuffer1[3]

  motor.left.target=sumacc0*15+sumacc1*15    # acc0 gives rotation, acc1 gives forward movement
  motor.right.target=-sumacc0*15+sumacc1*15

This is a video of the result:

Another video showing the same behavior but with a weight to help the adhesion of the wheels on the ball: