Can robot brain get/send custom messages to PC?

I’m trying to choose a VEX system to buy.
Which, if any, VEX product line’s ‘robot brain’ modules can run a user program that sends requests for information to a listening PC and then waits and process responses from the PC?

If you have any examples or other references that demonstrate or describe how I can accomplish this, that would be great.

Just in case my question is not clear, I’ll provide an example of the desired scenario.

I write a robot brain user program that uses some sort of VEX communication programming library to send a message over wifi to a PC that has a (custom) program listening on a PC network interface. The PC then sends back information to the listening robot brain/program, which then acts based on the data, e.g., moves to a destination indicated by the PC or perhaps displays some text provided by the PC.

There are a few ways to achieve what you’re trying to do with the V5 brain.
First, is through a direct wired connection. You can connect the computer to the brain’s USB port and communicate over serial that way

Second, is through the wireless serial link using the controller. If you plug your computer into the controller, you can receive data printed to the console from the brain. I am unsure of whether you can send data back using this method however. Additionally, this connection is quite slow.

Third, is to use a raspberry pi or other device plugged into the brain’s USB port to enable you to talk to the brain over wifi. I have done this personally in order to communicate bidirectionally with the robot over the network using ROS nodes

13 Likes

I’ll add a few more

Vex cortex used all standard ports so a 10$ Bluetooth chip could be plugged in and used to talk to computer easily. The new V5 could potentially be interfaced in this way with a rs485 to uart chip between v5 smart ports and uart Bluetooth dongle.

11 Likes

Before I get into this, this needs said - If this can be done with an Adruino or Raspberry Pi, just do it that way. So much easier. Arduino can plug in via USB and you’re done. RPi is a computer already.

Alright so this could be / kind of is a bigger topic. All VEX brains can communicate with a PC it’s just a matter of how much work you want to take on and what you are trying to accomplish.

There are different ways to do it as well. In general these break down to Serial, UART, SPI, I2C, etc. If these terms aren’t familiar to you, you should go learn about communications protocols in embedded systems and come back. Sparkfun has some excellent guides on these subjects.

One easy way is with an FTDI board. It will let you connect a Cortex to PC with a USB cable and four connections. I used to have a detailed post on exactly this subject but it’s probably gone. Actually it’s kind of still there: Cody's BeagleBone Black / Cortex Bridge

I have the images from that guide saved on my vault store, I can grab those for you upon request.

Tabor is talking about a UART to Bluetooth adaptor, and yes these things are cheap and work reasonable well if wireless communications are what you want and the bandwidth and distance limitations of Bluetooth work for you. Other options for wireless communications also include Xbee and Zigbee which range in distance / bandwidth.

In those options you would leverage the exposed UART on the Cortex (no idea about V5) and plug them into the RX and TX ports of whatever bridge you’re using.

Once communicating, you have the additional problem of HOW to communicate. I don’t mean like… how to send data, I mean how you structure that data, which get’s complicated fast. In general what you are asking for is a generic remote procedure call (RPC) framework where the VEX brain is the “master” and the PC is “slave”. I apologize for the somewhat offensive terms, as I am fully aware of the traditional problems with those terms, nonetheless this is what the computer science community has used to describe this relationship for decades so I will just use my industries terms and hopefully that’s OK with all the super mature moderators we have here on VF who can clearly differentiate between real bigotry and realism. :roll_eyes:

Anyway creating this RPC exchange is a little tricky. You have to write code that runs on both the VEX brain and the PC on either end of a serial link. This is because regardless of how you send the data over to the PC, it will show up to the PC (and Cortex) as a serial connection. Those BT bridges go from VEX Brain (as serial) > UART > BT > PC (as serial), as do the FTDI boards VEX Brain (as serial) > UART > PC (as serial).

So you write a program on the Cortex (or whatever) that sends a command message, the PC program gets it and responds with a payload, the Cortex reads the payload and does something with it.

Not that bad. For a very dumb version of this you can send getTheThing\r\n to the PC, and send back [PAYLOAD]\r\n and as long as the payload never naturally contains a newline char, you’re good to go.

To be clear, no existing nice RPC framework exists, you have to write it. VEX does not run Grbl or whatever (if you are thinking of doing numeric control).

14 Likes

V5 only exposes 3-wire ports, which are much the same as those on the Cortex, and the not-exactly-proprietary but not-really-standard-either “Smart” RS485 ports.

The SoC in the Brain supports USB 2.0 OTG, Gigabit Ethernet, SDIO, UART, CAN, I²C, and SPI, but none of that is exposed. (Datasheet)

2 Likes

Why on Earth would they not expose all that … :pensive:

I call upon @jpearman

1 Like

Vex may not be the best system for your application. Node-RED and a raspberry pi or MQTT and ESP32s may be better suited for what you are trying to do. V5 is more for robots. The old cortex system will have more communication directly exposed (UART and I2C) but will also be more expensive than an arduino, raspberry pi, or ESP32.

1 Like

It’s for competitive robotics not hacking/IOT projects :man_facepalming:

Circa 5 years ago, me calling for a sub $100 robot brain with exposed USB. Five years later, yet another person asking for PC to VEX communication which would be a hell of a lot easier with … an exposed USB port.

Look they clearly made the product that works best for them, not for us. This is why robotics needs to move towards purely open source and open hardware. It’s super simple.

2 Likes

You can actually use the USB port on V5 while having VEXnet connected (the VEXnet radio for the Brain plugs into a “Smart” port) — see what @sazrocks said above.

Nevertheless, you are still limited to the standard printf() family of functions for interfacing with anything over USB.

1 Like

I see that…

Screen Shot 2020-06-23 at 12.14.39 PM

What’s wrong with that? I assume his application is simple enough. Does that port expose a bi-directional serial device?

It is indeed bidirectional, and it should work for simple applications. I am not sure which programming environments support reading data from serial-over-USB, but I know at least PROS does support it.

1 Like

some of those buses are used internally, otherwise it’s usually (not completely) about $$$$

Don’t forget, VEXs target market is primarily schools, not hobbyists.

With the right PC, BLE connection to the V5 is pretty useful.

10 Likes

Excuse my ignorance of the V5, does it have BLE out the box?

Also is the money saved at the SoC vendor level by disabling the IP or is it a cost of ports, PCB parts, making injection models more complicated kind of thing?

Also I don’t buy it, darn thing costs $270, when an RPi costs $5-35.

I didn’t realize that direct to the brain BLE connections had been enabled yet. Is there any documentation on how to set this up? I would very much like to bypass the raspi in my ROS setup.

1 Like

yes, you can use browser APIs like navigator.bluetooth for communication if the PC/Mac hardware supports it. The next release of VEXcode for iPad has BLE download.

4 Likes

Yeah I worked as a firmware engineer at GoPro briefly on their BLE protocol on the HERO 8 / thing I can’t talk about yet. I just didn’t know the V5 had it. Makes sense though.

Alright op has options.

It was enabled in vexos 1.0.9 I think, certainly it was several months ago.
and I don’t know what the current plan is for documentation.
It’s most useful for tablets, I’ve had very intermittent success with Mac’s for example, my 2015 laptop won’t work, my 2017 laptop will, my old Mac Pro won’t

2 Likes

BT / BLE standards are strange and complicated. I would say that is less of a V5 thing and more of a BLE thing.

1 Like

Ok, but can you give us some of the basics? For instance, what methods do we use to send and receive bluetooth messages on the brain?

7 Likes