RVR: drive_with_gamepad.py

First Iteration

    I am working on a project that will utilize a gamepad to drive the RVR and control certain parts it. So far, I took the drive_with_wasd_keys.py script and modified it to work with PiBorg's Gamepad.py script. I do have issues with serial port flooding during shot turn steering. However, increasing asyncio.sleep from .1 to .125 helped reduced flooding.

    I've also noticed an rc_rvr directory in the SDK, I will make a second iteration of the code using some of the steering portion of that code. Once I get the serial port flooding reduced down to something a little more bearable, I will post the code in GitHub for those who are interested in tinkering with it.

Enjoy the video and let me know what you think!

Update

    There was nothing that I was able to use from the rc_rvr code. However, I was able to fix the turning issue. In fact, it was not serial port flooding. It started flashing yellow and red, therefore, the motor was stalling during a small radius turn or turning from a stand still. This was rectified by adding a value of 5 to speed in the drive_with_heading function whenever turning is greater than zero. The asyncio.sleep was set back to .1, and everything works just fine!!!

    I am planning on mapping each button to certain functions like slow mode, turn headlights on and off, brake lights, turn signals, and battery indicator that flashes all the lights to a color that correlates to the battery life. Alright fellow community members, let me know if any one is interested in instructions and code.

2 Likes

Second Iteration

    I've added conditional statements that turn on both brake lights when current_speed is zero and turn headlights on or off when the "CIRCLE" button is pressed, and one function that reads when the right_paddle_button is depressed and released which adds a "boost mode." That is it for the RVR for now.

    Next, I will create a JavaScript script for a Bolt which will cause it to spin and move to a random spot when it receives a message from the RVR. Wish me luck...

1 Like

That is actually really amazing!! Do you think you could make the joysticks each control one of the treads for full control?

Sorry for the late response. My Java programming class just started, and I was busy working on completing my lab assignments, so I can spend time playing with my RVR.

To answer your question, yes, I can control the tracks separately if I tweak the gamepad scrip to pass y-axis values from both the left and right joysticks to the raw_motors( ) function. The gamepad script is currently passing a y-axis value from the left joystick and an x-axis value from the right joystick to the drive_with_heading( ) function which is then translated to what you see in the video.