Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
ControllerSystem.h
Go to the documentation of this file.
1#ifndef RENSSELAERMOTORSPORT_CONTROLLER_SYSTEM_H
2#define RENSSELAERMOTORSPORT_CONTROLLER_SYSTEM_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7
8#include "System.h"
9#include "MonitorSystem.h"
10#include "../Utils/Constants.h"
11#include "../Utils/Updateable.h"
12#include "../Scheduler/Task.h"
13
14typedef enum {
18 c_RTD
20
21typedef enum {
26
27// Need to do this because of circular dependency
33 MonitorSystem* monitors[MAX_MONITORS]; // What monitors are associated with this controller?
35 int (*safety)(struct ControllerSystem* controller); // Check if the controller is operating safely
36 int (*addMonitor)(struct ControllerSystem* controller, MonitorSystem* monitor); // Add a monitor to the controller
37 int (*removeMonitor)(struct ControllerSystem* controller, MonitorSystem* monitor); // Remove a monitor from the controller
38 int (*updateController)(struct ControllerSystem* controller); // Update the controller
39 void* child;
40};
41
51void initControllerSystem(ControllerSystem* controller, const char* name, int hz,
53 void* child);
54
62int c_defaultAddMonitor(ControllerSystem* controller, MonitorSystem* monitor);
63
72
79int c_defaultUpdate(Updateable* updateable);
80
87int c_defaultSafety(ControllerSystem* controller);
88
89#endif // RENSSELAERMOTORSPORT_CONTROLLER_SYSTEM_H
90
#define MAX_MONITORS
Definition: Constants.h:21
int c_defaultRemoveMonitor(ControllerSystem *controller, MonitorSystem *monitor)
Removes a monitor from the controller.
void initControllerSystem(ControllerSystem *controller, const char *name, int hz, ControllerType type, int(*updateController)(ControllerSystem *controller), void *child)
Initializes the Controller System with initial settings.
int c_defaultAddMonitor(ControllerSystem *controller, MonitorSystem *monitor)
Adds a monitor to the controller.
ControllerType
@ c_TORQUE
@ c_BRAKES
@ c_APPS
@ c_RTD
int c_defaultUpdate(Updateable *updateable)
Default update function for ControllerSystem objects.
ControllerState
@ c_idle
@ c_computed
@ c_validated
int c_defaultSafety(ControllerSystem *controller)
Default safety function for ControllerSystem objects.
MonitorSystem * monitors[MAX_MONITORS]
int(* addMonitor)(struct ControllerSystem *controller, MonitorSystem *monitor)
int(* safety)(struct ControllerSystem *controller)
int(* updateController)(struct ControllerSystem *controller)
int(* removeMonitor)(struct ControllerSystem *controller, MonitorSystem *monitor)
ControllerType type
ControllerState state
Definition: System.h:17