Skip to content

Commit

Permalink
Updated mkdocs.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNoobInventor committed Aug 28, 2022
1 parent 3c393fe commit 3695508
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 21 deletions.
Empty file modified .github/workflows/main.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .vscode/launch.json
100644 → 100755
Empty file.
Empty file modified .vscode/settings.json
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified docs/images/ev3_segway.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 31 additions & 7 deletions docs/index.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
# Lego EV3 Segway
Using ev3dev OS to self-balance a Lego Mindstorms EV3 robot.
A segway robot is built with the LEGO MINDSTORMS EV3 robot kit and the EV3 Gyroscopic sensor. The self-balancing code is written in Python using EV3 MicroPython: which runs on top of the ev3dev Operating System (OS).

(To be completed)
Give a bit of background about segways here [think this should be the first sentence or paragraph...or?]

## Hardware

### Components
This includes tools and misc like double sided tape

Pictures of some components/sensors
The following components are needed to setup this project:

- LEGO MINDSTORMS EV3 Home Edition #31313
- Gyroscopic Sensor

### Assembly

The Segway robot was built following this [guide](https://robotsquare.com/2014/07/01/tutorial-ev3-self-balancing-robot/).

Actually this guide: https://www.youtube.com/watch?v=Jx9VuX15nqI. The robot square link is broken.

Be mindful that the color of some of the parts might be different. And it doesn't show how to connect the infrared sensor. Try and make it out using this link: https://www.youtube.com/watch?v=-dcGsilEEXQ

or should i decouple this part and show them how to assemble it?

Show better pictures

<p align="center">
<img src=images/ev3_segway.jpg>
</p>

## Software

### Software architecture

Visual Studio Code

Software used

### Software install
how to download and run the code
how to download and run the code [ev3 micropython](https://pybricks.com/ev3-micropython/startinstall.html)

state version of ev3 micropython we are using

## Working principle

Need to heavily reference Gyro Boy. Should I mention it in the intro for main.py as well?

## Video demonstration

Expand All @@ -33,20 +52,25 @@ how to download and run the code
### Channel 2

## Observations
Note about some intermittent errors running the program - what error and how to fix it.
Some intermittent errors running the program - elaborate, possible fix?

Occasional delay when calibrating gyro sensor. Why?

Issue with my remote - code not picking up two or more button presses correctly with repeatability.

Gyro sensor is retired...suggest alternative

Kit from 2016..age an issue?

## Future work/suggestions
Upgrades to channel two:
if an obstacle is in its way, it will have to go back and turn left or right and proceed onto the driving to the beacon

- For beacon channel 3 - moving around randomly (say for 5 seconds) and avoiding obstacles. Make your robot drive around a room while avoiding obstacles with the Infrared Sensor in Proximity mode.

- For beacon channel 4 - actively avoiding objects that come too close.

## References
https://pybricks.github.io/ev3-micropython/examples/gyro_boy.html
- [Gyro Boy](https://pybricks.github.io/ev3-micropython/examples/gyro_boy.html)

- [Ev3dev Micropython](https://www.ev3dev.org/news/2019/04/13/ev3-micropython/)
35 changes: 23 additions & 12 deletions main.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#!/usr/bin/env pybricks-micropython

'''
This program balances the Lego Mindstorms Segway robot built using the LEGO Mindstorms Ev3 home edition and a gyroscopic sensor.
The robot makes use of an infrared sensor and beacon remote to have two control modes:
- to control the robot movement while it is balancing and
- to follow the beacon remote as it is moved around in the range of the infrared sensor, also as the robot is
balancing.
'''

# Import packages
from ucollections import namedtuple
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor, InfraredSensor, GyroSensor
from pybricks.parameters import Port, Color, Button
#from pybricks.parameters import Port, Color, ImageFile, Button
from pybricks.media.ev3dev import SoundFile, ImageFile
from pybricks.tools import wait, StopWatch

Expand All @@ -18,17 +28,17 @@
# Initialize gyro and infrared sensors
gyro_sensor, infrared_sensor = GyroSensor(Port.S2), InfraredSensor(Port.S3)

# Initialize timers, to measure how long loops run for further optimization
single_loop_timer = StopWatch() #
control_loop_timer = StopWatch() #
fall_timer = StopWatch() #
action_timer = StopWatch() #
# Initialize timers
single_loop_timer = StopWatch()
control_loop_timer = StopWatch()
fall_timer = StopWatch()
action_timer = StopWatch()

# Initialize program constants
GYRO_CALIBRATION_LOOP_COUNT = 200 #
GYRO_OFFSET_FACTOR = 0.0005 # obtained from GyroBoy project
TARGET_LOOP_PERIOD = 20 # milliseconds
prev_error = 0 #
GYRO_CALIBRATION_LOOP_COUNT = 200 # Number of iterations for gyro calibration
GYRO_OFFSET_FACTOR = 0.0005 # Gyro offset factor (obtained from GyroBoy project)
TARGET_LOOP_PERIOD = 20 # 20 milliseconds
prev_error = 0 # Initial ... error

"""
# "Robot motion/action definition"
Expand Down Expand Up @@ -232,8 +242,9 @@ def update_action():

# Battery warning for voltage less than 7.5V
battery_voltage = (ev3.battery.voltage())/1000
if battery_voltage < 7.5:
ev3.speaker.play_file(SoundFile.UH_OH)

if battery_voltage < 7.5:
ev3.speaker.play_file(SoundFile.UH_OH)

# Make sure loop time is at least TARGET_LOOP_PERIOD. The output power
# calculation above depends on having a certain amount of time in each loop. What??
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ theme:
name: material
palette:
- scheme: default
primary: teal
primary: indigo
toggle:
icon: material/toggle-switch-off-outline
name: Switch to dark mode
- scheme: slate
primary: teal
primary: indigo
toggle:
icon: material/toggle-switch
name: Switch to light mode
Expand Down

0 comments on commit 3695508

Please sign in to comment.