Scribbler Exercises

From Laramie Robotics Club
Jump to: navigation, search

The Scribbler robots are a staple of the LRC. They are quite robust and can be used to a variety of challenges. Controlling the Scribbler requires the Calico program. Check out the wiki pages on information on how to install Calico and where to buy and connect to the Scribbler robots.

Line Following

The line following exercises require the use of the robot's line sensors, robot movement commands, conditional statements, and while loops. The following code snippet is an example of a partial solution.

def lineFollow():
     while True:
          left,right=getLine()
          print(left,right)
          if left==1 and right==1:                
               print("Both sensors report 1")
          elif left==0 and right==1:
               print("Left is 0 and right is 1")
          elif left==1 and right==0:
               print("Left is 1 and right is 0")
          else:
               print("Both sensors are 0")

The Squiggly One

  • Rules: Start with the robot at the 1 or 2 location, and get it to follow the line to the end.

TheSquigglyOne.jpg


The Loop of Doom

  • Rules: Start the robot at the 1 or 2 location, and get it to follow the line to the end. A successful solution requires you go around the loop.

TheLoopOfDoom.jpg


Circuit Maze

  • Make a single lap, start anywhere
  • Start robot at the center of the circuit facing left or right. Robot should go forward, and count the number of lines. Based on the number of lines counted the robot should turn and follow the main circuit line to get to location 1 or 2.

CircuitLabeled.png

Hall of Fame

  • The Squiggly One - Qingfeng Li the Stinky and David Zhang the Nasty aka The Failures(Time: 32.63 seconds)
  • The Loop of Doom - Cooper Jackson and Harrison Steeve (Time: 24.62 seconds)
  • Circuit Maze - Jonah Hogsett (Time: ???)

Drawn Maze Escape

Get the robot from the start location to the maze exit. Solve the mazes with a left wall follow rule, then solve with a right follow rule. Start locations and orientations shown in images.

Minos Maze aka The Labyrinth

MinosMaze.png

Shining Maze aka The Hedges

TheShiningMaze.png

Hall of Fame

-When you solve a maze add your name, time, and name of maze.

Brick Blocks

Use the colored brick blocks for simple obstacle avoidance, or create walls and corridors for wall following. Use either getIR() or getObstacles() for obstacle detection.

def obstacleAvoid():
     setIRPower(124)
     while True:
         left,center,right=getObstacle()
         if left<right:
              turnRight(2,1)
         else:
              turnLeft(2,1)

Obstacle Avoidance

Randomly place bricks around the robot. Have the robot do a random walk without hitting a block.

ScribblerObstacle.png

Wall Follow

Create a an arena with the blocks and get the robot to navigate the arena without hitting an blocks.

ScribblerWallFollow.png

Or check out this demo on Youtube.

https://www.youtube.com/watch?v=9Tq0jTXBo4Q

Vision

Use the robot's camera to solve these challenges. You can do blob challenges with configureBlobObject() and getBlob(). Sample code shown below. Note code snippet is an example and won't necessarily work off the bat.

def followBlob():
blob=configureBlobObject()
while True:
     [m,x,y]=getBlob()
     #show(Picture("blob"))
     if m>1000:
          if x<50:
               turnLeft(0.1,0.5)
         elif x>350:
              turnRight(0.1,0.5)
         else:
              print("Looking at blob")


You can also simply grab the images and manipulate them directly.

pic=takePicture()
show(pic)
blobPic=takePicture("blob")
show(blobPic)
for i in range(pic.width):
     for j in range(pic.height):
          print(pic[i][j])

Blob Tracking

Balloon Follow - Have the robot follow a colored ballon.

ScribblerVisionBalloon.png

Robot Chase - Have one robot follow another. The lead robot can be controlled by arrowKeys.py or joystickLRC.py.

ScribblerVisionChase.png

Boxes and Balloon - Place the robot under a box. When the box is lifted up have the robot turn, find the balloon, and head towards it.

ScribblerBoxBalloon.png

Maze Navigation

Simple T Maze

  • Rules: start with the robot sticking out of the end of the maze. Go to green square, turn either direction and stop before touching the blue square. The back of the robot has to be completely in the wing of the maze.

SimpleTMaze.jpg


Line Detection

Hall of Fame

  • Maze Navigation - Tony Trent the Fantastic and Joshua Arulsamy the Amazing A.K.A. Da Wizards Time: 9.38 Sec

Light Challenges

