Skip to content

Commit d1a0900

Browse files
authored
Merge pull request #29 from apl-ocean-engineering/devel/alt_constants
Update Constants.h to include a new set of constants which include both sonar model name and frequency.
2 parents 19bef52 + d955a01 commit d1a0900

File tree

1 file changed

+70
-21
lines changed

1 file changed

+70
-21
lines changed

include/liboculus/Constants.h

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,90 @@ const uint16_t DataPort = 52100;
4646
const uint8_t PacketHeaderLSB = (OCULUS_CHECK_ID & 0x00FF);
4747
const uint8_t PacketHeaderMSB = (OCULUS_CHECK_ID & 0xFF00) >> 8;
4848

49-
namespace Oculus_1200MHz {
49+
#define DEG2RAD(x) (x * M_PI / 180.0)
50+
51+
//===================================================================
52+
//
53+
// New constants API which separates constants by both model
54+
// and frequency band
55+
56+
namespace Oculus_M750d {
57+
namespace Freq_750kHz {
58+
const float ElevationBeamwidthDeg = 20.0;
59+
const float ElevationBeamwidthRad = DEG2RAD(ElevationBeamwidthDeg);
60+
61+
const float AzimuthBeamwidthDeg = 1.0;
62+
const float AzimuthBeamwidthRad = DEG2RAD(AzimuthBeamwidthDeg);
63+
64+
const float MaxRange = 120;
65+
}; // namespace Freq_750kHz
66+
67+
namespace Freq_1200kHz {
68+
const float ElevationBeamwidthDeg = 12.0;
69+
const float ElevationBeamwidthRad = DEG2RAD(ElevationBeamwidthDeg);
70+
71+
const float AzimuthBeamwidthDeg = 0.6;
72+
const float AzimuthBeamwidthRad = DEG2RAD(AzimuthBeamwidthDeg);
73+
74+
const float MaxRange = 40;
75+
}; // namespace Freq_1200kHz
76+
}; // namespace Oculus_M750d
77+
78+
namespace Oculus_M1200d {
79+
namespace Freq_1200kHz {
5080
const float ElevationBeamwidthDeg = 20.0;
51-
const float ElevationBeamwidthRad = 20.0 * M_PI / 180.0;
81+
const float ElevationBeamwidthRad = DEG2RAD(ElevationBeamwidthDeg);
5282

5383
const float AzimuthBeamwidthDeg = 0.6;
54-
const float AzimuthBeamwidthRad = 0.6 * M_PI / 180.0;
84+
const float AzimuthBeamwidthRad = DEG2RAD(AzimuthBeamwidthDeg);
5585

56-
// NOTE(lindzey): According to the spec sheet, max range is 30 m
57-
// at 1.2 MHz on the M3000d, but 40 m on the M1200d.
5886
const float MaxRange = 40;
59-
}; // namespace Oculus_1200MHz
87+
}; // namespace Freq_1200kHz
6088

61-
namespace Oculus_2100MHz {
89+
namespace Freq_2100kHz {
6290
const float ElevationBeamwidthDeg = 12.0;
63-
const float ElevationBeamwidthRad = 12.0 * M_PI / 180.0;
91+
const float ElevationBeamwidthRad = DEG2RAD(ElevationBeamwidthDeg);
6492

6593
const float AzimuthBeamwidthDeg = 0.4;
66-
const float AzimuthBeamwidthRad = 0.4 * M_PI / 180.0;
94+
const float AzimuthBeamwidthRad = DEG2RAD(AzimuthBeamwidthDeg);
6795

68-
// \todo These shouldn't be fixed, should read from Oculus.h
69-
// But I don't feel like dealing with their data structure
70-
const float MaxRange = 10; // meters
71-
}; // namespace Oculus_2100MHz
96+
const float MaxRange = 10;
97+
}; // namespace Freq_2100kHz
98+
}; // namespace Oculus_M1200d
7299

73-
namespace Oculus_3000MHz {
100+
namespace Oculus_M3000d {
101+
namespace Freq_1200kHz {
74102
const float ElevationBeamwidthDeg = 20.0;
75-
const float ElevationBeamwidthRad = 20.0 * M_PI / 180.0;
103+
const float ElevationBeamwidthRad = DEG2RAD(ElevationBeamwidthDeg);
76104

77-
const float AzimuthBeamwidthDeg = 0.4;
78-
const float AzimuthBeamwidthRad = 0.4 * M_PI / 180.0;
105+
const float AzimuthBeamwidthDeg = 0.6;
106+
const float AzimuthBeamwidthRad = DEG2RAD(AzimuthBeamwidthDeg);
79107

80-
// \todo These shouldn't be fixed, should read from Oculus.h
81-
// But I don't feel like dealing with their data structure
82-
const float MaxRange = 5; // meters
83-
}; // namespace Oculus_3000MHz
108+
const float MaxRange = 30;
109+
}; // namespace Freq_1200kHz
110+
111+
namespace Freq_3000kHz {
112+
const float ElevationBeamwidthDeg = 20.0;
113+
const float ElevationBeamwidthRad = DEG2RAD(ElevationBeamwidthDeg);
114+
115+
const float AzimuthBeamwidthDeg = 0.4;
116+
const float AzimuthBeamwidthRad = DEG2RAD(AzimuthBeamwidthDeg);
117+
118+
const float MaxRange = 5;
119+
}; // namespace Freq_3000kHz
120+
}; // namespace Oculus_M3000d
121+
122+
//===================================================================
123+
//
124+
// "Old"" constants API which only considered nominal frequency.
125+
// So it can't handle the case where different models may have
126+
// different performance at the same nominal center frequency.
127+
128+
// For backwards compatibility
129+
namespace Oculus_750KHz = Oculus_M750d::Freq_750kHz;
130+
namespace Oculus_1200MHz = Oculus_M1200d::Freq_1200kHz;
131+
namespace Oculus_2100MHz = Oculus_M1200d::Freq_2100kHz;
132+
namespace Oculus_3000MHz = Oculus_M3000d::Freq_3000kHz;
84133

85134
struct FlagBits {
86135
// bit 0: 0 = interpret range as percent, 1 = interpret range as meters

0 commit comments

Comments
 (0)