Hi all, so I am fairly new to the Cortex but have a good experience with IQ, EV3, and am a mobile developer. I want to take my building to the next level and so I thought the Cortex would be the best way to do it. I want to start using the Microsoft Kinect / Lidar with it and looking at what the best solutions are. Both would involve a host (Raspberry Pi or PC) but what’s the best way to exchange data between them? What programming language would you suggest.
I have connected a Android tablet to a Cortex, I know RobotC well (ish) via BT (wiring in one on the Cortex)
I know both the Lidar and Kinect have Python drivers.
Has someone got Python (Host) talking to a Cortex (I guess running RobotC)? I have EDR hardware programming kit
I had my laptop visualize the lidar data in python and then show the robots location and draw large circles everywhere a ball was computed to be. I did all of calculations on board the cortex but with the sheer amount of data coming out of the kinect you will definitely need to do processing on your host machine.
For the python part my partner and I started with this XV-11 python program and then heavily modified it.
Making it work over BT is actually incredibly easy. Your current program should work assuming you change the com port to the port of your computer’s BT chip. The lidar can be read quite easily through UART like you do with your Arduino mega. A ROBOTC program like this to read data in from 1 UART out another is pretty simple. This program was used whenever we wanted to visualize the raw data. A little note is to pay attention to the data != 0xFF because ROBOTC doesn’t have a way of checking the contents of the UART buffer other than grabbing the byte, 0xFF is returned whenever the buffer is empty.
Actually all of code is on github and I would totally be willing to release it if it were not for the just sheer amount of inappropriate jokes and comments through out the code. Just skimming I came across “Added findBalls to find balls deep in the sweaty pants of vex u nerds…” as a commit message.(facepalm) I would be willing to throw all the lidar code into a new repository and add you if you would like.(there is a lot of non lidar code in the current repo and it would just be a mess for you to try to sort through it)
edit: if a mod would like to remove the inappropriate sentence feel free. I know it is at best towing the line.
So the python side doesn’t need to change other than the com port. It’s all just serial. You need to figure out which com port is BT chip and then connect as you would connect any BT device and then start the python program. Not sure how much electrical computer engineering education you have and James(@jpearman) would explain it better but here it goes
USB - universal serial bus
UART - asynchronous serial communication
Serial just means sending all the data over a single transmit data line and a single receive line. The arduino mega has several UART busses and 1 of them is wired to a USB port but has no hardware differences to the other ones. So when you are connected currently it is the same as if you had used a BT chip attached to a different UART and printed using Serial2 or Serial 3. The cortex is the same way except getting the main usb connection is difficult to access so you have to use one of the other UARTs.
The issue is that the official wireless debugging tool has no current way to get the data to an external program. If ROBOTC had a way to send all debug print statements out a virtual com port it would be best. The live debugger sending over all the global variables and motor values makes it hard to try to intercept the data using your own program instead. (no one has ever tried but it could be interesting)
Thanks, I think I know what to do now, I probably did not explain myself correctly but your help is awesome.
I am sure there is plenty out there to show me how to receive BT data in Python. I have done tons of BT on Android etc. I will probably give it a go tonight. Test the Android to -Cortext connection, then rewrite the Android code in Python for the PC. If you ever get time, I would still love to see your project code (jokes and all)