PS3/PS4 Kontroller für unseren Ardumower mit CC

Hallo Zusammen,

heute wollte ich mal meine fortschritte bezüglich der Anbindung meines PS3 Controller teilen.

Zur Zeit arbeite ich mit einen Zero W mit USB HUB HAT
https://www.amazon.de/Waveshare-USB...4747&sr=1-2-catcorr&keywords=zero+USB+HUB+HAT
diesen benutze ich für das CC zur Kommunikation mit dem DUE und mit einem Seriell Konverter für meinen Kartenleser (HZ-1050 rfid Modul) zum tracken an der Schleife.

https://www.amazon.de/gp/product/B072K3Z3TL/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1 https://www.amazon.de/UIOTEC-HZ-105...1546775567&sr=8-2&keywords=HZ-1050+rfid+Modul
das lauft alles super mit node-RED die Tags werden erfasst und das CC führt eine Aktion aus! (zB dreh nach rechts für 1sec dann fahre geradeaus für 3sec und suche dann die schleife zur Home fahrt als Abkürzung!)
das läuft schon alles gut dem mini !

jetzt wollte ich noch unseren alten PS3 Controller kompatibel machen.
Dazu habe ich das Pairing nach dieser Anleitung durchgeführt, allerdings mit der OnBoard BT-Schnittstelle.
https://custom-build-robots.com/ras...-einrichten-am-raspberry-pi-mit-raspbian/9909
dazu brauchte mein Zero noch die sudo apt-get install Joystick um jstest /dev/input/js0 ausführen zu können.

Dann habe ich im node-RED im exec Modul den jstest /dev/input/js0 ausgeführt und schwupp sind die Joystick daten im node-RED.

Hier mein Test Flow:

[{"id":"fba36ee3.60da6","type":"tab","label":"Flow 1"},{"id":"b68e7b83.4f8f58","type":"inject","z":"fba36ee3.60da6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":194.5,"y":59,"wires":[["ac984cbb.dab8e"]]},{"id":"41462ba1.935a94","type":"debug","z":"fba36ee3.60da6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":910.5,"y":198,"wires":[]},{"id":"ac984cbb.dab8e","type":"exec","z":"fba36ee3.60da6","command":"jstest /dev/input/js0","addpay":false,"append":"","useSpawn":"true","timer":"","oldrc":false,"name":"","x":178.5,"y":171.5,"wires":[["74257b01.8ba1f4"],["d4eec49f.794b18"],[]]},{"id":"74257b01.8ba1f4","type":"function","z":"fba36ee3.60da6","name":"js","func":"var jsbegin = msg.payload.toString().search("");nnif (jsbegin == -1){n n}nelse{n n var output = msg.payload.split(":");nnaxesY = {payload:parseInt(output[2])};nnreturn [axesY];nnn}n","outputs":1,"noerr":0,"x":437,"y":94,"wires":[["750147d7.cd3088"]]},{"id":"750147d7.cd3088","type":"range","z":"fba36ee3.60da6","minin":"-32767","maxin":"32767","minout":"-25","maxout":"25","action":"scale","round":true,"property":"payload","name":"","x":620.5,"y":95,"wires":[["41462ba1.935a94"]]},{"id":"d4eec49f.794b18","type":"debug","z":"fba36ee3.60da6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":172.5,"y":308,"wires":[]}]

So jetzt zu meinen Problem:

Sollte ich versuchen die payload Ausgabe für meine Axes zu trennen/splitten oder so?
oder macht es mehr sinn mit python Code wie zB der von diddyborg anzupassen so das man direkt das richtige Format hat.
https://www.piborg.org/blog/build/diddyborg-v2-build/diddyborg-v2-examples-joystick-control
einen python Code kann man auch wunderbar mit node-RED ausgeben, über node-red-contrib-pythonshell
https://flows.nodered.org/node/node-red-contrib-pythonshell
naja jetzt wird es allerdings für mich zu kompiliert mit der Anpassung des payload
da hoffe ich auf Unterstützung von euch.
 
Hi Oli.
I have some trouble to understand all your post with Google translate but if i understand :
You can manage the RFID with a correct distance and speed reading.
I never test your module but can you confirm this before i order one.
The mower can read the tag at tracking speed 0.4m/s or little less.
The distance between the tag on ground and antenna is > 7 CM
Can you make a small video or picture on how you put the coil on the mower ?

For the PS3 or 4 remote i use PS4 on my Python code and it's work like a charm.
If you want i can send you the Python class i use but i never work with Node Red (Is the speed is real time or really slow)
https://www.youtube.com/watch?v=w3pxaZgwgJk
 
