-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMecanumChassis.c
37 lines (32 loc) · 1.8 KB
/
MecanumChassis.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma config(Motor, port2, frontRight, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, frontLeft, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port8, backLeft, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port9, backRight, tmotorServoContinuousRotation, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
Mecanum Drive - Basic with Deadzones by Ada Tessar
(current code just makes the victor 888s sound awful with all the tiny pwm inputs they're trying to
use when the controller isnt being driven)
[I/O Port] [Name] [Type] [Description]
Motor Port 2 frontRight Victor 888 Front Right motor
Motor Port 3 backRight Victor 888 Back Right motor
Motor Port 5 frontLeft Victor 888 Front Left motor
Motor Port 6 backLeft Victor 888 Back Left motor
----------------------------------------------------------------------------------------------------*/
task main()
{
int deadzone = 15; // Define the deadzone threshold
// Loop Forever
while(1 == 1)
{
// Apply deadzone logic
int y = abs(vexRT[Ch3]) > deadzone ? -vexRT[Ch3] : 0; // Forward/backward
int x = abs(vexRT[Ch4]) > deadzone ? vexRT[Ch4] : 0; // Strafing
int rotation = abs(vexRT[Ch1]) > deadzone ? vexRT[Ch1] : 0; // Rotation
// Remote Control Commands
motor[frontRight] = y - rotation - x;
motor[backRight] = y - rotation + x;
motor[frontLeft] = y + rotation + x;
motor[backLeft] = y + rotation - x;
}
}