Skip to content

Commit 58e3c7e

Browse files
committed
Updates to oc_client to debug gain issues.
oc_client doesn't send use gain_assistance for any data sizes. oc_client calculates mean pixel intensity (over the whole sonar image) as an example of accessing image data.
1 parent c82d5e1 commit 58e3c7e

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

include/liboculus/ImageData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class ImageData {
7070
_stride(stride == 0 ? nBeams*dataSize : stride), // Stride is in _bytes_
7171
_offset(offset) {}
7272

73+
uint16_t nRanges() const { return _numRanges; }
74+
uint16_t nBeams() const { return _numBeams; }
7375

7476
uint8_t at_uint8(unsigned int beam, unsigned int rangeBin) const {
7577
CHECK(_dataSize == 1) << "This function can only handle 8-bit data, use at_uint16()";

include/liboculus/SimpleFireMessage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ void SimpleFireMessage<FireMsgT>::dump() const {
118118
LOG(DEBUG) << "Flags: Range is: " << (this->flags().getRangeAsMeters() ? "Meters" : "Percent");
119119
LOG(DEBUG) << " Range: " << range();
120120
LOG(DEBUG) << "Speed of sound: " << this->fireMsg()->speedOfSound;
121+
LOG(DEBUG) << " Gain pct: " << this->fireMsg()->gainPercent;
122+
121123
}
122124

123125
} // namespace liboculus

tools/oculus_client.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ void signalHandler(int signo) {
4444
doStop = true;
4545
}
4646

47+
double mean_image_intensity( const liboculus::ImageData &imageData ) {
48+
double f;
49+
for ( int r = 0; r < imageData.nRanges(); ++r ) {
50+
for ( int a = 0; a < imageData.nBeams(); ++a ) {
51+
f += imageData.at_uint32(a,r);
52+
}
53+
}
54+
f /= (imageData.nRanges() * imageData.nBeams());
55+
return f;
56+
}
57+
58+
4759
int main(int argc, char **argv) {
4860
libg3logger::G3Logger logger("ocClient");
4961

@@ -128,14 +140,14 @@ int main(int argc, char **argv) {
128140
config.setRange(range);
129141

130142
LOG(INFO) << "Setting gain to " << gain;
131-
config.setGainPercent(gain);
143+
config.setGainPercent(gain).noGainAssistance();
132144

133145
if (bitDepth == 8) {
134146
config.setDataSize(dataSize8Bit);
135147
} else if (bitDepth == 16) {
136148
config.setDataSize(dataSize16Bit);
137149
} else if (bitDepth == 32) {
138-
config.sendGain().noGainAssistance().setDataSize(dataSize32Bit);
150+
config.sendGain().setDataSize(dataSize32Bit);
139151
}
140152

141153
_io_thread.reset(new IoServiceThread);
@@ -163,6 +175,8 @@ int main(int argc, char **argv) {
163175
output.write(cdata, ping.buffer()->size());
164176
}
165177

178+
LOG(DEBUG) << "Average intensity: " << mean_image_intensity(ping.image());
179+
166180
count++;
167181
if ((stopAfter > 0) && (count >= stopAfter))
168182
_io_thread->stop();
@@ -189,6 +203,8 @@ int main(int argc, char **argv) {
189203
output.write(cdata, ping.buffer()->size());
190204
}
191205

206+
LOG(DEBUG) << "Average intensity: " << mean_image_intensity(ping.image());
207+
192208
count++;
193209
if ((stopAfter > 0) && (count >= stopAfter))
194210
doStop = true;

0 commit comments

Comments
 (0)