Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
src/main_controller.cpp
- Committer:
- dionigi
- Date:
- 2018-11-15
- Revision:
- 1:6f18bb7a77a5
- Child:
- 3:35deb5c21b33
File content as of revision 1:6f18bb7a77a5:
#include <string>
#include "main_controller.h"
#include "pid_controller.h"
MainController::MainController() {
m_pid = new PIDController;
}
MainController::~MainController() {
delete m_pid;
}
/***
* Assignment 3
*
* Implement PID! Most of this work is done in "pid_controller".
***/
void MainController::update() {
// Update PID controller. This is the function you should be
// calling every systick.
m_pid->update();
}
/***
* Assignment 3: Part 1
*
* Get your mouse driving straight.
***/
void MainController::driveStraight() {
/**
* Set an X goal and W goal correctly! This is discussed in the lecture slides.
* For help, see example code: pid/drive-straight.cpp
**/
m_pid->setXGoal(10);
m_pid->setWGoal(0);
pc.printf("Driving straight\n");
}
/***
* Assignment 3: Part 2
*
* Get your mouse to turn, and drive a specific distance.
***/
void MainController::turn(int deg) {
/**
* For help, see example code: pid/turning.cpp
**/
pc.printf("Turning %d degrees\n", deg);
}
void MainController::moveCells(float n) {
/**
* For help, see example code: pid/full.cpp
**/
pc.printf("Moving %d cells\n", n);
}
