Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
TorqueControlActuatorTest.c
Go to the documentation of this file.
1#include "../Inc/Systems/Controller/TorqueControl.h"
2#include "test.h"
3
4#define MAX_TORQUE 100
5
6#define TORQUE_DO(torque, desired) \
7 TorqueControl tc; \
8 initTorqueControl(&tc, 0, MAX_TORQUE); \
9 setActualTorque(&tc, torque); \
10 setDesiredTorque(&tc, desired); \
11 updateTorqueControl(&tc); \
12 TorqueStatus status = checkTorqueLimits(&tc);
13
15 TEST(torque_init, {
17 initTorqueControl(&tc, 0, 100);
18 ASSERT(tc.status == TORQUE_OK, "status is expected", "status is not expected");
19 })
20
21 TEST(update_normal, {
22 TORQUE_DO(75, 75)
23 ASSERT(tc.status == TORQUE_OK, "status is expected", "status is not expected");
24 })
25
26 TEST(update_below_desired, {
27 TORQUE_DO(93.5, 95)
28 ASSERT(tc.status == TORQUE_OK, "status is expected", "status is not expected");
29 })
30
31 TEST(update_above_desired, {
32 TORQUE_DO(98.5, 95)
33 ASSERT(tc.status == TORQUE_OK, "status is expected", "status is not expected");
34 })
35
36 TEST(update_over_limit, {
37 TORQUE_DO(101, 95)
38 ASSERT(tc.status == TORQUE_OVER_LIMIT, "status is expected", "status is not expected");
39 })
40
41 TEST(update_negative_torque, {
42 TORQUE_DO(-10, 95)
43 ASSERT(tc.status == TORQUE_UNDER_LIMIT, "status is expected", "status is not expected");
44 })
45
46 TEST(update_sensor_error, {
47 TORQUE_DO(10, 80)
48 ASSERT(tc.status == TORQUE_SENSOR_ERROR, "status is expected", "status is not expected");
49 })
50}
#define TORQUE_DO(torque, desired)
void torque_control_main()
@ TORQUE_OK
Definition: TorqueControl.h:10
@ TORQUE_UNDER_LIMIT
Definition: TorqueControl.h:12
@ TORQUE_SENSOR_ERROR
Definition: TorqueControl.h:13
@ TORQUE_OVER_LIMIT
Definition: TorqueControl.h:11
void initTorqueControl(TorqueControl *tc, int hz, float maxTorque)
Initializes the Torque Control Actuator with initial settings.
Definition: TorqueControl.c:4
TorqueStatus status
Definition: TorqueControl.h:21
#define TEST(NAME, BODY)
Definition: test.h:19
#define ASSERT(BOOL, OK, ERR)
Definition: test.h:27