This commit is contained in:
Arne van Iterson 2023-12-06 23:04:26 +01:00
parent 476c89967e
commit 5e0ee34ed7
3 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,35 @@
# EV5_Modcon # EV5_Modcon
Everything for the EE HU Semester 5 Modelling and Control course Everything for the EE HU Semester 5 Modelling and Control course
![Screenshot](res/screenshot1.png)
# Simulation
The inverted pendulum system has been simulated in Python using pygame.
## Running simulator
1. Open the venv:
```bash
$ ./.venv/Scripts/Activate
```
2. Start the script
```bash
$ python3 ./src/sim/sim.py
```
3. The script can be controlled using the following commands:
| Key | Purpose |
| --------- | --------------------- |
| Esc | Exit |
| Space | Reset simulation |
| P | Pause simulation |
| G | Show debugging graphs |
| C | Toggle PID Control |
| A / Left | Accelerate cart left |
| D / Right | Accelerate cart right |
# Hardware
A robot has been built using LEGO EV3 to show the simulated system in action.
## Connections to EV3 required ## Connections to EV3 required
- Large motor on port B - Large motor on port B
- Large motor on port C - Large motor on port C
@ -12,5 +41,3 @@ Connect either via WiFi, USB or Bluetooth. Do note that connecting via USB or Bl
## Compiling C++ ## Compiling C++
Compiling C or C++ requires a Docker installation of the compiler following (this guide)[https://www.ev3dev.org/docs/tutorials/using-docker-to-cross-compile/] Compiling C or C++ requires a Docker installation of the compiler following (this guide)[https://www.ev3dev.org/docs/tutorials/using-docker-to-cross-compile/]
## Running Python Code
TODO

BIN
res/screenshot1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -50,7 +50,7 @@ class Pendulum:
def update(self, dt): def update(self, dt):
self.doMath(dt) self.doMath(dt)
self.vector = Vector2.from_polar( self.vector = Vector2.from_polar(
((self.length * C_MTPRATIO), math.degrees(self.theta[self.index] + (1.5 * math.pi))) ((self.length * C_MTPRATIO), math.degrees(self.theta[self.index] - (0.5 * math.pi)))
) )
if abs(self.theta[self.index]) == C_FALL_ANG: if abs(self.theta[self.index]) == C_FALL_ANG: