Record/Play Block Icon of block

紀錄/撥放指令


Record/Play Block

該指令負責紀錄使用者對機器人所作用的動作,藉由紀錄下機器人馬達選轉的圈數並在按下撥放鍵時,準確地轉動該圈數.
This block lets you record an action that you act out with your robot. It does this by remembering how many times the motors turn on your robot and then replaying the correct number of turns when you select “run” on your Record/Play block and run your program.

例如,使用紀錄/撥放指令來紀錄裝有轉輪的機器人前進並即速地向左轉的動作.或是紀錄機器人揮舞著手臂的動作.當執行撥放指令時,這個機器人就會自動地前進,轉向並作出揮手的動作.
For example, you can have the Record/Play block record the motion as you roll a wheeled robot forward and then turn it sharply to the left. Or you might build a robotic arm and record the motion as it shakes hands with you. When you run these recorded motions using a Record/Play block, the wheeled robot will go forward and turn, and the robotic arm will shake hands, in both cases without your help.

要紀錄動作前,先選擇動作名稱跟預估完成的時間,在上述轉輪機器人的範例中,可以設定"前進並轉向"為名稱,並設定10秒的動作時間.
To record an action, first choose a name for the action and an estimated time for how long it will take to complete. In the first example above of the wheeled robot, you might call the file “forward and turn” and set the time to 10 seconds.

下載指令到機器人,準備好後就執行程式並在機器人上作出動作.當時間到時(此例為10秒),使用者操作的動作會被儲存.
You would then download the block. When you’re ready, run the program and act out the motion you want to record. When the time is up (10 seconds in this case), the motion you acted out will be saved.

最後,將指令的參數從"紀錄"改為"撥放",輸入剛才紀錄的動作名稱,再次地下載指令與執行.機器人就會盡可能地自動重複前述的動作.
Finally, change the block’s action property from “record” to “play,” type the name you gave to the recorded sequence, download the Record/Play block again and run the program. It will repeat (as closely as possible) the acted out motion without your help.

注意:被紀錄的動作並不一定完全與使用者作用的動作一致.
Note: Your recorded movement may not be exactly the same as the movement you acted out.

Image of Record/Play block, default settings

  1. 此圖示表示指令為紀錄或是撥放.
    The displayed icon shows whether the block is set to record or play.

設定紀錄/撥放指令
Configuring the Record/Play block:

Image of the configuration pane for the Record/Play block set to record

若是紀錄/撥放檔案,參數便面板的設定如下圖所示.
If you choose to record a Record/Play file, the configuration panel will look like the one above.

  1. 輸入將要做動作的名稱.
    Use the text field to name the motion that you are going to act out.
  2. 勾選要紀錄的輸出端,如果馬達連接的是B與C,則要勾選B與C.
    Check the output ports that you would like to record. If you have motors connected to ports B and C, check the B and C checkboxes.
  3. 設定紀錄動作所需的時間.
    Set the length of time you would like to record in seconds.

Image of the configuration pane for the Record/Play block set to play a recorded file

若是要撥放以紀錄好的檔案,參數面板設定如下圖所示.
If you choose to play an already recorded Record/Play file, the configuration panel will look like the one above.

  1. 輸入要撥放的動作名稱.已經紀錄在NXT裡的動作會依字母順序列在表中,選取要撥放的檔案.
    Type in the file name of the recorded action you want to replay. Files that have already been saved on the NXT will appear in the list in alphabetical order. Select the one you would like to play.

Stop注意:如果要在同一個程式中,紀錄撥放某個動作,則必須記得在兩個指令中輸入同樣的名稱.因為這個名稱是不會顯示在之前的紀錄動作名單內.
Note: If you record and play an action in the same program, you must remember to type in the same file name in both blocks – the file name will not appear in the list of previously saved actions.

設定紀錄/撥放指令的資料集線器
Configuring the Record/Play block’s Data Hub

用資料線可以任意地用來控制紀錄/撥放指令.(從其他指令的資料集線器到紀錄/撥放指令的資料集線器).
You can control the Record/Play block dynamically by connecting data wires (from other blocks’ data hubs) to the Record/Play block’s data hub.

把指令放在工作區上後,可以按圖示的左下角來打開資料集線器.
Open a block’s data hub by clicking the tab at the lower left edge of the block after it has been placed on the work area.

Image showing unopened tab on a generic block

連接到集線器左邊連接埠的資料線是屬於負責傳遞資料進入指令中,而要從指令送出資料時,則須從集線器的右邊連接埠連接資料線.
Data wires carrying input information to a block are connected to the plugs on the left side of its data hub. Data wires carrying output information are connected to the plugs on the right side.

Image of data wires

[A]輸入連接埠 [A] Input plug
[B]輸出連結部 [B] Output plug
[C]數字資料線(黃) [C] Number data wire (yellow)
[D]邏輯資料線(綠) [D]Logic data wire (green)
[E]文字資料線(橘) [E]Text data wire (orange)
[F]無效資料線(灰) [F]Broken data wire (gray)

