diff --git a/README.MD b/README.MD index 010f0b4..48f718f 100644 --- a/README.MD +++ b/README.MD @@ -1,6 +1,35 @@ # EV5_Modcon 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 - Large motor on port B - 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 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 \ No newline at end of file diff --git a/res/screenshot1.png b/res/screenshot1.png new file mode 100644 index 0000000..9061aa1 Binary files /dev/null and b/res/screenshot1.png differ diff --git a/src/sim/pendulum.py b/src/sim/pendulum.py index deab903..3bb368b 100644 --- a/src/sim/pendulum.py +++ b/src/sim/pendulum.py @@ -50,7 +50,7 @@ class Pendulum: def update(self, dt): self.doMath(dt) 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: