View: 1224|Reply: 2

Controlling RaspTank with PS4 Controller

[Copy link]

1

Threads

3

Posts

15

Credits

Newbie

Rank: 1

Credits
15
Post time 2021-12-19 09:42:34 | Show all posts |Read mode
Has anyone tried modifying the code to control this robot (or any other adeept robots) using a PS4 controller?  I would like to be able to move it around using the controller and then have the video displayed on an Android phone attached to the controller.

I just started taking some python classes through Udemy about 2 months ago, so I'm still a novice.  I have a general idea what I need to do, but have only gotten so far as getting the controller to register button presses using pyPS4Controller.  Any direction past this point would be appreciated.  I'll keep this thread posted if/when I make progress.


Reply

Use magic Report

1

Threads

3

Posts

15

Credits

Newbie

Rank: 1

Credits
15
 Author| Post time 2021-12-20 13:32:10 | Show all posts
This looks promising...

https://github.com/m4n0b0dy/Curiosity
Reply

Use magic Report

0

Threads

2

Posts

14

Credits

Newbie

Rank: 1

Credits
14
Post time 2022-3-1 00:06:36 | Show all posts
Edited by 1646062069 at 2022-3-16 05:06 AM

Modify 3-15-2022.

I got mine to work with the EasySMX PS 3 Game Controller from Amazon (found here: https://www.amazon.com/dp/B01KV7B2CG).  I used AntiMicroX to map the keyboard keys to the various controls and buttons.   I used the left joystick (or Stick 1 in AntiMicroX) for its steering (A and D).  I used the game pad (or DPad) for half of the Arm functions (I, J, K and L).  I used the right joystick (or Stick 2) for the rest of the arm functions (U, O, P and ;).  And finally, I set forward and reverse thrust to the triggers (S or reverse on the left trigger and W or forward on the right trigger).  

Initially I had all of this working on my laptop with the game controller's USB receiver plugged into it.  However I found that the controller stopped controlling the car after it got about 30 feet from my laptop.  I then proceeded to add AntiMicroX to the Raspberry Pi and plugged the controller directly into the Pi itself.  I found that being that as long as the car was within 30 feet of me, it would continue to work.  

To do this, I found that had to learn how to make the Raspberry Pi run headless.  What I did was put two shell scripts into the AutoStart folder (under /home/pi/.config/autostart.  If the autostart folder doesn't exist, you will need to create it) in order to run AutoMicroX and Chromium automatically run upon boot.  Chromium was needed to run the Adeept Bot Controller webpage directly on the Pi.  This worked for both of them.  Being that it was in the folder alphabetically, it ran AutoMicroX first and then Chromium.  This was important because the webpage needs to be in the foreground in order for the controller to work.  

Then I needed a way to properly stop these programs remotely.  If you just switch off the power or perform a shutdown, it can corrupt Chromium.  I found that it kept asking if I wanted to restore the previously viewed webpage.  Whether I clicked restore or cancel it kept popping up.  I couldn't get rid of it.  I googled this to no avail.  The only extreme way around it that I found was to restore the OS and start over from scratch.  Now what I do is use MobaXTerm to remote in from my laptop and pkill both AutoMicroX and Chromium first before running shutdown.  That seemed to do the trick.  No more pop ups!!  There may be a better way to do this, but I also am new to Linux.  I hope this helps!!
Reply

Use magic Report

You have to log in before you can reply Login | Sign Up

Points Rules