資料由輸入端傳至傳出端
Passing data from the input plug to the output plug

如果輸入連接埠有對應的輸出連接埠(請參閱 A 以上)時,那麼輸入的資料就會原封不動地傳遞到輸出連接埠.在這樣的情況下, 如果輸入連接埠連著資料線,那麼就只能使用輸出連結埠來做連結. 也就是說,當連結輸出連接線到這樣的輸出連接埠,而不透過相對應的輸入資料線時,就會讓該輸出連接線呈現無效的狀態.
If an input plug has a corresponding output plug (see A above), the input data will pass through from the input plug to the output plug without being changed. In this case, you can only use the output plug if the input plug is connected to an input data wire; connecting an output data wire to such an output plug without a connected input data wire will cause the output data wire to be “broken” (and colored gray).

特定的資料型態
Data wires carry specific types of data

每條資料線都負責傳送特定資料.例如,一條從邏輯連接埠拉出的資料線則只能連結到另一個同屬邏輯連接埠的集線器上.
Each data wire carries a specific type of data between blocks. For example, if a data wire is dragged from a logic plug on a block’s data hub, it can only be connected to a logic plug on another block’s data hub. The chart below shows what kind of data each plug can accept or send out.

資料線顏色
Data wire colors

資料線依照特定的顏色作識別:黃色資料線傳送數值資料、綠色資料線傳送邏輯資料(真/偽)及橘色資料線傳送文字資料
Data wires are identified with specific colors: wires carrying number data are colored yellow, wires carrying logic data are colored green, and wires carrying text data are colored orange.

無效的資料線
“Broken” data wires

如果資料線連結到錯誤資料型態的連接埠時,則該資料線會呈現斷線無效狀態並以灰色表示.而有無效的資料線存在就無法下載程式.
If you try to connect a data wire to a plug of the wrong data type, the data wire will be broken (and colored gray). You will not be able to download your program if a data wire is broken.

點選無效的資料線時,在工作區右下方的幫助視窗中會看到無效的原因.
If you click a broken wire you can read why it is broken in the small help window in the lower right corner of the work area.

資料必須在連接埠的限制範圍內
Data must be within the possible range of the plug

如果資料線傳輸該連接埠資料範圍之外的資料時,該指令不是忽略資料就是轉成合理範圍內的資料.對那些只能接收少量輸入值的連接埠來說(例如,0,1,或2),該連結埠就會忽略超出範圍的數值.
If an input data wire transmits a value outside the possible range of the plug it is connected to, the block will either ignore the value or change it to a value within its range. For plugs that allow just a few input values (example: just 0, 1, or 2), the plug will ignore the input if a value arrives outside its range.

而對那些可以接收大量範圍輸入值(例如: 0~100)的連接埠來說,該連接埠就會將數值轉成可接受的範圍. 例如, 移動指令的動力連接埠接收到150的輸入值時,那麼移動指令就會轉成100(也就是動力連接埠的範圍內).
For plugs that accept larger input ranges (example: 0 – 100), the plug will force any input outside its range to fit. For example, if a Move block’s Power plug receives an input value of 150, the block will change the input value to 100 (i.e., a number within the Power plug’s range).

下表列出本資料集線器中各連接埠的特性
This chart shows the different characteristics of the plugs on the Record/Play block’s data hub:

  連接埠
Plug
資料型態
Data Type
資料範圍
Possible Range
資料意義
What the Values Mean
連接埠例外說明
This Plug is Ignored When...
Port 狀態
Action
數值
Number
0 - 1 0=紀錄, 1=撥放
0 = Record, 1 = Play
 
Port 檔案名稱
Filename
文字
Text
最多15個字元
15 character maximum
紀錄/撥放的檔案名稱
Filename to record/play
 
Port 紀錄A
Record A
邏輯
Logic
真/偽
True/False
真=紀錄馬達A
偽=不紀錄馬達A
True = Record Motor A
False = Don't record Motor A
狀態=撥放
Action = Play
Port 紀錄B
Record B
邏輯
Logic
真/偽
True/False
真=紀錄馬達B
偽=不紀錄馬達B
True = Record Motor B
False = Don't record Motor B
狀態=撥放
Action = Play
Port 紀錄C
Record C
邏輯
Logic
真/偽
True/False
真=紀錄馬達C
偽=不紀錄馬達C
True = Record Motor C
False = Don't record Motor C
狀態=撥放
Action = Play
Port 每秒的取樣時間
Samples per Second
數值 Number 0 - 255 設定在紀錄時馬達的取樣時間
Determines how often the motors are sampled during recording
狀態 = 撥放
Action = Play
Port 總時間
Total Time
數值
Number
0 - 2147483647 紀錄時間(毫秒)
Time to record in milliseconds
狀態=撥放
Action = Play