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.
Controller.h
- Committer:
- oehlemar
- Date:
- 2020-02-24
- Revision:
- 0:7ee4c6416e08
File content as of revision 0:7ee4c6416e08:
/*
* Controller.h
* Copyright (c) 2020, ZHAW
* All rights reserved.
*/
#ifndef CONTROLLER_H_
#define CONTROLLER_H_
#include <cstdlib>
#include <mbed.h>
#include "EncoderCounter.h"
#include "LowpassFilter.h"
/**
* This class implements a controller that regulates the
* speed of the two motors of the ROME2 mobile robot.
*/
class Controller {
public:
Controller(PwmOut& pwmLeft, PwmOut& pwmRight, EncoderCounter& counterLeft, EncoderCounter& counterRight);
virtual ~Controller();
void setDesiredSpeedLeft(float desiredSpeedLeft);
void setDesiredSpeedRight(float desiredSpeedRight);
private:
static const float PERIOD;
static const float COUNTS_PER_TURN;
static const float LOWPASS_FILTER_FREQUENCY;
static const float KN;
static const float KP;
static const float MAX_VOLTAGE;
static const float MIN_DUTY_CYCLE;
static const float MAX_DUTY_CYCLE;
PwmOut& pwmLeft;
PwmOut& pwmRight;
EncoderCounter& counterLeft;
EncoderCounter& counterRight;
short previousValueCounterLeft;
short previousValueCounterRight;
LowpassFilter speedLeftFilter;
LowpassFilter speedRightFilter;
float desiredSpeedLeft;
float desiredSpeedRight;
float actualSpeedLeft;
float actualSpeedRight;
Ticker ticker;
void run();
};
#endif /* CONTROLLER_H_ */