Which language should i use for rocket simulator?

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

deepfreeze

Well-Known Member
TRF Supporter
Joined
Dec 3, 2022
Messages
55
Reaction score
1
Location
New Jersey, US
Hello guys i am building a rocket and i also coded a simulator so i can get the data in real-time when i am connected to the teensy 4.0.
I coded it in python but i dont think it is really working as smooth as i think.

I have 2 simulators, one is just a pygame screen. It is working but it can't be more than that. But i am an obsessive programmer and play with my code all the time to make it better.
second is on the tkinter window and couple plots in it. But this is not working as smooth as i would want.

Is there anything you can suggest on this matter? I can code in any language that's fine.
 

Attachments

  • WhatsApp Video 2022-12-26 at 15.05.40.mp4
    1.8 MB
  • WhatsApp Video 2022-12-26 at 15.05.27 (1).mp4
    1.6 MB
As others have said, complied c is fast but I personally prefer to work in Python as long as I can get away with it.

Assuming that you're reading the data in via serial/UART, I'd first ask if the data ingest is being done efficiently or if that is a part of the problem. There are a lot of really bad patterns that can be used for UART reading and only a few good ones.

If that's not the bottleneck, I'd start to look at the display/GUI. Do you need/want a GUI or just real-time plots? Do you need to recalculate the plots limits each time you update or less regularly?

Depends upon your update rates and end goals but I'd be surprised if you couldn't get acceptable results in Python. If you want to post your code or a send Github link, I'll be happy to take a look.
 
As others have said, complied c is fast but I personally prefer to work in Python as long as I can get away with it.

Assuming that you're reading the data in via serial/UART, I'd first ask if the data ingest is being done efficiently or if that is a part of the problem. There are a lot of really bad patterns that can be used for UART reading and only a few good ones.

If that's not the bottleneck, I'd start to look at the display/GUI. Do you need/want a GUI or just real-time plots? Do you need to recalculate the plots limits each time you update or less regularly?

Depends upon your update rates and end goals but I'd be surprised if you couldn't get acceptable results in Python. If you want to post your code or a send Github link, I'll be happy to take a look.
I want to put like 10 plots and updating them constantly in a while(true) loop. Something like that.
Python is alright but if I wanna update more than 5 plots, it’s going crazy.

My data is just comma separated values. Not a csv file tho. So I don’t do anything to work on the data. Just getting the data, feeding a rocket class and plotting. That’s all.

I want something like more efficient.

Also in Python I am having so many threads. Almost one thread for each plot. It is not working good actually. It is hard to change things too. Bcz in tkinter I gotta adjust everything like line by line. I didn’t like the grid system usage much.
I don’t know if it makes sense. I’ll share my code with you. Send me a message please
 
I would suggest APL, but people will hurl bricks at me.

I will suggest whatever language you are familiar and comfortable in programming in. I would have thought Python would be a good starting point, and may be easier to read, think and maintain than C variants. It depends on your skill level as a programmer.
 
Also in Python I am having so many threads.
In standard Python threads don't get you any real parallelism on a multicore computer because of the global interpreter lock. You have to use the multiprocessing library.

That said, I agree with tHoagland, there is probably some way to get acceptable performance in Python. I am not a big fan of matplotlib, however, if that's what you are trying to use.
 
In standard Python threads don't get you any real parallelism on a multicore computer because of the global interpreter lock. You have to use the multiprocessing library.
All correct but different threads can be used to allow one task to continue while another sleeps or awaits an async response. That said, I'm not sure I would be using any additional threads in this application.

I'd probably look at using Matplotlib (as part of a pyqt/pyside application) or Bokeh (using the web browser/Javascript to render the plots). Both are reasonably preformant and easy to work with.
 
Or my day job... :)

Your day job is getting all my kits to me so that I can stare at them for a few weeks, wondering where to start first. 😂🥳🤩😇

I am kidding, but it was too easy to pass up!! 😁

My former IT guy at work, who retired after an extremely lucrative career in programming and software sales and consulting for around 20 years prior. Said that if you want to sign your own paycheck. Learn Cobol and then go work as a consultant for the US Government. His words, "They're some of the only morons that let themselves get so far behind on technology, they have to spend a fortune to have developers in archaic languages on retainer to keep them going. Then again, it is the US Government."
 
All correct but different threads can be used to allow one task to continue while another sleeps or awaits an async response. That said, I'm not sure I would be using any additional threads in this application.

I'd probably look at using Matplotlib (as part of a pyqt/pyside application) or Bokeh (using the web browser/Javascript to render the plots). Both are reasonably preformant and easy to work with.
I agree Matplotlib (pyqt/pyside) works pretty well and much better than tkinter or Vpython.
I did do a sim in Vpython with 3D rendering of a rocket. This used the data file. It wasn't too slow but was not very useful in analyzing the flight.

If you really need to speed on the plots then Visual C# can run much faster.
You will also have much better control of a Serial Port if you are reading live data.

I have not found plotting the rocket data live to be of much use. I'd rather be watching the rocket then a screen. Only condition when live data is useful is when the rocket goes high enough to be out of sight. Then data is nice to tell you status.
I simply log the data then at home run the log file through calibration and import into Excel to plot graphs.
 
Last edited:
What are you guys think about electric ui with c++
Never heard of nor found anything about "electric ui" in a search.
Any links to this?

Way back in the day, 1980's, I did write GUI libraries for a 'windows' like apps. This was before GUI's were common. This does take a lot of coding. Today, there are many GUI libraries on which to base an app.

Here is a discussion on GUI's :
https://stackoverflow.com/questions/1186017/how-do-i-build-a-graphical-user-interface-in-c
Note: Stackoverflow is a very good place to go to to find good answers to coding questions. It typically pops up when I enter a coding question in Google search.
 
Back
Top