Hi everyone,
Could anyone tell me if ROBOTC supports Inter-process Communication? If not, could you point me to something that does? I’m currently working on a project that has an Xbox Kinect controlling a VEX robot and I need to use IPC to send values to the robot.
Thanks.
Can you expand a bit more on what you would like to do. IPC can means many things, if you are looking for something based on UDP or TCP then that’s not possible via VEXnet. The cortex does have serial ports available and, assuming this is not a competition robot, that’s probably your best bet. If it needs to be wireless then perhaps something like this would work.
https://www.sparkfun.com/products/10822
My project is to have a Kinect track a human arm and send its coordinates to a VEX PIC. The PIC will move a robotic arm to follow the human one. I was thinking I needed something like socket programming for sending and receiving coordinates.
Basically I’m trying to pass Kinect HID values for joystick HID values. Does that make any more sense?
So is the Kinect plugged into a PC? As I said before, you have no access to the WiFi with the cortex (or PIC with VEXnet connection kit). If you really want to use TCP or UDP communication then perhaps the VEXpro ARM9 controller would be the way to go, it has the capability you want as it runs a flavor of linux.
Alternatively perhaps another WiFi link with a serial interface would work, something like ZigBee or one of the roving network modules.
If you had the cortex perhaps there is a way of using USB via an adapter into the partner port of the joystick, something like this.
Sounds like and interesting project. I’m assuming the your use of HID means Human Input Device? and given your description of using the Kinect as an input device and PIC as robot Arm controller I’m assuming the Kinect is connected to a PC and you are using a package such as processing to get the human skeleton coordinates? and now you are thinking through how to get that data to the PIC?
Are you restricted to the PIC as the robot controller? or as James asked do you have access to other devices?
The Vex system Cortex and PIC are built to primarily support a teleoperated mode using the Hobby RF joysticks in the case of the PIC and the WiFi gamepad in the case of the Cortex. fortunately both devices have serial ports which can provide an alternative method of I/O to the device and using Xbee or roving networks modules would allow you to utilize the serial port on the PIC/CORTEX to provide a serial port based control and status interface. If you don’t need wireless connectivity you could use a prolific USB to Serial port adapter to connect from the PC (with the Kinect) directly to the serial port on the robot controller. You will still need to write serial port interface code for either the PIC or Cortex to send and (optionally receive) data to the robot.
I’ve some experimenting with serial port based communications between Cortex and Arduino based upon the multi robot project here:
http://www.robotc.net/firewiki/index.php?title=Main_Page
I’ve had help from James on the bit banging (serial interface) and data structure definition to facilitate sending binary data structures over a serial port (which the Xbee then transmitted wirelessly) But if you don’t need wireless could be accomplished with a hardwired serial port interface.
Unfortunately I don’t work on the project enough I don’t have a really good framework, but I have been able to send and display data between the 2 platforms.
Let us know if this is what your heading towards.
Cheer Kb
Thanks so much for the help so far! Just to make clear, there will be no wireless involved. My idea is to have a Kinect and the PIC connected to one computer. I will be using the serial port on the PIC to send values to it. Unfortunately, the PIC is all I have to work with right now, but I may be able to get a hold of a Cortex soonish.
As far as having the two programs communicate, I don’t have to use a TCP/UDP structure. I should use whatever is the easiest and most capable. I am just unsure as to what that may be.
Well I did some experiments with the Kinect early this year, but haven’t played with it for a while, using the book ‘making things see’ which was a great read and set of examples to access the data from the Kinect. I see there is a serial library for processing here:
you can get USB to serial port adaptors pretty inexpensively (here’s an example)
http://www.mcmelectronics.com/product/ADAFRUIT-INDUSTRIES-954-/83-14392
so I think Serial port com is your best bet to PIC, with Cortex you can use one of the 2 exposed UARTS or something like this :[https://vexforum.com/showpost.php?p=319321&postcount=125, but I think the external serial ports would be the best choice.
I haven’t tried with a PIC yet maybe I’ll have some time next week. I am planning to have 2 robots working in some coordinated fashion. I have a Cortex & a PIC to play with. right now. If I get the code I wrote for the Cortex to work on the PIC I could post it as an example.
Cheers Kb](https://vexforum.com/showpost.php?p=319321&postcount=125, but I think the external serial ports would be the best choice.)
Okay, so I have it mostly figured out. I have my C# Kinect program sending values through a virtual serial port(COM1), which seems to be the solution. However, I can get my RobotC program to receive any information. I’m trying to use configureSerialPort() and getChar(), but I can’t get anything to come throw. The Kinect program is sending data just fine. I just don’t know how to get the RobotC program to open a COM serial port to get sent data.
Any suggestions?
Well it’s really hard to give any specific advice since I have no idea how you’ve connected the two devices. Are you using a prolific USB to serial adapter? if not what is the nature of the serial port connection to the PIC? are both devices set tot he same Baud rate? Have you verified the PC device is really putting bits on the wire? Did you hook it to the PIC serial port correctly? Tx from the PC to RX of the PIC? How familiar are you with serial ports? Are the logic levels matched correctly (12v vs 5 v vs 3.3v)? There’s really a lot that can go wrong so you may need to break it down piece by piece and ensure each piece is working.
The ‘seed’ code I used for serial comms on the cortex is here:
http://www.robotc.net/firewiki/index.php?title=Main_Page#Downloads
This site had a ton of good description on how to get robot to robot communication working. The drivers for the cortex are called: Multi-Robot Library File for NXT/Cortex (XbeeTools.h) : I have not tried it on a PIC yet.
In my case I was using XBee devices to provide the serial ‘connection’ so I started working from the pc side towards the robot (Cortex in my case). After configuring the Xbee’s and ensuring they worked by using the Tera Term terminal emulator I proceeded to hook up an XBee to the cortex. after much frustration and trying all common baud rates I found they would only work on the Cortex at 115200 baud. I don’t know if that is a true constraint but once I set the baud on both devices to 115200 I could get Ascii data transferred to the cortex. From there I had to learn a lot to get a binary data compatible transfer setup going, but I did eventually get a reasonably reliable link going 1/sec bi directional. I’ve got more to work on a lot more but having no deadline my project suffers from a lower priority.
The other thing I worked very methodically on was sending data from the Cortex back to the (arduino in my case) device. I now can send messages in both directions without the devices getting overloaded and dropping bits. But both my devices have hardware serial ports. I must say upon recollection the Tera term window often had less problem receiving large sets of string data generated from the cortex / Arduino than they had talking to each other.
If you want to post your PIC code I would be glad to review it. I will try to get an example running on my PIC this next week and post it when I do. We have a competition tomorrow so I won’t be able to work on it very soon.
Good Luck. Cheers Kb