PDA

View Full Version : PhantomX / ArbotiX read String from Unity



MeisterEder
02-02-2017, 08:21 AM
Hi all,

hope I'm in the correct section. We have mounted a camera on the turret which is capable of face recognition. We want to implement that the camera turret follows a user's face automatically (e.g. when the face of the user is not in the middle of the camera, turn the turret...). So in theory that's relatively simple.
We send data with Unity to the serial port and read it with the ArbotiX. The problem is, that we want to send strings. There's a function for Arduino Uno for example called readStringUntil() which we want to use, it's not available for ArbotiX though. Why? We have a workaround with parseInt() but that is too slow and cumbersome for our purposes.
Does anybody know a way to read a string from the serial port so we can send fast commands with Unity? Any help is greatly appreciated!

Best regards

tician
02-02-2017, 01:38 PM
The arbotix originally used customized UART code because of performance issues with the standard core's HardwareSerial from several years ago. Those issues have since been resolved, but the arbotix library still uses an old copy of the arduino avr core (the original developer is not active on the forum, and works on much more expensive robots and components). Since the arbotix is based on the Sanguino, which is an AVR arduino board, it should be directly compatible with any newer arduino core as long as the boards, platform, and variant files are up-to-date. I do not have the hardware to test, but replacing the contents of '/hardware/arbotix/avr/cores/arbotix/' with the contents of '/hardware/arduino/avr/cores/arduino/' to use the functions of the newer core, but some of the arbotix custom non-dynamixel libraries might have issues.

jwatte
02-02-2017, 02:46 PM
You can easily reimplement something like "readStringUntil()" yourself.
Just keep reading bytes into a buffer until you get the correct end byte or run out of buffer space.

KurtEck
02-02-2017, 06:20 PM
Or you can convert to use the latest versions of Arduino... Been several threads on this. I personally no longer look at any of the Arduino 1.0.x stuff anymore... I have had the stuff running on Arduino 1.5.x and 1.6.x and now 1.8.x for several years now.

Trossen was in the process of officially converting, but I believe the person doing it is no longer there. More about the steps to do this can be found in the thread: http://forums.trossenrobotics.com/showthread.php?7971-ArbotiX-1-6-Files-Libraries

Note: Current Arduino release is 1.8.1, which is find to use the 1.6.x stuff. They went to 1.8 as arduino.cc is now working again with arduino.org (who had 1.7.x releases) and so they numbered next release as 1.8.x...

Again hopefully someone at Trossen will take this up again

MeisterEder
02-03-2017, 07:03 AM
Thank you all for your answers, all are helpful! We actually got parseInt() to run much faster today but we will look at all of your suggestions. Have a good day and thanks again!