update links
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
This tutorial shows FTC Blocks programmers how to use Timers. If you're in a hurry (<i>no time</i>), skip to the [examples below](#timer-examples). Java programmers may benefit from learning here how FTC timers work.
|
This tutorial shows FTC Blocks programmers how to use Timers. If you're in a hurry (<i>no time</i>), skip to the [examples below](#timer-examples).
|
||||||
|
|
||||||
|
<p>Java programmers may benefit from learning here how FTC timers work.
|
||||||
|
|
||||||
## Why not Sleep?
|
## Why not Sleep?
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ Instead you must use a built-in <u>method</u> or command, to <u>get</u> or retri
|
|||||||
|
|
||||||
The green Block uses an **Elapsed Time** method named "Time"; you can consider it as "Get A Timer's Current Elapsed Time Value". **<u>Elapsed time</u> means the time that has passed since the timer was created or last reset, whichever was later.** You might prefer to ignore the system time and think of timers as counting **from zero**. That outlook or model does work, but keep in mind the actual process is to subtract the starting system time from the current system time. This tutorial will often refer to elapsed time as simply "time".
|
The green Block uses an **Elapsed Time** method named "Time"; you can consider it as "Get A Timer's Current Elapsed Time Value". **<u>Elapsed time</u> means the time that has passed since the timer was created or last reset, whichever was later.** You might prefer to ignore the system time and think of timers as counting **from zero**. That outlook or model does work, but keep in mind the actual process is to subtract the starting system time from the current system time. This tutorial will often refer to elapsed time as simply "time".
|
||||||
|
|
||||||
We can read the above Blocks from right to left. The "Time" method gets the time value from myTimer and passes, or <u>returns</u>, the calculated Elapsed Time to the left. On the left could be a variable to hold that number, or it could be another Block that accepts number input.
|
We can read the above Blocks from right to left. From myTimer, the "Time" method gets the time value and passes, or <u>returns</u>, the calculated Elapsed Time to the left. On the left could be a variable to hold that number, or it could be another Block that accepts number input.
|
||||||
|
|
||||||
The units will be Seconds or Milliseconds, based on how the timer was created.
|
The units will be Seconds or Milliseconds, based on how the timer was created.
|
||||||
|
|
||||||
@ -89,6 +91,8 @@ You may find that a constantly changing time value causes programming or calcula
|
|||||||
|
|
||||||
Here the Telemetry Block builds a message showing the variable currentTime, containing a value retrieved from your timer. Although its value may be updating constantly in a Repeat loop, currentTime is not actually the running stopwatch. Again, keep in mind that the variable holds a **fixed, saved value**.
|
Here the Telemetry Block builds a message showing the variable currentTime, containing a value retrieved from your timer. Although its value may be updating constantly in a Repeat loop, currentTime is not actually the running stopwatch. Again, keep in mind that the variable holds a **fixed, saved value**.
|
||||||
|
|
||||||
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
Telemetry can give a **final time report** from variables that recorded the duration of actions or time between actions. When developing new Autonomous OpModes, this tool can help you optimize performance and identify wasted time.
|
Telemetry can give a **final time report** from variables that recorded the duration of actions or time between actions. When developing new Autonomous OpModes, this tool can help you optimize performance and identify wasted time.
|
||||||
|
|
||||||
<p align="center">[[/images/Timers-in-FTC-Blocks/0820-options-Telemetry3.png|]]<p>
|
<p align="center">[[/images/Timers-in-FTC-Blocks/0820-options-Telemetry3.png|]]<p>
|
||||||
@ -108,11 +112,11 @@ When testing your Op Mode, make sure the final Telemetry message **stays on the
|
|||||||
|
|
||||||
Here are five common uses of timers in FTC:
|
Here are five common uses of timers in FTC:
|
||||||
|
|
||||||
[1. ](#1-loop-for-time)Loop until a time limit is reached. Think of this as an alarm clock.<br>
|
[<b>1. </b>](#1-loop-for-time)Loop until a time limit is reached. Think of this as an alarm clock.<br>
|
||||||
[2. ](#2-measure-duration-of-action)Measure the length of time (until an action stops or occurs). Think of this as a stopwatch.<br>
|
[<b>2. </b>](#2-measure-duration-of-action)Measure the length of time (until an action stops or occurs). Think of this as a stopwatch.<br>
|
||||||
[3. ](#3-safety-timeout)Safety timeout. Don't get stuck in a loop!<br>
|
[<b>3. </b>](#3-safety-timeout)Safety timeout. Don't get stuck in a loop!<br>
|
||||||
[4. ](#4-match-timer)Match timer or countdown timer.<br>
|
[<b>4. </b>](#4-match-timer)Match timer or countdown timer.<br>
|
||||||
[5. ](#5-device-timer-in-teleop)Device timer in TeleOp.
|
[<b>5. </b>](#5-device-timer-in-teleop)Device timer in TeleOp.
|
||||||
|
|
||||||
More advanced applications are mentioned at the end of this tutorial.
|
More advanced applications are mentioned at the end of this tutorial.
|
||||||
|
|
||||||
@ -142,7 +146,7 @@ Again, **timers don't stop**; all you can do is read the time value at one momen
|
|||||||
|
|
||||||
## 3. Safety Timeout
|
## 3. Safety Timeout
|
||||||
|
|
||||||
This is similar to 'Loop for Time', except here the timer is not the **primary basis** for looping, it's the **last resort**. Reaching the time limit typically means the loop **did not achieve** its primary goal; it's <i>time</i> to give up and move on. This can help prevent: motor/servo burnout, mechanism breaking, field damage, or simply wasted time. All action loops should have a safety timeout.
|
This is similar to 'Loop for Time', except here the timer is not the **primary basis** for looping, it's the **last resort**. Reaching the time limit typically means the loop **did not achieve** its primary goal; it's <i>time</i> to give up and move on. This can help prevent: motor/servo burnout, mechanism breaking, field damage, or simply wasted time. <b><i>Action loops should have a safety timeout.</b></i>
|
||||||
|
|
||||||
Here is a simple example that might be used in Autonomous or an automated section of TeleOp.
|
Here is a simple example that might be used in Autonomous or an automated section of TeleOp.
|
||||||
|
|
||||||
@ -248,7 +252,7 @@ The above Block writes a message to the system log file, for later analysis. Th
|
|||||||
|
|
||||||
<p align="center">[[/images/Timers-in-FTC-Blocks/0680-Elapsed-to-text.png|]]<p>
|
<p align="center">[[/images/Timers-in-FTC-Blocks/0680-Elapsed-to-text.png|]]<p>
|
||||||
|
|
||||||
The above Block returns a <u>text string</u>, converted from the timer's numeric value of elapsed time. This allows combining the value with other text; here is an example.
|
The above Block returns a <u>text string</u>, converted from the timer's numeric value of elapsed time. This allows combining the value with other text; here is an example:
|
||||||
|
|
||||||
<p align="center">[[/images/Timers-in-FTC-Blocks/0690-example-to-text.png|]]<p>
|
<p align="center">[[/images/Timers-in-FTC-Blocks/0690-example-to-text.png|]]<p>
|
||||||
|
|
||||||
@ -275,6 +279,8 @@ This tutorial described basic use of Timers in Blocks programming. Timers also
|
|||||||
|
|
||||||
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
[<p align="right"><i>Return to Top</i>](#introduction)<p>
|
||||||
|
|
||||||
===========
|
***
|
||||||
|
|
||||||
<i>Questions, comments and corrections to: westsiderobotics@verizon.net</i>
|
<br><i>Questions, comments and corrections to: westsiderobotics@verizon.net</i>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
Reference in New Issue
Block a user