PS4 controller not working in GoPigo3

Oooh!  I did that too. . .

I had this brilliant brainstorm, (probably helped by a bit of (ahem!) “rocket fuel”, or if you’re in Russia, “anti-freeze”), of changing all the class references from “gopigo3_robot” to “gopigo3” throughout my code - to make it easier to read.  :man_facepalming:

The results were, well, “interesting” and I couldn’t figure out why my beautifully working piece of software had suddenly gone all pear-shaped on me.  What was especially interesting was that there were no exceptions or errors or conflicts or whatever thrown at all - things were just as peachy and calm as the weather in the eye of a hurricane.

When I RE-re-named everything to “my_gopigo3”, things were happy again - and it took me a few moments to figure it out.  (Actually more than a “few” moments if I’m going to be perfectly honest.)

What happened is that my “gopigo3” instance was derived from the EasyGoPiGo3 class, which was, (surprise!), derived from the original “gopigo3” base-class.

I don’t know what the computer was thinking I was telling it to do, but it was interesting!

3 Likes

Haha that is fair enough :sweat_smile: I think I could definitely brush up on Python conventions though. Yes that’s true it is me that will be reading my code I will also add comments aswell.

For my project, my supervisor and an assessor will be grading it. From what I’ve gathered, the implementation is worth 20% and my dissertation is worth 70% and presentation 10%. I don’t think they are really strict with the compliance. I’ll be graded on lots of different things like background research, design documentation, and proving that I have created the Autonomous Car. Whereas one of my modules Embedded Systems will mainly be assessing my C++ implementation. I think my coding is still very important of course but I’ll be assessed on other things aswell.

Oh okay that’s great thank you very much! To be honest the library I used PyPS4 in the github page: https://github.com/ArturSpirin/pyPS4Controller it outlines flaws of the package like ‘not all buttons are recognised’ which I did notice that the d-pad wasn’t working at all so I had to use other buttons that were recognised on the PS4 Controller. There is no harm in double checking though definitely! My supervisor also gave me a PS2 Controller to try :laughing:

That is really annoying though about your gamepad. I feel like with mine it has been very temperamental so I definitely will check out that website! I do have 2 PS4 Controllers so if it is to do with one of them at least I have a backup.

Yes exactly, to be honest i have tested it now and it is working fine but I can always double check my controller and ensure some of the buttons that aren’t registering actually work.

Haha thank you!!!

2 Likes

Remind me what “Autonomous Car” means with respect to this project.

  • Drive from one side of the room to another without catching fire?
  • Drive to the refrigerator and bring back a cold beer?
    https://spectrum.ieee.org/gamma-two-robot-fetches-you-a-beer
  • Drive outside and walk the dog?
  • Drive downtown and buy groceries?
  • Drive itself to your professor’s office and drop off your dissertation?
    (and bring him a beer too? :wink:)

Also remind me, what connection interface are you using?  I don’t know what “ds4drv” is, (Sony PlayStation Dual-Shock 4 - whatever that is), but it sound like poison to me - at least with regard to this gamepad.

Is a wireless gamepad connection required?  In my case, I have my gamepad/joystick connected to my computer via USB so I avoid all the wireless issues.

The way my robot works is that the core functionality is on the robot itself, which connects to my household network via WiFi, and I connect to the robot via a web browser, (a whole different set of problems!), and use my “big” Saitek X52 joystick to drive it around.  Theoretically, (:smirk:), any computer with access to my network, (and another Saitek joystick!) could connect to my robot and drive it around.

I did not implement any kind of Bluetooth control just to avoid the issues that using a wireless gamepad would produce.

Another question:
What is the definition of “success”?  Does it have to drive across the room?  Drive across the room and avoid obstacles like the Professor’s cat?  Or maybe drive across the room, avoid the cat, and bring back fresh cat-treats?

3 Likes

Haha if my car could drop my dissertation off at my supervisors office and then fetch me a gin after that would be great :joy:

The connection interface I am using is ds4drv and is via Bluetooth I watched a YouTube video on the PyPS4 library and the guy who created this library shown how he used it by connecting the controller via Bluetooth using this interface so I assumed I needed to do that. It isn’t always reliable sometimes the controller connects better the closer it is to my car but it always says on the terminal that the ‘signal is very low’.

A wireless controller isn’t required I can use any. My supervisor gave me a wired ps2 pad but he said I can use any. It is only so that I can control the car to drive around a track and collect data from the track.

The main objective for the project is for the Autonomous Car to follow a track. For the track I am just using white A4 paper. I have implemented the rpi camera using OpenCV for image processing and colour detection.

Another feature I need to implement is obstacle detection so when there are objects near the car in front or behind the car will stop. I will implement this part after lane detection. My supervisor told me that a student last year implemented these 2 and got 85%/100.

Optionally and if I have time, I want to implement traffic light detection. So when the light is green the car will go and if the light is red the car will stop. I will have to see though because I’m not too sure if I will have time to do this and it isn’t required for the project but it is something I’d like to do!

Definition of success:

  • Car can drive around a track and identify curves and patterns

  • Car can detect objects, obstacles/avoid collisions

  • Car can detect traffic lights

3 Likes

I’m going to invite @superbam to join us as he’s already done this.

You may want to go check out his thread, he was doing the exact same thing except that he was doing lane detection.

Viz.:

There’s a lot of good information there that may well be useful to you.

3 Likes

I’m doing lane detection in my project aswell. Thank you I will have a look at the thread! :grin:

3 Likes

I don’t know how much of “his work” you can use without getting in trouble for plagiarism, but hopefully this will give you ideas.

Maybe you can/should cite his efforts as a research source?

Side Note:

My how times have changed!  I remember during my freshman year at Virginia Tech, my big (independent) project was wiring up a boot loader circuit that took the place of a stack of punched cards and was used to make a GE-4020 mainframe self-booting.

Today’s projects?
Self driving cars that can avoid obstacles, find the liquor store, know the best sources for weed, and find you a hot date!

Sheesh!

3 Likes

Well, if you use A4 paper as your track, I would recommend you this youtube series:

To track obstacles, you could use a haar cascade, but it’s not very reliable… But I am pretty sure, there are a lot of projects on github that let you detect the state of traffic lights

3 Likes

I’ll have a look at the thread but I wouldn’t copy anything. Yes definitely it will give me ideas for how I’d like to approach mine.

Wow that sounds interesting! I’m only just working with circuits this semester I do enjoy it. For mine I have to make an environmental home monitoring system that monitors temperature, humidity and other things in C++.

Haha yes there is quite a difference :joy:

2 Likes

Oh okay I’ll have a look at that YouTube series thank you!

3 Likes