top of page

MISSION COUNT

Aurora P.

Hi,

Welcome to the first guide to advanced programs.

Today I will teach you how to insert all the launches of your robot into a single program. It is not a complex program to create and can help you make your RobotGame more efficient.

Get ready with the robot and a new project open on your programming device.

Aurora

Introduction

If you have gained some experience with Spike you will have noticed that when you want to change or start a program there are some animations that make you lose a few seconds at each change in base.

Our team has designed a system that allows you to start each launch instantly by pressing just one button.

Thanks to Mission Count we can quickly start our launches, stop the robot during the run and move on to the next launch quickly and efficiently.

Creating the Variable

First, we need to create the variable Mission Count, which is responsible for storing the number of the current launch.

We then set up our variable at the start of the program, setting its value to 1.

Next, we insert a block to display the value of this variable on the screen. In our case, we also add a block to adjust the display orientation so that the numbers are easily readable by our drivers.

basic program
programma base
basic program
basic program

Starting the Launches

Now that we have set the Mission Count value and written it on the display, we continue by inserting the event that allows us to start our program.

First we insert a When right/left button is released block that determines the action we need to perform to initiate our throw.

We attach to it all the operations that we want to perform before each launch. For example, we always keep the angle measured by our gyroscope before starting. Always remember to wait a few tenths of a second before and after the reset to avoid the gyroscope from undergoing accelerations during this delicate operation.

We then insert an If block that allows us to perform the operations contained therein only when the mission count is equal to the specific launch number. For the first launch we will have the condition If Mission Count is equal to 1 , for the second we insert the value 2 and so on for all our launches.

Inside these we will insert the various throws that our robot must perform.

To conclude this part of the program we need to update the Mission Count variable and write its new value to the display to let the drivers know which launch they are about to perform.

after all blocks If we insert the Change Mission Count by 1 block and write the mission count value again.

basic program
basic program
basic program
basic program
basic program
basic program
basic program
basic program

Stopping the Launches

The last part of the program we need to write is the one that allows us to stop the robot during a launch and move on to the next launches.

This action must be performed when the other button on our Hub is pressed. We insert the block When the right button is pressed and first stop the execution of all other Stacks. To do this, we insert the block stop other Stacks.

Once the other executions are stopped, we stop all motors using the block Stop motors and update the Mission Count.

It is very important that the block that stops the Stacks is positioned before stopping the motors to prevent them from being restarted by one of the operations performed by the other Stacks.

To conclude, we need to insert a condition that allows us to reset the Mission Count to the initial value when we have exceeded the number of our launches. For example, if we plan to perform 6 launches, we insert a condition that automatically resets the Mission Count variable to 1 if it has reached 7 since we do not have a launch 7.

The condition is If Mission Count is equal to 7 Set Mission Count to 1.

This condition can also be inserted at the end of the Stack containing the launches. Remember to insert this condition before writing the Mission Count value on the screen; otherwise, the display will show the value 7 instead of the value 1.

basic program
basic program
programma base
basic program
basic program
basic program
bottom of page