Skip to content

Commit 6eed5ed

Browse files
committed
Configure Kite through plugin TOML
1 parent 81c9397 commit 6eed5ed

3 files changed

Lines changed: 93 additions & 88 deletions

File tree

config/plugin/GeoData.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ name = "Campus"
8585
easting = 507047.64631626336
8686
northing = 5398555.900845651
8787
altitude = 450.0
88+
89+
90+
[[datasets]]
91+
name = "Kite ground station"
92+
easting = 507047.64631626336
93+
northing = 5398555.900845651
94+
altitude = 450.0
95+
trueNorth = 0.0

config/plugin/KitePlugin.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Model = "/data/MERIDIONAL/kitedata/kite.stl"
2+
CSV = "/data/MERIDIONAL/kitedata/flight.csv"
3+
4+
ShowGround = true
5+
GroundPosX = 0.0
6+
GroundPosY = 0.0
7+
GroundPosZ = 0.0
8+
9+
WorldScale = 0.5

src/OpenCOVER/plugins/hlrs/Kite/KitePlugin.cpp

Lines changed: 76 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "KitePlugin.h"
99

10-
#include <config/CoviseConfig.h>
1110
#include <cover/coVRAnimationManager.h>
1211
#include <cover/coVRFileManager.h>
1312
#include <cover/coVRPluginSupport.h>
@@ -83,8 +82,13 @@ static osg::Matrix geoTransformMatrix(const osg::Vec3 &pos, float scale, float y
8382

8483
bool KitePlugin::init()
8584
{
86-
auto modelEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.Model", "");
87-
m_csvPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.CSV", "");
85+
const auto configEntries = config()->entries("");
86+
const auto hasConfigEntry = [&configEntries](const std::string &name) {
87+
return std::find(configEntries.begin(), configEntries.end(), name) != configEntries.end();
88+
};
89+
90+
auto modelEntry = config()->value<std::string>("", "Model", "")->value();
91+
m_csvPath = config()->value<std::string>("", "CSV", "")->value();
8892

8993
auto toLowerCopy = [](std::string s) {
9094
std::transform(s.begin(), s.end(), s.begin(),
@@ -113,95 +117,92 @@ bool KitePlugin::init()
113117
return false;
114118
};
115119

116-
const std::string nedEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.NED", "");
117-
if (!nedEntry.empty())
120+
if (hasConfigEntry("NED"))
118121
{
119-
m_useNedFrame = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.NED", m_useNedFrame);
122+
m_useNedFrame = config()->value<bool>("", "NED", m_useNedFrame)->value();
120123
m_frameAuto = false;
121124
}
122-
const std::string frameEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.Frame", "");
125+
const std::string frameEntry = config()->value<std::string>("", "Frame", "")->value();
123126
if (!frameEntry.empty())
124127
applyFrameMode(frameEntry);
125-
m_rollSign = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RollSign", m_rollSign);
126-
m_pitchSign = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PitchSign", m_pitchSign);
127-
m_yawSign = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.YawSign", m_yawSign);
128-
m_rollOffsetDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RollOffset", m_rollOffsetDeg);
129-
m_pitchOffsetDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PitchOffset", m_pitchOffsetDeg);
130-
m_yawOffsetDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.YawOffset", m_yawOffsetDeg);
131-
m_rollScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RollScale", (float)m_rollScale);
132-
m_pitchScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PitchScale", (float)m_pitchScale);
133-
m_limitAttitude = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.LimitAttitude", m_limitAttitude);
134-
m_maxAbsRollDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.MaxAbsRollDeg", (float)m_maxAbsRollDeg);
135-
m_maxAbsPitchDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.MaxAbsPitchDeg", (float)m_maxAbsPitchDeg);
136-
m_smoothPose = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.SmoothPose", m_smoothPose);
137-
m_posSmoothAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.PositionSmoothing", (float)m_posSmoothAlpha);
138-
m_rotSmoothAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RotationSmoothing", (float)m_rotSmoothAlpha);
139-
m_despikeOrientation = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.DespikeOrientation", m_despikeOrientation);
140-
m_despikeYawOnly = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.DespikeYawOnly", m_despikeYawOnly);
141-
m_despikeJumpDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.DespikeJumpDeg", (float)m_despikeJumpDeg);
142-
m_despikeSettleDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.DespikeSettleDeg", (float)m_despikeSettleDeg);
143-
m_knotFollowTether = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.KnotFollowTether", m_knotFollowTether);
128+
m_rollSign = config()->value<double>("", "RollSign", m_rollSign)->value();
129+
m_pitchSign = config()->value<double>("", "PitchSign", m_pitchSign)->value();
130+
m_yawSign = config()->value<double>("", "YawSign", m_yawSign)->value();
131+
m_rollOffsetDeg = config()->value<double>("", "RollOffset", m_rollOffsetDeg)->value();
132+
m_pitchOffsetDeg = config()->value<double>("", "PitchOffset", m_pitchOffsetDeg)->value();
133+
m_yawOffsetDeg = config()->value<double>("", "YawOffset", m_yawOffsetDeg)->value();
134+
m_rollScale = config()->value<double>("", "RollScale", m_rollScale)->value();
135+
m_pitchScale = config()->value<double>("", "PitchScale", m_pitchScale)->value();
136+
m_limitAttitude = config()->value<bool>("", "LimitAttitude", m_limitAttitude)->value();
137+
m_maxAbsRollDeg = config()->value<double>("", "MaxAbsRollDeg", m_maxAbsRollDeg)->value();
138+
m_maxAbsPitchDeg = config()->value<double>("", "MaxAbsPitchDeg", m_maxAbsPitchDeg)->value();
139+
m_smoothPose = config()->value<bool>("", "SmoothPose", m_smoothPose)->value();
140+
m_posSmoothAlpha = config()->value<double>("", "PositionSmoothing", m_posSmoothAlpha)->value();
141+
m_rotSmoothAlpha = config()->value<double>("", "RotationSmoothing", m_rotSmoothAlpha)->value();
142+
m_despikeOrientation = config()->value<bool>("", "DespikeOrientation", m_despikeOrientation)->value();
143+
m_despikeYawOnly = config()->value<bool>("", "DespikeYawOnly", m_despikeYawOnly)->value();
144+
m_despikeJumpDeg = config()->value<double>("", "DespikeJumpDeg", m_despikeJumpDeg)->value();
145+
m_despikeSettleDeg = config()->value<double>("", "DespikeSettleDeg", m_despikeSettleDeg)->value();
146+
m_knotFollowTether = config()->value<bool>("", "KnotFollowTether", m_knotFollowTether)->value();
144147

145148
// Rope config (optional)
146-
m_ropeEnabled = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.RopeEnabled", m_ropeEnabled);
147-
// m_ropeRadius = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeRadius", m_ropeRadius);
148-
m_ropeRadius = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeRadius", m_ropeRadius);
149+
m_ropeEnabled = config()->value<bool>("", "RopeEnabled", m_ropeEnabled)->value();
150+
m_ropeRadius = config()->value<double>("", "RopeRadius", m_ropeRadius)->value();
149151
if (m_ropeRadius <= 0.f)
150152
m_ropeRadius = 0.05f; // force visible default
151153

152-
m_ropeSagFactor = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSagFactor", m_ropeSagFactor);
153-
m_ropeSagMax = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSagMax", m_ropeSagMax);
154-
m_ropeSamplesMain = (int)coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSamplesMain", (float)m_ropeSamplesMain);
155-
m_ropeSamplesBridle = (int)coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.RopeSamplesBridle", (float)m_ropeSamplesBridle);
154+
m_ropeSagFactor = config()->value<double>("", "RopeSagFactor", m_ropeSagFactor)->value();
155+
m_ropeSagMax = config()->value<double>("", "RopeSagMax", m_ropeSagMax)->value();
156+
m_ropeSamplesMain = (int)config()->value<double>("", "RopeSamplesMain", m_ropeSamplesMain)->value();
157+
m_ropeSamplesBridle = (int)config()->value<double>("", "RopeSamplesBridle", m_ropeSamplesBridle)->value();
156158

157-
m_drawFullTether = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.DrawFullTether", m_drawFullTether);
158-
m_fullTetherAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.FullTetherAlpha", m_fullTetherAlpha);
159-
m_focusTetherAlpha = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.FocusTetherAlpha", m_focusTetherAlpha);
159+
m_drawFullTether = config()->value<bool>("", "DrawFullTether", m_drawFullTether)->value();
160+
m_fullTetherAlpha = config()->value<double>("", "FullTetherAlpha", m_fullTetherAlpha)->value();
161+
m_focusTetherAlpha = config()->value<double>("", "FocusTetherAlpha", m_focusTetherAlpha)->value();
160162

161-
m_tetherFade = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.TetherFade", m_tetherFade);
162-
m_tetherNearLen_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherNearLen_m", m_tetherNearLen_m);
163+
m_tetherFade = config()->value<bool>("", "TetherFade", m_tetherFade)->value();
164+
m_tetherNearLen_m = config()->value<double>("", "TetherNearLen_m", m_tetherNearLen_m)->value();
163165

164-
m_tetherSagBoost = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherSagBoost", m_tetherSagBoost);
165-
m_tetherSagMaxLong_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherSagMaxLong_m", m_tetherSagMaxLong_m);
166+
m_tetherSagBoost = config()->value<double>("", "TetherSagBoost", m_tetherSagBoost)->value();
167+
m_tetherSagMaxLong_m = config()->value<double>("", "TetherSagMaxLong_m", m_tetherSagMaxLong_m)->value();
166168

167-
m_tetherLineWidthNear = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherLineWidthNear", m_tetherLineWidthNear);
168-
m_tetherLineWidthFar = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherLineWidthFar", m_tetherLineWidthFar);
169+
m_tetherLineWidthNear = config()->value<double>("", "TetherLineWidthNear", m_tetherLineWidthNear)->value();
170+
m_tetherLineWidthFar = config()->value<double>("", "TetherLineWidthFar", m_tetherLineWidthFar)->value();
169171

170-
m_tetherAlphaNear = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherAlphaNear", m_tetherAlphaNear);
171-
m_tetherAlphaFar = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TetherAlphaFar", m_tetherAlphaFar);
172+
m_tetherAlphaNear = config()->value<double>("", "TetherAlphaNear", m_tetherAlphaNear)->value();
173+
m_tetherAlphaFar = config()->value<double>("", "TetherAlphaFar", m_tetherAlphaFar)->value();
172174

173-
m_snapAnchorsToSurface = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.SnapAnchorsToSurface", m_snapAnchorsToSurface);
174-
m_anchorLift_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.AnchorLift_m", m_anchorLift_m);
175-
m_snapRayUp_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.SnapRayUp_m", m_snapRayUp_m);
176-
m_snapRayDown_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.SnapRayDown_m", m_snapRayDown_m);
175+
m_snapAnchorsToSurface = config()->value<bool>("", "SnapAnchorsToSurface", m_snapAnchorsToSurface)->value();
176+
m_anchorLift_m = config()->value<double>("", "AnchorLift_m", m_anchorLift_m)->value();
177+
m_snapRayUp_m = config()->value<double>("", "SnapRayUp_m", m_snapRayUp_m)->value();
178+
m_snapRayDown_m = config()->value<double>("", "SnapRayDown_m", m_snapRayDown_m)->value();
177179

178-
m_groundPos.x() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundPosX", m_groundPos.x());
179-
m_groundPos.y() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundPosY", m_groundPos.y());
180-
m_groundPos.z() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundPosZ", m_groundPos.z());
181-
m_showGround = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.ShowGround", m_showGround);
182-
m_worldScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.WorldScale", m_worldScale);
183-
m_targetTether_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.TargetTether_m", m_targetTether_m);
184-
const std::string groundSizeEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.GroundSize_m", "");
185-
if (!groundSizeEntry.empty())
180+
m_groundPos.x() = config()->value<double>("", "GroundPosX", m_groundPos.x())->value();
181+
m_groundPos.y() = config()->value<double>("", "GroundPosY", m_groundPos.y())->value();
182+
m_groundPos.z() = config()->value<double>("", "GroundPosZ", m_groundPos.z())->value();
183+
m_showGround = config()->value<bool>("", "ShowGround", m_showGround)->value();
184+
m_worldScale = config()->value<double>("", "WorldScale", m_worldScale)->value();
185+
m_targetTether_m = config()->value<double>("", "TargetTether_m", m_targetTether_m)->value();
186+
if (hasConfigEntry("GroundSize_m"))
186187
{
187-
m_groundSize_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GroundSize_m", m_groundSize_m);
188+
m_groundSize_m = config()->value<double>("", "GroundSize_m", m_groundSize_m)->value();
188189
m_groundSizeAuto = false;
189190
}
190-
m_focusMode = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.FocusMode", m_focusMode);
191-
m_focusTetherLen_m = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.FocusTetherLen_m", m_focusTetherLen_m);
192-
193-
m_geoModelPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.GeoModel", "");
194-
m_geoPos.x() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoPosX", m_geoPos.x());
195-
m_geoPos.y() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoPosY", m_geoPos.y());
196-
m_geoPos.z() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoPosZ", m_geoPos.z());
197-
m_geoScale = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoScale", m_geoScale);
198-
m_geoYawDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.GeoYawDeg", m_geoYawDeg);
199-
m_geoAutoCenter = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.GeoAutoCenter", m_geoAutoCenter);
200-
m_geoAutoGround = coCoviseConfig::isOn("COVER.Plugin.KitePlugin.GeoAutoGround", m_geoAutoGround);
201-
202-
m_junctionLocal.x() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.JunctionLocalX", m_junctionLocal.x());
203-
m_junctionLocal.y() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.JunctionLocalY", m_junctionLocal.y());
204-
m_junctionLocal.z() = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.JunctionLocalZ", m_junctionLocal.z());
191+
m_focusMode = config()->value<bool>("", "FocusMode", m_focusMode)->value();
192+
m_focusTetherLen_m = config()->value<double>("", "FocusTetherLen_m", m_focusTetherLen_m)->value();
193+
194+
m_geoModelPath = config()->value<std::string>("", "GeoModel", "")->value();
195+
m_geoPos.x() = config()->value<double>("", "GeoPosX", m_geoPos.x())->value();
196+
m_geoPos.y() = config()->value<double>("", "GeoPosY", m_geoPos.y())->value();
197+
m_geoPos.z() = config()->value<double>("", "GeoPosZ", m_geoPos.z())->value();
198+
m_geoScale = config()->value<double>("", "GeoScale", m_geoScale)->value();
199+
m_geoYawDeg = config()->value<double>("", "GeoYawDeg", m_geoYawDeg)->value();
200+
m_geoAutoCenter = config()->value<bool>("", "GeoAutoCenter", m_geoAutoCenter)->value();
201+
m_geoAutoGround = config()->value<bool>("", "GeoAutoGround", m_geoAutoGround)->value();
202+
203+
m_junctionLocal.x() = config()->value<double>("", "JunctionLocalX", m_junctionLocal.x())->value();
204+
m_junctionLocal.y() = config()->value<double>("", "JunctionLocalY", m_junctionLocal.y())->value();
205+
m_junctionLocal.z() = config()->value<double>("", "JunctionLocalZ", m_junctionLocal.z())->value();
205206

206207
auto envToBool = [](const char *name, bool value) {
207208
if (const char *env = std::getenv(name))
@@ -237,19 +238,6 @@ bool KitePlugin::init()
237238
return value;
238239
};
239240

240-
if (modelEntry.empty())
241-
{
242-
modelEntry = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.Model", "");
243-
}
244-
if (m_csvPath.empty())
245-
{
246-
m_csvPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.CSV", "");
247-
}
248-
if (m_geoModelPath.empty())
249-
{
250-
m_geoModelPath = coCoviseConfig::getEntry("value", "COVER.Plugin.KitePlugin.GeoModel", "");
251-
}
252-
253241
if (std::getenv("KITE_NED"))
254242
{
255243
m_useNedFrame = envToBool("KITE_NED", m_useNedFrame);
@@ -309,9 +297,9 @@ bool KitePlugin::init()
309297
m_geoAutoCenter = envToBool("KITE_GEO_AUTO_CENTER", m_geoAutoCenter);
310298
m_geoAutoGround = envToBool("KITE_GEO_AUTO_GROUND", m_geoAutoGround);
311299

312-
double modelRollDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.ModelOffsetRoll", 0.0);
313-
double modelPitchDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.ModelOffsetPitch", 0.0);
314-
double modelYawDeg = coCoviseConfig::getFloat("COVER.Plugin.KitePlugin.ModelOffsetYaw", 0.0);
300+
double modelRollDeg = config()->value<double>("", "ModelOffsetRoll", 0.0)->value();
301+
double modelPitchDeg = config()->value<double>("", "ModelOffsetPitch", 0.0)->value();
302+
double modelYawDeg = config()->value<double>("", "ModelOffsetYaw", 0.0)->value();
315303
modelRollDeg = envToDouble("KITE_MODEL_OFFSET_ROLL", modelRollDeg);
316304
modelPitchDeg = envToDouble("KITE_MODEL_OFFSET_PITCH", modelPitchDeg);
317305
modelYawDeg = envToDouble("KITE_MODEL_OFFSET_YAW", modelYawDeg);

0 commit comments

Comments
 (0)