Skip to content

Commit c82d5e1

Browse files
committed
Increased verbosity of output from oculus_client.
1 parent c3977a8 commit c82d5e1

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

tools/oculus_client.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include <fstream>
32
#include <memory>
43
#include <string>
@@ -95,7 +94,7 @@ int main(int argc, char **argv) {
9594
}
9695

9796
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";
9998
}
10099

101100
ofstream output;
@@ -124,14 +123,19 @@ int main(int argc, char **argv) {
124123

125124
SonarConfiguration config;
126125
config.setPingRate(pingRateNormal);
126+
127+
LOG(INFO) << "Setting range to " << range;
127128
config.setRange(range);
128129

130+
LOG(INFO) << "Setting gain to " << gain;
131+
config.setGainPercent(gain);
132+
129133
if (bitDepth == 8) {
130-
config.setGainPercent(gain).setDataSize(dataSize8Bit);
134+
config.setDataSize(dataSize8Bit);
131135
} else if (bitDepth == 16) {
132-
config.setGainPercent(gain).setDataSize(dataSize16Bit);
136+
config.setDataSize(dataSize16Bit);
133137
} else if (bitDepth == 32) {
134-
config.setGainPercent(gain).sendGain().noGainAssistance().setDataSize(dataSize32Bit);
138+
config.sendGain().noGainAssistance().setDataSize(dataSize32Bit);
135139
}
136140

137141
_io_thread.reset(new IoServiceThread);
@@ -141,8 +145,8 @@ int main(int argc, char **argv) {
141145
// Callback for a SimplePingResultV1
142146
_data_rx.setCallback<liboculus::SimplePingResultV1>(
143147
[&](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
146150

147151
{
148152
const auto valid = checkPingAgreesWithConfig(ping, config);
@@ -167,8 +171,8 @@ int main(int argc, char **argv) {
167171
// Callback for a SimplePingResultV2
168172
_data_rx.setCallback<liboculus::SimplePingResultV2>(
169173
[&](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
172176

173177
{
174178
const auto valid = checkPingAgreesWithConfig(ping, config);
@@ -190,15 +194,16 @@ int main(int argc, char **argv) {
190194
doStop = true;
191195
});
192196

193-
// Callback when connection to a sonar
197+
// When the _data_rx connects, send the configuration
194198
_data_rx.setOnConnectCallback([&]() {
195199
config.dump();
196200
_data_rx.sendSimpleFireMessage(config);
197201
});
198202

199203
// Connect the client
200204
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
202207
_status_rx.setCallback([&](const SonarStatus &status, bool is_valid) {
203208
if (!is_valid || _data_rx.isConnected())
204209
return;
@@ -232,7 +237,7 @@ int main(int argc, char **argv) {
232237
return 0;
233238
}
234239

235-
// Playback not currently working
240+
// !! Playback not currently working
236241
//
237242
// int playbackSonarFile(const std::string &filename, ofstream &output,
238243
// int stopAfter) {

0 commit comments

Comments
 (0)