Online Brain Simulator

Hello, this year I took notice of the difficulty you can face when attempting to make code affecting the brains screen from home. For this reason I want to work on a website simulator of how a brains screen might function when running vex code. My first instinct was to find a way of converting the vex brains firmware into a UI for the website, but then I learned of the closed nature around it’s code. With this in mind my next thought was to take the commands that would be run from the code(Ex; Print on brain) and then make the website know to change the UI(Ex; in this case to print it on the screen image on the website). I still feel like this would have flaws though. If you have better ideas on how we could I could go about doing this, or any tips in general please let me know.

1 Like

It’s fairly simple.
Because you are creating a website, I recommend the HTML element. Afterward, just simulate the functions from, let’s say blocks. Firstly, ask the user to upload some file.
If you open a plain vexcode file in notepad, you’ll notice the JSON, which you can use to your advantage.
You can also use the HTML to render to the user. Steal some Vex CSS to style it.
For every block, add another line of code in javascript for ctx.some_function, which you can all attach to a string together.
After that, run an eval() function over the string, and I think it would work. (Sorry for the bad description)
Also, because there are wait functions, I advise you to use asynchronous for the entire thing (bleurgh, but I guess you have to).

As a side note, I’m not sure how you would do the same with Python or C++.

I’ll make an interface framework for you if you want one.

go for it and show us how simple is is.

22 Likes

I’ll say that you aren’t going to get anywhere with full firmware emulation. The brain has a crazy amount of I/O and a lot of proprietary hardware to deal with such I/O that make CPU0 (VEXos/firmware-level) emulation through something like QEMU not impossible, but very very impractical. Emulating just user code is a different story, and is something that could be viably done given enough effort.

If you’re just looking to emulate display stuff, there isn’t a complete solution for that yet, but specific libraries like LVGL that people often use have desktop OS ports. If it’s just the basic brain drawing functions, i’d recommend just doing that on actual hardware for now.

3 Likes

At one point we had planned to release a simulator for VEXcode projects (text only). All of the V5 cpu1 (ie. the user cpu) code can be built with simulation in mind. The problem I ran into was how to release as it required a local toolchain, XCode or Visual studio, to be available and it’s not allowed to release parts of those projects to simplify integration into something like VEXcode. It used SDL2 as the cross platform graphics engine. So I abandoned it, but it could do things like this.

simulator

16 Likes

Here’s my current progress without CSS:

brain_sim_beta.zip (1.4 KB)

You can see the basic parts of my idea in here. I am currently adding more functions, styling, and I think I might finish by next week.

Once you show a program flowchart, it actually is quite simple.

Keyword: yet.

Also, I do claim rights to my code.

5 Likes

Uh, you mean the code emulating a piece of copyrighted software?

9 Likes

Yes. I hold “My code”, not the VexCode Brain’s code.

Also, people who agree with this:

go for it and show us how simple is is.

Can you show how this is difficult and not simple?

sure, here is a link to a VEXcode project that draws a simple graph, it’s fairly simple graphics just using a few of the available drawing commands that VEXcode has.

come back with a JS simulation that uses this code and produces the same result.

6 Likes

Sure; Can you give me the C++/Python code for this? My current code is for blocks, not text.

It’s in the topic I linked, first post.

7 Likes

Here it is!! There are still many bugs I am trying to catch and flatten, as well as the fact that the page looks terrible, but it works. Also, the canvas and the brain aren’t always aligned (based on computer):
https://jakehu2020.github.io/V5-Brain-Emulator/
https://jakehu2020.github.io/V5-Brain-Emulator/

Here is the current vex blocks file I’m using for that:
VEXcode Project (21) (12) (1) (33).v5blocks (9.5 KB)
(Don’t worry about the end, it’s fine)

Once I fine-tune it, I might post this as a new post on VexForum. (Sorry @Owlumination7865E, I kind of did it myself; it’s no longer a template.)

6 Likes

WRONG CODE… That was testing
Here’s the actual one:
VEXcode Project (21) (12) (1) (31) (28).v5blocks (20.5 KB)

3 Likes

Honestly thank you for doing this, also tbh this all somewhat revived my hope in these forums to see people actually come together to solve a problem again.

4 Likes

I am thinking of building a sensor for VEXIQ, is there any way to exchange data with VEXIQ? Like UART or IIC or even MATLAB or something?