[Quick Coding Tips] Optimize the Speed and Timing of Robot Behaviors

The Robotics Competitions are exciting! Our primary goal is to accomplish the tasks successfully as fast as possible. Optimizing the speed and timing of robot behaviors is the key to enhancing the robot’s efficiency.

Optimize the speed of Robot Behaviors

  1. The role of blocks
    VEXCode VR allows us to adjust the speed of various robot behaviors using blocks. Here are some examples:

To change the speed, we only need to modify the parameter value of the block (The default velocity is 50%).
oimage2

  1. Set optimal velocity for Robot behaviors to improve the task efficiency
    Based on the requirements of the tasks, we can set a desired velocity for various robot behaviors to improve the overall performance of the robot in the challenges. It doesn’t mean we must always set the velocities to the maximum. Sometimes excessive speed can lead to task failures.

Consider the Coral Reef Cleanup Challenge as an example. Our solution is: 1. Turn the robot to check if there is a piece of trash in front of it. 2. If a piece of trash is detected, drive the robot forward to the trash to collect it. In this project, if we set both the drive velocity and the turn velocity of the Drivetrain to the maximum value (100%), the robot will miss a lot of trash (Image 2).

timing1

This issue arises because the robot rotates too fast, potentially causing the sensor to not report precise data in time. Therefore, we can reduce the robot’s turn velocity to enhance accuracy and complete the tasks successfully.

timing2

Coordinate Robot behaviors

  1. Use the and don’t wait feature of the Robot Control blocks to save time.
    Some Robot Control blocks have the and don’t wait feature. This feature will cause other blocks to continue running. In other words, we can change waiting blocks to non-waiting blocks by applying the and don’t wait feature.

Note:
Waiting blocks–the blocks pause the rest of the stack until that block’s behavior has been completed.

None-waiting blocks–the blocks have the stack continue even if the block’s behavior is not yet complete.

For more information about waiting blocks and non-waiting blocks , please see this article.

To use the feature, select the arrow to expand and don’t wait.
oimage5

The following are some example blocks.

Using the and don’t wait feature empowers the robot to perform distinct behaviors at the same time. Undoubtedly, it will save a lot of time in task completion. Let’s take a look at the following example.
On the VIQRC Slapshot Playground, we want to drive the robot to knock down the Blue Dispenser on the left. There are two ways to crack the challenge. First one: drive the robot to the Blue Dispenser, then raise the Robot Arm to knock down the Dispenser (Image 4). The robot takes more than 4 seconds to complete the task.
oimage7

timing3

Another solution is using the and don’t wait feature of the spin ArmMotor block to enable the robot to start spinning the Arm Motor and continue to spin for 90 degrees while the robot driving to the Blue Dispenser to knock it down (Image 5). The robot completes the task in less than 3 seconds, significantly faster than the first approach.

oimage8

20230817_104906

  1. Use the wait block to coordinate the robot behaviors
    In VEXCode VR, the wait block is another powerful tool that helps us to coordinate the robot’s behaviors, ensuring accuracy and efficiency.
    oimage9

In the following example, we intend to drive the robot to score the Preload Triball in the Blue Alliance Goal on the Over Under Playground. To complete the task as fast as possible, our strategy is: 1. drive the robot to the scoring position while simultaneously lowering its Arm, 2. spin the Intake Motor to launch the Triball into the Blue Alliance Goal (Image 7).

timing5

However, the Triball is not scored into the Goal. The reason is that when the robot arrives at the scoring position, its Arm doesn’t reach the 1200 degrees position yet, which causes the Arm position to be too high to score the Triball into the Goal. To solve this problem, we can insert a wait block before the spin IntakeMotor block to make the robot wait for a certain amount of time, ensuring to launch the Triball when the Arm is at the position of 1200 degrees.

timing 6

Optimizing the speed and timing of robot behaviors is crucial in enhancing task efficiency. Practice makes perfect. The effectively coordinated robot actions can improve the robot’s overall performance in competitions significantly.

Please let us know if you have any questions, comments, or feedback. Thank you!

3 Likes

Thanks for sharing @Ling_Zhang! I think this post is a great reminder that faster is not always better. Particularly in Playgrounds like Coral Reef Cleanup, many students’ first instinct may be to just go as fast as they can - BUT there are several tradeoffs when that happens. Your post gives a great way to help explain why speed isn’t always the best strategy, and opens the door to explore other strategies. :slight_smile:

1 Like

Thank you very much @Audra_Selkowitz ! I really like the VEXCode VR playgrounds because they can show the coding results immediately in front of our eyes, just like in the real world :grinning:. This makes it easy and fun to help students understand why this strategy works or where that approach could be better.

1 Like