def readLight():
     while True:
          left,center,right=getLight()
          print(left,center,right)
          if left<right:
               print("left is less than right")
               beep(440,2)
               beep(329,2)
          elif right<left:
               print("right is less than left")
               turnRight(1,1)
          else:
               print("right and left are equal")
               turnLeft(1,1)
               beep(220,2)

Box

For these light challenges you will need to use the getLight() command to read the light sensors.

Party Robot - Box Detection

Program the scribbler so that when the box is ontop of it the scribbler turns randomly and beeps. When the box is pulled off the scribbler it stops moving and making noise. You will have to use the scribbler's light sensors to differentiate between in and out of the box, and then a few turn and beep commands.


ScribblerUnderBox.png

Escape Box

Pull the flap of the box and tie it down with tape. Place the scribbler under the box is a random orientation. Scribbler must find the opening in the box and exit. This challenge can be done with the scribbler exiting going backwards or going forwards.

ScribblerExitBox.png

Laser or Light Follow

Get the scribbler robot to first track (turn left or right) a light source or laser pointer. Then have the scribbler move toward the light, but stop before hitting it.

ScribblerLightFollow.png

Hall of Fame

-Add your name and the name of the challenge when you complete it.

Sound Challenges

The scribbler robot has a built in microphone that detects the loudness of sound. Sample code below.

def useMic():
     while True:
          volume=getMicrophone()
          if volume<100:
               print("Volume is ",volume)
               turnLeft(1,1)
               turnRight(1,1)
         else:
               beep(2,440)
               beep(2,329)
               print("Second print statement. Volume is ",volume)


Interrupting Robot

Have the scribbler beep everything it's mic hears someone talking. You will have to use the scribbler's mic functionality and figure out the right threshold to distinguish between the sound of someone talking and background noise.

Clap and Response

Have the scribbler do a dance and beep everytime someone claps. You can also try tapping something near the microphone if a clap is not enough to trigger the robot.

ScribblerSoundTap.png

ScribblerSound.gif

Safety Bot

Robots can be utilized for a variety of applications. One application is as assistance devices for the disabled. In this challenge you are going to program the robot to be an autonomous wheelchair. Drive the robot with the arrowKeys.py and have it stop when it reaches a drop off or when it is about to run into a wall.

Use the command setIRPower() and getObstacle() to prevent hitting a wall. Use the command getLine() to prevent the dropoff.

setIRPower(126)
leftO,centerO,rightO=getObstacle() 
left,right=getLine()

ScribblerSafetyObstacle.png

ScribblerSafetyEdge.png

Mapping and Localization

This challenge has yet to be formalized. Use scribbler Advanced Commands (shown below) to perform precise movements and possibly follow a map.

getEncoders(): reads and returns the left and right encoders

getEncoders(bool): if passed True the encoder count is reset

getDistance(): returns a number between 0-100 correlated roughly with distance from S2 IR sensors

setS2Volume(): set volume 0-100

beep(0, frequency): beeps frequency until you tell it not to.

getMicrophone(): returns a sample of the microphone correlated to ambient sound level (i.e. how loud)

The following Advanced commands are currently being tested. They work with the Scribbler2 real robot.

moveTo(x, y, "mm" | "s2"): move to position x, y in global coordinates (defaults to mm)

moveBy(x, y, "mm" | "s2"): move by x, y in global coordinates (defaults to mm)

turnTo(angle, "deg" | "s2"): move to angle (defaults to degrees)

turnBy(angle, "deg" | "s2"): move by angle (defaults to degrees)

arcTo(x, y, radius, "mm" | "s2"): arc to position x,y with radius (defaults to mm)

arcBy(x, y, radius, "mm" | "s2"): arc by position x,y with radius (defaults to mm)

arc(degrees, radius): move so many degrees along an arc (radius in mm). Negative degrees make the robot move forward and to the right, positive degrees make the robot move backward to the right. - does not update position and angle, yet

getPosition(): the position (in mm) used by turnTo, turnBy, moveTo, moveBy, arcTo, and arcBy

getAngle(): the angle (in degrees) used by turnTo, turnBy, moveTo, moveBy, arcTo, and arcBy

setPosition(x, y): set the current position (in mm) used by turnTo, turnBy, moveTo, moveBy, arcTo, and arcBy

setAngle(angle): set the current angle (in degrees) used by turnTo, turnBy, moveTo, moveBy, arcTo, and arcBy