Computer Science
Gilmour AcademyLancerTech
  • Our Curriculum and Department
  • Intro to Programming
    • 1: Parts of a Computer
    • 2: Parts of Python
    • 3: DRY Turtle
    • 4: Turtle Design App
    • Wordle with Turtles
    • 5: Interactive Turtles
    • OLD 5: Replit, GitHub, and repositories (Oh my!)
    • 6: Raspberry Pi / GoPiGo
    • 7: Kivy
  • Intro to Web Design
    • 1: Internet?
    • 2: Websites?
    • 3: Bootstrap Template
    • 4: Graphics and Branding
    • 5: Collaboration
    • 6: Advanced Editing
    • Publish Static HTML
  • AP Computer Science
    • 1: Logic & Instances
    • 2: How Java Works
    • 3: Data Types & Flow
    • 4: Strings
    • 5: Objects & References
    • 6: Inheritance & Algorithms
    • 7: Data Structures
    • 8: Sorting
    • 9: Review
    • Data Science
  • Web App Dev
    • 1: Core Concepts
    • 2: MVT Pattern
    • 3: Hello Flask
    • 4: Install Flaskinni
    • 5: Tour Flaskinni
    • 6: Visualize Your App
    • 7: Theme & Blueprint
    • 8: Standup Your DB
    • 9: Advanced Topics
    • 10: Deployment
  • 2D Game Design
    • Class Overview
    • Gamemaker Studio 2 and Github Setup
    • Game 1: Bouncing Ball
    • Turning in your games
    • Game 2: Maze
    • Game 3: Ping Pong
    • Game 4: Breakout
    • Game 5: Tank Battle
    • Game 6 Highlights
    • DO NOT DO:
    • Game 7: Final Project
    • Publish to Opera
    • FAQ
  • 3D Game Design
    • 1: Class Overview
    • 2: Installation
    • 3: Exploring the Unity UI
    • Game 1: Rolling Ball
    • Game 2: Tanks
    • Game 3: Third Person Platformer
    • Game 4: Final project
    • FAQs
    • OLD: Distance Learning Setup
    • OLD: GIT
  • 3D Modeling & Fabrication
    • Installation
    • Fusion 360 Interface and Sketch Modeling
    • Primitive Modeling
    • Patterns
    • Appearances and Rendering
    • Building Community Gallery Page 2023
    • Parametric Modeling
    • 3D Printing Concerns
    • Assemblies and Mechanical Design
    • Laser Cutting
    • Sculpt Tools
    • Milling Concerns
  • Robotics 7
    • Software Installation
    • Python basics (trinket.io)
    • Python Turtle
    • Programming for the Ev3
    • Setting up for clarity
  • Robotics 8
    • Replit
    • Python review
    • Kivy Basics
    • Calculator
  • Competitive Robotics
    • Hardware Team
      • CAD Examples
      • Elevators
    • Software Team
      • Command Pattern
      • Example Command
      • Subsystem
      • Running Your Code
      • Under the Hood
      • RoadRunner
      • Vision Processing
  • Archives
    • Adiletta Archives
      • Old Web
        • Ex: WordPress CMS
      • ItP
        • OLD: Parts of Python (old -- Mr. A)
        • OLD: 5: Raspberry Pi
        • OLD: 6: Deploying Code
        • OLD 7: Nav Algorithm
    • Vanek Archives
      • OLD Robotics 8
        • OLD: End of Class Project
      • OLD Competitive Robotics
        • Untitled
        • Webots Videos
      • OLD Robotics 7
        • Trinket Introduction
        • Lists: x/y position
        • Functions: Math program
        • Lists: Grocery List
        • Study Guide Program
        • Tic Tac Toe Game
        • Dice Roller Program
        • Visualization
        • Dice Roller + Visualization
        • OpenSCAD: Installation
        • OpenSCAD: Command Sheet and Intro
        • OpenSCAD: Difference
        • OpenSCAD: Variables
        • OpenSCAD: Union
        • OpenSCAD: For Loops
        • OpenSCAD: Final Project
      • OLD Art I - Blender Sculpting
        • Class Overview
        • Installation
        • Lesson 1 - Tools
        • Lesson 2 - Detail
        • Lesson 3 - Base Mesh: Metaballs
        • Lesson 4: Converting metaballs and adding detail
        • Lesson 5: Masking, Hiding, and Working with Multiple Objects
        • Lesson 6: Joining Objects & Basing
        • Lesson 7: Sculpture Painting
        • Student Gallery: Animal Sculpts
        • Lesson 8: 3D Compositon
        • Lesson 9: The Project - Putting it all together
        • Lesson 10: Developing the image further
        • Lesson 11: Layout the base metaball mesh.
        • Lesson 12: Final Detail
        • Lesson 13: Basing and Painting
        • Final Project Gallery
      • OLD Fab
        • OLD Building Community Project Gallery
        • Copy of Building Community Project Gallery
        • old Building Community Project Gallery
      • OLD: Turtle Design App
      • OLD Arduino Robotics 8
        • Arduino Basic Commands Cheat Sheet
        • Logging into Tinkercad
        • Arduino, Circuits, LEDs and Resistors
        • Functions and Variables
        • Serial Monitor
        • Buttons and Interrupts
        • Traffic Light Project
        • Potentiometers + Servos
        • Piezo Buzzer and Tone();
        • Sequencer Project
        • Arrays and for loops
        • Extra Loop Practice
        • Refining the Sequencer
        • Servos
        • Ultrasonic Sensors
        • Final Project
