1
-
2
1
#include < fstream>
3
2
#include < memory>
4
3
#include < string>
@@ -95,7 +94,7 @@ int main(int argc, char **argv) {
95
94
}
96
95
97
96
if ((gain < 1 ) || (gain > 100 )) {
98
- LOG (FATAL) << " Invalid gain " << gain;
97
+ LOG (FATAL) << " Invalid gain " << gain << " ; should be in the range of 1-100 " ;
99
98
}
100
99
101
100
ofstream output;
@@ -124,14 +123,19 @@ int main(int argc, char **argv) {
124
123
125
124
SonarConfiguration config;
126
125
config.setPingRate (pingRateNormal);
126
+
127
+ LOG (INFO) << " Setting range to " << range;
127
128
config.setRange (range);
128
129
130
+ LOG (INFO) << " Setting gain to " << gain;
131
+ config.setGainPercent (gain);
132
+
129
133
if (bitDepth == 8 ) {
130
- config.setGainPercent (gain). setDataSize (dataSize8Bit);
134
+ config.setDataSize (dataSize8Bit);
131
135
} else if (bitDepth == 16 ) {
132
- config.setGainPercent (gain). setDataSize (dataSize16Bit);
136
+ config.setDataSize (dataSize16Bit);
133
137
} else if (bitDepth == 32 ) {
134
- config.setGainPercent (gain). sendGain ().noGainAssistance ().setDataSize (dataSize32Bit);
138
+ config.sendGain ().noGainAssistance ().setDataSize (dataSize32Bit);
135
139
}
136
140
137
141
_io_thread.reset (new IoServiceThread);
@@ -141,8 +145,8 @@ int main(int argc, char **argv) {
141
145
// Callback for a SimplePingResultV1
142
146
_data_rx.setCallback <liboculus::SimplePingResultV1>(
143
147
[&](const liboculus::SimplePingResultV1 &ping) {
144
- // Pings send to the callback are always valid, don't need to check
145
- // again
148
+ // Pings are only sent to the callback if valid()
149
+ // don't need to check independently
146
150
147
151
{
148
152
const auto valid = checkPingAgreesWithConfig (ping, config);
@@ -167,8 +171,8 @@ int main(int argc, char **argv) {
167
171
// Callback for a SimplePingResultV2
168
172
_data_rx.setCallback <liboculus::SimplePingResultV2>(
169
173
[&](const liboculus::SimplePingResultV2 &ping) {
170
- // Pings send to the callback are always valid, don't need to check
171
- // again
174
+ // Pings are only sent to the callback if valid()
175
+ // don't need to check independently
172
176
173
177
{
174
178
const auto valid = checkPingAgreesWithConfig (ping, config);
@@ -190,15 +194,16 @@ int main(int argc, char **argv) {
190
194
doStop = true ;
191
195
});
192
196
193
- // Callback when connection to a sonar
197
+ // When the _data_rx connects, send the configuration
194
198
_data_rx.setOnConnectCallback ([&]() {
195
199
config.dump ();
196
200
_data_rx.sendSimpleFireMessage (config);
197
201
});
198
202
199
203
// Connect the client
200
204
if (ipAddr == " auto" ) {
201
- // For auto-deteciont, when the StatusRx connects configure the DataRx
205
+ // To autoconnect, define a callback for the _status_rx which
206
+ // connects _data_rx to the received IP address
202
207
_status_rx.setCallback ([&](const SonarStatus &status, bool is_valid) {
203
208
if (!is_valid || _data_rx.isConnected ())
204
209
return ;
@@ -232,7 +237,7 @@ int main(int argc, char **argv) {
232
237
return 0 ;
233
238
}
234
239
235
- // Playback not currently working
240
+ // !! Playback not currently working
236
241
//
237
242
// int playbackSonarFile(const std::string &filename, ofstream &output,
238
243
// int stopAfter) {
0 commit comments