Hi Bernard,

dein python Code würde mich schon sehr Interessieren.
Ich würde versuchen diesen in mein node-RED einzubinden, wir werden dann sehen ob das ganze dann schnell genug ist, eventuell würde ich noch auf den PI A+ umbauen da der so schnell wie der PI B+ ist, nur mit halb soviel Speicher.

Grüße der Olli
 
Hi.
Here the 2 pythons files
One test and the class
Put the 2 files in the same directory on your Pi and start idle3, load the PS4test.py and run it (in the debug windows you need to see what you click on the joystick)

I assume pygame is installed on the Pi.
The Joystick need to be pair with the PI in BT using Share and PS at the same time
Attachment: https://forum.ardumower.de/data/media/kunena/attachments/3545/joystick.zip/
 
Zuletzt bearbeitet von einem Moderator:
Ich brauche da jetzt echt hilfe:

Für die Controllersteuerung würde ich gerne den payload:

Axes: 0: 1013 1: 32767 2:-32767 3: 0 4: 0 5:-32767 Buttons: 0:eek:ff 1:eek:ff 2:eek:ff 3:eek:ff 4:eek:ff 5:eek:ff 6:eek:ff 7:eek:ff 8:eek:ff 9:eek:ff 10:eek:ff 11:eek:ff 12:eek:ff 13:eek:ff 14:eek:ff 15:eek:ff 16:eek:ff

Splitten.

Für meine Steuerung brauchte ich nur die werte von Axes 1: xxxxx und Axes 3: xxxxx die Buttons sollen später auch aber ich will erstmal sehen ob ich hiermit auf dem richtigen weg bin ?

oder ob das echt alles über Python laufen muss, denn da wäre ich halt raus!
 
never test your module but can you confirm this before i order one.
The mower can read the tag at tracking speed 0.4m/s or little less.
The distance between the tag on ground and antenna is > 7 CM


Did you make test of your 1050 RFID module inside the mower or only on table ?
 
So ich wieder,

der PS3 Controller läuft recht zufriedenstellend mit meinen Mini,
die einen oder andern Probleme muss ich allerdings noch lösen.
Die Programmierung über node-Red hat sich doch einfacher als gedacht gestaltet.
Ein paar Anpassungen werde ich allerdings noch vornehmen.

Hier mal mein Flow zum selber rumspielen:

