Make script for car control

#1

Hello everyone! I'm using Epoc+ headset to control the movement of a robot car. The brain signals will be collected by the headset and send to EmotiBCI application. I trained different mental commands there and I pass the data of the mental commands to Node-RED toolbox. So my question is, is anyone knows how to make a script for the car control using the data that passed to the Node-RED toolbox? Or can anyone suggest other method or software that can provide the same function? I'm a newbie in this area. Thanks in advance.

0 Likes

#2

Interesting project!

A couple of quick thoughts:

  • Firstly, "latency". There will be quite a lag between your brain, the interpreted signal, and the vehicle. Something to keep in mind. I believe that you can get away with about 80 ms before this becomes an issue.
  • Secondly, we would need to know how the car is controlled? Is it a custom robot where you have control over the firmware?
1 Like

#3

Hi! Thanks for reply me.

I will made a http server on a WiFi module (ESP-12E) which will connected to the Arduino robor car. With using javascript, I'll take the script of the mental command and the signal will be send to the Arduino robot car through the WiFi to control the movement.

0 Likes

#4

OK, so in that case, yes you could use Node-RED as an intermediary to help. Though without knowing some details about the brain controller, it is hard to say just how much help it will be.

For example, NR is great at prototyping process flows. But if your controller outputs data that is easily and relatively directly consumable, then it may be just as easy - and likely have lower latency - to send it direct.

In truth, using HTTP for the control protocol with the ESP is not very efficient either. Off the top of my head, I'm not sure how easy it is to implement a websockets interface but that would likely be more efficient.

Head controller -> xfer to processor -> process control data -> xfer to ESP -> control relays

Seems fairly straight-forwards. Node-RED could easily take care of the middle 3 steps.

Some quick searches throw up a number of examples for using websockets with ESP8266 devices so that should be fine. Node-RED has a websocket connector node, also good.

Next question is how to connect the headset to Node-RED. It looks like the headset uses BlueTooth? So you'll need to set up a controller with BT - a Raspberry Pi 3 would do the job nicely and without too much cost. You could also use a <3 version but would need to add BT via a USB stick.

Without looking into the details, hopefully the BT connection exposes serial data? That would be the easiest approach as you could then use a serial-in node to capture the EEG data into Node-RED and start processing it.

One word of caution, if the EEG data is significant - e.g. there is lots of it - once again, it might become easier to process it using more traditional tools first. But maybe you could share some data so we can look at it?

Shame the EPOC+ unit is rather expensive - you had me quite excited that I could offer this as something my wife's children's therapy using could use with seriously disabled children.

0 Likes

#5

No worries about the connection to Node-RED. Node-RED shares the same cloud with the EmotivBCI which I used to train different commands. The picture shows the flow of one of my commands. Just wondering how to transfer the data to a script. I'll post the data of this flow after I deployed it tomorrow.

1 Like

#6

The data on the right hand side of the picture is the data when I deploy the training command into Node-RED. I'm still figuring out what is the meaning of the data.

0 Likes

#7

I'm guessing that the number is some kind of confidence factor (%?) that the "command" is what you think it is?

So you are going to end up with a few commands, each with a feed of numbers.

So you will want to filter out (for each command node) numbers below a confidence level and you will probably want to translate anything left into a command string - something like at least: "left", "right", "faster", "slower", "stop".

Then you will want to pass those to your car.

0 Likes

#8

Do you know how to translate the 'left' commands into the command string using Node-RED?

0 Likes

#9

Well, given that you have each command coming out of its own section of flow, all you need to do is something like:

command-node --> switch-node      -->   change-node   -->  output
                 Is the number  (yes)   set payload    
                 high enough?           to cmd string

                                (no)    [do nothing]
0 Likes

#10

Hi. Thanks for your reply. I’m currently on vacation so the progress of the project cannot be updated. I’ll update the progress once I continue on the project.

0 Likes

#11

Hello. The number is some kind of the sensitivity of the signals. Therefore, I've created two paths for the commands and I think it works fine now.


The next step is to transfer the signals to the Arduino Robot that I used in this project.
Arduino Robot: https://www.arduino.cc/en/Guide/Robot
Do you know any good solution to transfer the signals using the Arduino node?

0 Likes

#12

Depending on how you can talk to the Arduino, the 2 choices are Firmata - but that requires a Firmata build on the Arduino which, I think, excludes custom code (everything has to happen externally and is sent to the Arduino) or Serial. If you have WiFi on the Arduino then I would use MQTT as a message broker. If BlueTooth then you are back to serial over BT.

0 Likes

#13

Hi! Thanks for your reply. I've decided to use MQTT as the wireless communication using the ESP8266

1 Like