Powered by GitBook
On this page
  • Expectations
  • Learning Targets
  • Assessments
  • Terms
  • Getting Started
  • Fork code
  • Push code to GitHub
  • Pull code on robot
  • Calibrate
  • Midpoint
  • Motor Speeds
  • Moving Your Robot
  • Dance Project
  • Higher-Ordered Logic
  • Shutting down the robot
  • Basic Movement Methods
  • Intermediate Movement Methods
  • Maze Navigation

Was this helpful?

Export as PDF
  1. Intro to Programming

6: Raspberry Pi / GoPiGo

Expectations

Learning Targets

  • I can connect to my Raspberry Pi via SSH.

  • I can deploy an app to a Raspberry Pi.

  • I can compose a higher-ordered algorithm.

  • I can update code on my Raspberry Pi.

  • I can make short, descriptive commit messages.

Assessments

  • You will submit a link to your GitHub repo.

  • You will demonstrate your capacity to control your robot.

  • You will be asked regular comprehension questions about Raspberry Pis.

Terms

Printed Circuit Board (PCB)

​

Single Board Computer (SBC)

This is a PCB with all the basic components found in a personal computer (PC)

Getting Started

Fork code

  1. Open Replit and start a new project from github

  2. Use your forked github project. You should now see your code on your editor. Explore student.py and teacher.py.

  3. Open putty and enter the ip address of your robot. Click open.

    • login: pi

    • password: robots1234

  4. Remove the Piggy folder if it's already there: rm -rf Piggy

  5. Now we'll clone your project on the robot too with git clone https://github.com/YOURUSERNAME/Piggy

  6. Change to your project folder: cd Piggy

  7. Run the app: python3 student.py

Push code to GitHub

Whenyou make changes to your app and want to update the code on your robot, we first need to send the code from our computers to GitHub. This happens in the version control tab by typing in "What did you change" and hitting Commit & Push.

Pull code on robot

Now we'll remote control our robots using SSH. We'll use Linux commands to pull the updated code down from GitHub.

Open putty and enter the ip address of your robot. Click open.

  • login: pi

  • password: robots1234

Note: You will not see the password when typing. This is a security feature!

  1. Make sure you're in the right folder: cd Piggy

  2. Pull your updated code: git pull origin master

  3. Run your app: python3 student.py

  4. If it doesn't run, study the error.

Calibrate

We'll need to configure your class variables.

Midpoint

Motor Speeds

Sometimes one motor will perform faster than the other, giving the robot a noticeable veer. We can try to correct for this drift by adjusting the motor power.

Moving Your Robot

Dance Project

Check out what commands are available from the API that's provided for you. These are the commands you're inheriting.

Higher-Ordered Logic

Your dance method should read as close to regular English as possible. The nitty-gritty commands are all kept in the particular methods being called in your dance algorithm. So your dance method should just call a handful of moves. Within those moves, you'll use the specific motor commands below and get into the nitty-gritty of robot control.

  • deg_fwd(angle) - how many degrees do you want your wheels to rotate? You need to pass the angle

  • turn_to_deg(angle) - rotates to the given angle as calculated by the piggy's gyroscope

  • turn_by_deg(angle) - turns relative to it's current heading. Positive values rotate right and negative rotate left

  • fwd - powers on your robot to drive forward. You'll need to use self.stop() to power off the motors

  • right - by default, self.right() will give the left motor 90% power and the right 0% which rotates right. You can use kwargs to adjust the power such as self.right(primary=90, counter=-90), which will spin the robot in place

  • left - same as right but reversed.

  • back - same as fwd but in reverse.

  • servo - moves the servo (plugged into servo1) to the given value (use 1000 - 2000)

  • stop - sets motor power to zero

  • read_distance - returns the distance from the distance sensor (plugged into I2C port) in millimeters

  • get_heading - returns the gyroscope's value

Shutting down the robot

To shut down your robot, type: sudo shutdown now in the putty window.

Basic Movement Methods

  • Square

  • Dance

  • Add safe_to_dance() method which checks surroundings and only dances if it has enough space.

  • Move to wall and stop

  • Move to wall and turn around. Move forward again and repeat endlessly.

  • Move to box and go around it

  • Before moving around box, figure out which side of closer. If you are closer to the left end of the box, go around left. If you are closer to the right end of the box, go around to the right.

Intermediate Movement Methods

  • Write a move method which scans slightly to the left and right of the robot as it moves forward.

  • If it senses a wall straight ahead, it goes around to the closest side as above (put that move in it's own method)

  • If it senses a wall at the edges of the robot, swerve slightly to miss the wall (this swerve should again be in it's own method).

Maze Navigation

  • Coming soon.

PreviousOLD 5: Replit, GitHub, and repositories (Oh my!)Next7: Kivy

Last updated 3 years ago

Was this helpful?

Visit the and fork it

Use SSH (on Mac) or (on Windows) to connect to your robot. Install PuTTy if it is not on your computer.

If the servo wasn't mounted perfectly, the midpoint won't be 1500. But that's rarely the case. We should adjust this to fit your particular robot.

project
PuTTy
magic number