What do we want ! That's right MORE CONTROL !!! In this short tutorial I will show you how to get fine and relatively smooth control using the Joystick and Servo services.
Mech-Dickel wanted to use the joystick of a game pad to control the direction and use a button key to start and stop. In this example we are going to control the Y axis of a pan / tilt kit, and use the (1) button for on / off.
Hardware
I am using a wireless Logitech rumble pad 2, a BBB Arduino, and a generic servo.
Software
I have loaded the latest MRLComm.ino into the Arduino and will be using the following MyRobotLab Services:
Rather than MRL (MyRobotLab) sending individual incremental position commands to the servo on where to go, we will tell the servo to move at an incremental speed. When the servo is moving at an incremental speed (<1.0) we have the ability to tell the servo to stop. If we had sent a command to the servo from Python for each position the 57600bps serial speed and the computer's scheduler can make the movement very jittery. Telling the Arduino to start moving and when its moved to the correct position, commanding it to stop is much more effecient and smooth.
Python
[[toSort/Joystick.Servo.fine.control.py]]
Darek asked - where can I find my Joystick Index
You can start a Joystick service and look what gets populated in the dropdown. Every system is different. In my case the rumble pad registers as device 7 - so I can use the 7 programmatically.
Well done!
Hi GroG! Well done work, man! I haven't tried it yet on my project. Now we have all the control on our hands!
Minimum Speed
I know this is just a tutorial for others to learn from and not use exactly but I would suggest that the minimum speed be set to 0.05 or something above 0.0 because a user might get confused when pushing the 1 button and a direction does nothing because they don't realize they mashed the 7 button too much.
Agreed, Changed,
Agreed, Changed, Updated
also, I didn't like the filename - I'm trying to standardize these in some form. They are supposed to start with the "dominant" service.. this was named Python.... but on consideration "Python" is mostly glue to make all the services work together happily. (Also, to implement your suggested change I looked in the repo first for Joystick and couldn't find it ;) filename updated too
A heartfelt thanks to Grog