MOVEMENT BLOCKS
|
Movement Blocks enable you to run two motors in a synchronized motion. They're primarily used to move Driving Bases around. Only motors of the same type (e.g., two Medium Motors) can be synchronized.
|
Initialization of Movement Blocks
In computer programming, initialization is the assignment of an initial value for a data object or variable. For example: at the beginning of a game, you would set the score to zero. That way every time the game starts, the score is zero. Your Spike Prime program doesn't know how you built your robot.
|
Movement Blocks
These 3 blocks all move your robot straight. How are they different? When would you use one over the other? Let's take a closer look?
This block can drive straight, arc, or spin on it's axis. It will be an important block for making sharp turns.
|
The ability to arc can be really useful when going around an obstacle. Here is some data from Carnegie Mellon University about how the arc numbers relate to real distances.
|
This block starts moving a Driving Base forever at the speed that's been specified for each motor. The first specified speed value sets the speed of the left motor, and the second specified value sets the speed of the right motor.
|
This block is the most versatile and provides more granular control because you can control the speed of each motor. This block can mimic all the other move blocks. Here are some examples (the speed numbers can be changed but need to remain relative to one another. For example 50 50 can be changed to 99 99).
|
Making Sharp Turns
The following code shows the code for a custom "right turn block" and "left turn block", as well as how it is used in a program. Click on the tags to learn more.
Hubs Gyroscope: Yaw, Pitch and Roll Angles
Now I can measure direction using angles. Notice the:
|
The gyroscope in the hub can sense direction similar to a compass. But it doesn't have a compass. That's why you have to tell it which way is north (or zero). You do that by using "Set yaw angle to 0". That says, set the direction I'm currently pointed in to zero.
The red line below is "yaw angle = 0". You measure your yaw angle from there.
|
This block can be used in your programs. It reports the Hub's pitch, roll, or yaw angle.
Here is the code if you want to see the yaw, pitch, or roll angle. It will be displayed on the screen.
|