sBotics Wiki

Tutorial do Simulador usado pela OBR

Ferramentas do usuário

Ferramentas do site


programming

Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

Próxima revisão
Revisão anterior
programming [2025/07/18 20:35] – criada adminprogramming [2025/07/18 20:37] (atual) – [Difficulty Hierarchy] admin
Linha 1: Linha 1:
-``` 
 ====== Programming ====== ====== Programming ======
  
Linha 17: Linha 16:
   - Import / Export program files.   - Import / Export program files.
  
-{{:programming.png|Programming Menu}}+{{:programacao.png|Programming Menu}}
  
 > **Tip!** If your written program (not BlockEduc) becomes too large (+700 lines), we recommend using VSCode to program in the simulator. Simply look for the "Switch Modes" button with the VSCode symbol to switch. VSCode is more efficient for very large codes and prevents the simulator from becoming too slow with your code. > **Tip!** If your written program (not BlockEduc) becomes too large (+700 lines), we recommend using VSCode to program in the simulator. Simply look for the "Switch Modes" button with the VSCode symbol to switch. VSCode is more efficient for very large codes and prevents the simulator from becoming too slow with your code.
Linha 25: Linha 24:
 {{ switch_language.png?200}} {{ switch_language.png?200}}
 That is, given the hierarchy below: That is, given the hierarchy below:
-  - [[BlockEduc]] (Easiest) +  - [[en:BlockEduc]] (Easiest) 
-  - [[rEduc]] (Intermediate) +  - [[en:rEduc]] (Intermediate) 
-  - [[csharp|C#]] (Most difficult)+  - [[en:csharp|C#]] (Most difficult)
 It is always possible, by programming in an easier language, to convert your code to a more difficult language using the language switch function at the top of the programming screen. It is always possible, by programming in an easier language, to convert your code to a more difficult language using the language switch function at the top of the programming screen.
  
Linha 34: Linha 33:
 > **We do not intend to make converters for easier languages because the purpose of sBotics is to introduce people to robotics education, and we want users to progress in difficulty and skill.** > **We do not intend to make converters for easier languages because the purpose of sBotics is to introduce people to robotics education, and we want users to progress in difficulty and skill.**
  
-In general, we always advise using **[[rEduc]]** for your programs. However, if you are not familiar with text-based programming or already know advanced programming, there is no problem in using [[BlockEduc]] and [[csharp|C#]]. Just understand that each language will bring advantages and disadvantages, such as less control over routines in the case of BlockEduc and a steep learning curve in the case of C#.+In general, we always advise using **[[en:rEduc]]** for your programs. However, if you are not familiar with text-based programming or already know advanced programming, there is no problem in using [[en:BlockEduc]] and [[en:csharp|C#]]. Just understand that each language will bring advantages and disadvantages, such as less control over routines in the case of BlockEduc and a steep learning curve in the case of C#.
 ===== Understanding Synchronous Programming (Advanced) ===== ===== Understanding Synchronous Programming (Advanced) =====
 Imagine that sBotics is like a stage where the robot performs its actions. In a traditional robot, it is its own stage, where it does its things without worrying too much about what might happen to the program. If the program is inefficient and causes memory to run out, the robot will simply shut down or stop. It is important to understand that sBotics and your robot share the same stage. An inefficient function in your robot can make the entire sBotics slow, or even exhaust the program's memory as a whole. Imagine that sBotics is like a stage where the robot performs its actions. In a traditional robot, it is its own stage, where it does its things without worrying too much about what might happen to the program. If the program is inefficient and causes memory to run out, the robot will simply shut down or stop. It is important to understand that sBotics and your robot share the same stage. An inefficient function in your robot can make the entire sBotics slow, or even exhaust the program's memory as a whole.
Linha 40: Linha 39:
 > **For those more studied in programming:** sBotics runs on the same "thread" as the user's program due to Unity. Previously, we used multi-threaded programming, but it was extremely inefficient and caused many memory leaks. > **For those more studied in programming:** sBotics runs on the same "thread" as the user's program due to Unity. Previously, we used multi-threaded programming, but it was extremely inefficient and caused many memory leaks.
  
-How does this affect programming? (in [[csharp|C#]])+How does this affect programming? (in [[en:csharp|C#]])
   * "While true": Indiscriminate "while true" statements crash sBotics, as it waits for the robot to finish something that never finishes before continuing to run the simulator.   * "While true": Indiscriminate "while true" statements crash sBotics, as it waits for the robot to finish something that never finishes before continuing to run the simulator.
   * Waiting is important: In real robotics, commands take time to execute. Now, in sBotics, you **must** use a command called "wait" to simulate this waiting time. This allows sBotics to continue functioning while the robot performs its actions.   * Waiting is important: In real robotics, commands take time to execute. Now, in sBotics, you **must** use a command called "wait" to simulate this waiting time. This allows sBotics to continue functioning while the robot performs its actions.
Linha 65: Linha 64:
 ==== How to Resolve? ==== ==== How to Resolve? ====
 To solve problems with your code, always separate your code into tasks, functions, and blocks that you can comment out or remove to test cases in isolation. This way, you can get a better idea of what is happening and where. In the vast majority of cases, problems that result in crashes come from inefficient programming, which has too many unnecessary loops and calculations. Check your repetition structures (while, for, repeat, etc.) and make sure the functions being performed are efficient, and if a functionality is too heavy, always consider putting one or more "''%%wait%%''" inside that repetition. To solve problems with your code, always separate your code into tasks, functions, and blocks that you can comment out or remove to test cases in isolation. This way, you can get a better idea of what is happening and where. In the vast majority of cases, problems that result in crashes come from inefficient programming, which has too many unnecessary loops and calculations. Check your repetition structures (while, for, repeat, etc.) and make sure the functions being performed are efficient, and if a functionality is too heavy, always consider putting one or more "''%%wait%%''" inside that repetition.
-``` 
programming.1752870936.txt.gz · Última modificação: 2025/07/18 20:35 por admin