Skip to content

Commit e4cc350

Browse files
authored
Merge pull request #92 from arduino-libraries/debug-print-recorded-values
Allow retrieval of captured angles in CSV format via Serial command.
2 parents b4d1b75 + c872015 commit e4cc350

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

Diff for: examples/Braccio_Record_and_Replay/AppState.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,41 @@ State * IdleState::handle_OnZeroPosition()
137137
return new ZeroState();
138138
}
139139

140+
State * IdleState::handle_OnTimerTick()
141+
{
142+
/* If data has been recorded and a serial command is
143+
* sent to the device then all recorded positions are
144+
* sent to the PC.
145+
*/
146+
if (!sample_cnt)
147+
return this;
148+
149+
if (!Serial)
150+
return this;
151+
152+
if (!Serial.available())
153+
return this;
154+
155+
if (Serial.read() == 'r')
156+
{
157+
for (int i = 0; i < sample_cnt; i += 6)
158+
{
159+
char msg[64] = {0};
160+
snprintf(msg, sizeof(msg), "%d;%0.2f;%0.2f;%0.2f;%0.2f;%0.2f;%0.2f;",
161+
i / 6,
162+
sample_buf[i + 0],
163+
sample_buf[i + 1],
164+
sample_buf[i + 2],
165+
sample_buf[i + 3],
166+
sample_buf[i + 4],
167+
sample_buf[i + 5]);
168+
Serial.println(msg);
169+
}
170+
}
171+
172+
return this;
173+
}
174+
140175
/**************************************************************************************
141176
* RecordState
142177
**************************************************************************************/

Diff for: examples/Braccio_Record_and_Replay/AppState.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class IdleState : public State
7070
virtual State * handle_OnRecord () override;
7171
virtual State * handle_OnReplay () override;
7272
virtual State * handle_OnZeroPosition() override;
73+
virtual State * handle_OnTimerTick () override;
7374
};
7475

7576
class RecordState : public State

Diff for: examples/Braccio_Record_and_Replay/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
`Braccio_Record_and_Replay`
2+
===========================
3+
For debug purposes all recorded angles can be received via serial command. The approach to do this is:
4+
* Start `minicom`.
5+
```bash
6+
minicom -D /dev/ttyACM0 -C angle_log.csv
7+
```
8+
* Press `Record` and record some angles.
9+
* Retrieve the recorded angles by sending `r` (Press `r`). You'll see the output on your console which will automagically be stored in the CSV file.
10+
* Close `minicom` with `Ctrl + A, Q`.
11+
12+
![Video recording of command sequence](retrieve-angles.mp4)
455 KB
Binary file not shown.

0 commit comments

Comments
 (0)