Skip to content

Commit f0a9db5

Browse files
committed
Allow retrieval of captured angles in CSV format via Serial command.
1 parent b4d1b75 commit f0a9db5

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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
**************************************************************************************/

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

0 commit comments

Comments
 (0)