[{"id":"9ef997be.494f38","type":"tab","label":"Flow 1"},{"id":"e07f04db.9ace28","type":"inject","z":"9ef997be.494f38","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":117.78573608398437,"y":225.14285278320312,"wires":[["d20eb958.34eed8"]]},{"id":"471d0d9c.ad9644","type":"debug","z":"9ef997be.494f38","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1679.0474853515625,"y":359.043701171875,"wires":[]},{"id":"d20eb958.34eed8","type":"exec","z":"9ef997be.494f38","command":"jstest /dev/input/js0","addpay":false,"append":"","useSpawn":"true","timer":"","oldrc":false,"name":"","x":154,"y":300,"wires":[["d9d15bf8.da9308","5e8d42b6.03f1ac"],["bdec00f4.e7ae5"],[]]},{"id":"ef40d.29408bf4","type":"debug","z":"9ef997be.494f38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":188.49996948242187,"y":447.25,"wires":[]},{"id":"7bf27ed4.c5436","type":"inject","z":"9ef997be.494f38","name":"$RMMOV,0,99,99,0,0,0 (max speed)","topic":"","payload":"$RMMOV,0,99,99,0,0,0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":227.75,"y":647.0000610351562,"wires":[["a0b5b531.11d608"]]},{"id":"80b4c920.b54d28","type":"serial out","z":"9ef997be.494f38","name":"","serial":"f4409ac2.4ad268","x":1682.1746826171875,"y":440.42071533203125,"wires":[]},{"id":"a0b5b531.11d608","type":"function","z":"9ef997be.494f38","name":"add Enter \n","func":"msg.payload = msg.payload + "\n";nreturn msg;","outputs":1,"noerr":0,"x":522.25,"y":646.0000610351562,"wires":[["80b4c920.b54d28"]]},{"id":"d4445bbb.a1e2a8","type":"inject","z":"9ef997be.494f38","name":"$RMMOW,0 (OFF)","topic":"","payload":"$RMMOW,0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":277.75,"y":599.0000610351562,"wires":[["a0b5b531.11d608"]]},{"id":"76a19830.c3d4b8","type":"inject","z":"9ef997be.494f38","name":"$RMMOW,2 (HOME)","topic":"","payload":"$RMMOW,2","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270.25,"y":690.0000610351562,"wires":[["a0b5b531.11d608"]]},{"id":"d9d15bf8.da9308","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":"Axes: "}]},{"name":"delRightMost","params":[{"type":"str","value":"Buttons: "}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":528.6031494140625,"y":200.44744873046875,"wires":[["8cb6fe4f.132e3","ab53d1bb.c6049"]]},{"id":"8cb6fe4f.132e3","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":"1:"}]},{"name":"delRightMost","params":[{"type":"str","value":"2:"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":668.7380981445312,"y":173.3491973876953,"wires":[["d6e1bbb4.845118"]]},{"id":"ab53d1bb.c6049","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":"3:"}]},{"name":"delRightMost","params":[{"type":"str","value":"4:"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":672.3015747070312,"y":229.17454528808594,"wires":[["927c510d.d25cd"]]},{"id":"d6e1bbb4.845118","type":"range","z":"9ef997be.494f38","minin":"-32767","maxin":"32767","minout":"99","maxout":"-99","action":"scale","round":true,"property":"payload","name":"","x":805.4048461914062,"y":172.68252563476562,"wires":[["4b4fdf26.a7334"]]},{"id":"4e15f0d5.3913e","type":"function","z":"9ef997be.494f38","name":"calculate motor speed","func":"var speed = 0;nvar steer = 0;nnspeed = flow.get("speed");nsteer = flow.get("steer");nnif ((speed > 50) || (speed < -50)){ntsteer = steer;nt}else{ntsteer = steer /2;n }nnif ((speed === 0) & (steer > 0)){ntvar speed_left = -steer *2;ntvar speed_right = steer *2;nt}else{ntif ((speed === 0) & (steer < 0)){nttvar speed_left = steer *2;nttvar speed_right = -steer *2;ntt}nt}nnnif (steer === 0){ntvar speed_left = speed;ntvar speed_right = speed;nt}nelse{ntif (speed > 0){nttif (steer > 0){ntttvar speed_left = speed;ntttvar speed_right = speed - steer;nttt}else{ntttvar speed_left = speed + steer;ntttvar speed_right = speed; nttt}ntt}else{ntif (steer < 0){ntttvar speed_left = speed - steer;ntttvar speed_right = speed;nttt}else{ntttvar speed_left = speed;ntttvar speed_right = speed + steer;nttt}ntt}nt}nnvar command = "$RMMOV,0,"+parseInt(speed_left)+","+ parseInt(speed_right)+",0,0,0\n";nnmsg.payload = command;nnreturn msg;n","outputs":1,"noerr":0,"x":1641.43701171875,"y":254.36495971679687,"wires":[["80b4c920.b54d28","471d0d9c.ad9644"]]},{"id":"927c510d.d25cd","type":"range","z":"9ef997be.494f38","minin":"-32767","maxin":"32767","minout":"-50","maxout":"50","action":"scale","round":true,"property":"payload","name":"","x":804.8572387695312,"y":229.84120178222656,"wires":[["b4751504.f9e428"]]},{"id":"b87dcaa7.d81bd8","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"speed","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1312.2385864257812,"y":149.36483764648437,"wires":[["59d37289.be331c"]]},{"id":"b4751504.f9e428","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"steer","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1323.04833984375,"y":235.87289428710937,"wires":[["59d37289.be331c"]]},{"id":"4b4fdf26.a7334","type":"switch","z":"9ef997be.494f38","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"-10","vt":"num","v2":"10","v2t":"num"},{"t":"lt","v":"10","vt":"num"},{"t":"gt","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":939.5714721679687,"y":172.57141876220703,"wires":[["195da263.23782e"],["b87dcaa7.d81bd8"],["b87dcaa7.d81bd8"]]},{"id":"195da263.23782e","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120.2144775390625,"y":142.8571319580078,"wires":[["b87dcaa7.d81bd8"]]},{"id":"5e8d42b6.03f1ac","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":"Buttons: "}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":521.4285888671875,"y":507.142822265625,"wires":[["52f74a44.0c97a4","523ff49d.aba55c","cb41fb87.b46268"]]},{"id":"52f74a44.0c97a4","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":" 0:"}]},{"name":"delRightMost","params":[{"type":"str","value":" 1:"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":675.71435546875,"y":478.5712585449219,"wires":[["41fd61bf.8360e"]]},{"id":"523ff49d.aba55c","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":" 1:"}]},{"name":"delRightMost","params":[{"type":"str","value":" 2:"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":678.5714111328125,"y":549.9998168945312,"wires":[[]]},{"id":"41fd61bf.8360e","type":"switch","z":"9ef997be.494f38","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on ","vt":"str"},{"t":"eq","v":"off ","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":814.9999389648437,"y":478.5713195800781,"wires":[["7a7379e4.3df388"],["526ae475.e9497c"]]},{"id":"7a7379e4.3df388","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":985.000026157924,"y":459.99986485072543,"wires":[[]]},{"id":"526ae475.e9497c","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":985.7142944335937,"y":501.4284973144531,"wires":[[]]},{"id":"cb41fb87.b46268","type":"string","z":"9ef997be.494f38","name":"","methods":[{"name":"delLeftMost","params":[{"type":"str","value":" 5:"}]},{"name":"delRightMost","params":[{"type":"str","value":" 6:"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":674.285888671875,"y":300,"wires":[["b4623b93.3c3748"]]},{"id":"b4623b93.3c3748","type":"switch","z":"9ef997be.494f38","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on ","vt":"str"},{"t":"eq","v":"off ","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":807.857177734375,"y":300,"wires":[["b1fbcec7.db207"],["b042eb94.581d98"]]},{"id":"b1fbcec7.db207","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"50","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980.7144775390625,"y":277.1428527832031,"wires":[["b87dcaa7.d81bd8"]]},{"id":"b042eb94.581d98","type":"change","z":"9ef997be.494f38","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980.000244140625,"y":321.4286804199219,"wires":[[]]},{"id":"59d37289.be331c","type":"trigger","z":"9ef997be.494f38","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"500","extend":false,"units":"ms","reset":"","bytopic":"all","name":"send each 500ms","x":1627,"y":172,"wires":[["4e15f0d5.3913e"]]},{"id":"bdec00f4.e7ae5","type":"switch","z":"9ef997be.494f38","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"jstest: No such file or directory","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":189.5,"y":386,"wires":[["ef40d.29408bf4"]]},{"id":"f4409ac2.4ad268","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"\n","bin":"false","out":"char","addchar":true}]

node-red-contrib-string habe ich noch eingebunden somit war es für mich als Elektriker einfacher die Strings zu teilen.

oben bei der Einrichtung der Controllers ist mir ein Fehler unterlaufen es muss heißen : sudo apt-get install joystick

allerdings habe ich mir auch folgenden Joystick bestellt:
https://www.pollin.de/p/joy-it-wireless-gamepad-fuer-arduino-incl-empfaenger-810905
werde die Tage den mal ausprobieren.
 
Bernard schrieb:
never test your module but can you confirm this before i order one.
The mower can read the tag at tracking speed 0.4m/s or little less.
The distance between the tag on ground and antenna is > 7 CM


Did you make test of your 1050 RFID module inside the mower or only on table ?

Ja habe ich getestet mit meinen Mini, er ist zu langsam!!!

Ich habe mir ein paar andere Leser bestellt um es besser testen zu können:
Heute kam der Neuftech USB RFID Reader:

Der liest bis 8cm und sehr schnell! An meinen Mini getestet und es wurde kein Tag übersehen !
Der lässt sich auch ins Node-Red einbinden! (allerdings nicht auf einen Zero)

Es kommen noch die beiden :
https://www.amazon.de/gp/product/B07MC1T3LP/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1 https://www.amazon.de/gp/product/B07H3GBDF6/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1
welcher es nachher der richtige ist bleibt offen.
Ich bleib da am Ball denn die Steuerung über die Chip möchte ich schon realisieren, das ganze am liebsten mit Node-Red!

Gruß der Olli
 
Zuletzt bearbeitet von einem Moderator:
Zuletzt bearbeitet von einem Moderator:
hier nochmal die BT Anbindung PI mit PS3 Controller:

Unseren alten PS3 Controller kompatibel machen.
Dazu habe ich das Pairing nach dieser Anleitung durchgeführt, allerdings mit der OnBoard BT-Schnittstelle.

custom-build-robots.com/raspberry-pi-ele...pi-mit-raspbian/9909

dazu brauchte mein PI noch die sudo apt-get install Joystick um jstest /dev/input/js0 ausführen zu können.

Dann habe ich im node-RED im exec Modul den jstest /dev/input/js0 ausgeführt und schwupp sind die Joystick daten im node-RED.
 
Oben