So just for fun I’m trying to use my hand as a controller for our swerve drive, I already have a code in python wich reads correctly the angle of my hand, but know i want to know what can I do so I log these data to the driver station so it recognizes it as a Joystick, thank you so muchin advance
Rather than submitting the data as a joystick, you may find it easier for your program to send data to the robot via NetworkTables. Then, on the roboRio side, you would read those values and pass them on to your swerve code.
I haven’t done it myself before, but I believe there is a Python version of the NetworkTables libraries available here:
This sounds like a really fun project. I’m sure the community would love to see a video of it in action when you get it working!
Building off what @SndMndBdy said: You will want to build your drive commands such that they can take in any function (suppliers for java users) that they can pull values from. This way, you can either choose to pass in a function that polls the joystick, or a function that polls for your hand movement.
This practice is known as decoupling, which makes it so one part of your program (your drivetrain) can exist separately from other parts (your joysticks). It makes creating modular code significantly easier and prevents future headaches.
Example (In python):
def mult_2(x):
return 2*x
def power_2(x):
return x**2
def apply_function(num, function):
return function(num)
#Use the mult_2 function to multiple 10 by 2
print(apply_function(10, mult_2))
#Use the power_2 function to raise 10 to the 2nd power
print(apply_function(10, power_2))
IF you want to use this at a competition, be careful about the rules for touching controllers during auton. As far as I can tell, it is ruled thay anything that connects to the driver station is a controller and you can’t touch it during auto.
Yeppp suree, remember that in about 2012 teams used kinect to controll their robots during auto, but now this is banned from the rules. Right now I’m doing this just for fun, either way, thanks for the reminder