Skip to content

Commit afdf97e

Browse files
committed
Merge branch 'master-mirror' into estimation-student
2 parents ce23866 + 88fa3df commit afdf97e

File tree

5 files changed

+65
-42
lines changed

5 files changed

+65
-42
lines changed

Diff for: config/X_Scenarios.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
X_DebugAttitudeInterp
22
X_TestMavlink
33
X_TestManyQuads
4-
X_MonteCarloTest
4+
X_MonteCarloTest
5+
X_ParamTests

Diff for: src/Drawing/GraphManager.cpp

+1-40
Original file line numberDiff line numberDiff line change
@@ -191,45 +191,6 @@ vector<string> GraphManager::GetGraphableStrings()
191191
return ret;
192192
}
193193

194-
vector<string> ParseFunction(string cmd)
195-
{
196-
vector<string> ret;
197-
198-
if (cmd.empty()) return ret;
199-
if (cmd[cmd.size() - 1] != ')') return ret;
200-
201-
string f = SLR::LeftOf(cmd, '(');
202-
if (f.find_first_of('"') != string::npos) return ret;
203-
204-
string args = cmd.substr(f.size() + 1, cmd.size() - f.size() - 2);
205-
206-
ret.push_back(f);
207-
208-
bool quote = false;
209-
unsigned int i=0, s = 0;
210-
for (i = 0; i < args.size(); i++)
211-
{
212-
if (args[i] == '"')
213-
{
214-
quote = !quote;
215-
if (quote) s = i;
216-
continue;
217-
}
218-
if (args[i] == ',' && !quote)
219-
{
220-
ret.push_back(SLR::Trim(args.substr(s, i - s)));
221-
s = i+1;
222-
}
223-
}
224-
225-
if (s != i)
226-
{
227-
ret.push_back(SLR::Trim(args.substr(s, i - s)));
228-
}
229-
230-
return ret;
231-
}
232-
233194
void GraphManager::GraphCommand(string cmd)
234195
{
235196
// old-style commands
@@ -244,7 +205,7 @@ void GraphManager::GraphCommand(string cmd)
244205
return;
245206
}
246207

247-
vector<string> s = ParseFunction(cmd);
208+
vector<string> s = SimpleFunctionParser(cmd);
248209

249210
if (s.size() == 3 && s[0] == "SetTitle")
250211
{

Diff for: src/Drawing/Visualizer_GLUT.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ void Visualizer_GLUT::InitializeMenu(const vector<string>& strings)
825825

826826
void Visualizer_GLUT::OnMenu(string cmd)
827827
{
828+
vector<string> s = SimpleFunctionParser(cmd);
828829
if (cmd == "Toggle.RefTrajectory")
829830
{
830831
showRefTrajectory = !showRefTrajectory;
@@ -842,6 +843,24 @@ void Visualizer_GLUT::OnMenu(string cmd)
842843
string name = string("../config/")+cmd.substr(9)+".txt";
843844
_delayedScenarioLoader = name;
844845
}
846+
else if (s.size() == 3 && s[0] == "PrintParam")
847+
{
848+
ParamsHandle config = SimpleConfig::GetInstance();
849+
850+
if (s[1] == "V3F")
851+
{
852+
V3F p;
853+
if (!config->GetV3F(s[2], p))
854+
{
855+
printf("Command [%s] error: parameter get failed\n", cmd.c_str());
856+
}
857+
else
858+
{
859+
printf("V3F %s = %lf %lf %lf\n", s[2].c_str(), p.x, p.y, p.z);
860+
}
861+
}
862+
863+
}
845864
else
846865
{
847866
graph->GraphCommand(cmd);

Diff for: src/Utility/SimpleConfig.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ void SimpleConfig::ReadFile(const string& filename, int depth)
6969
fclose(f);
7070
}
7171

72-
void SimpleConfig::ParseLine(const string& filename, const string& s, int lineNum, string& curNamespace, int depth)
72+
void SimpleConfig::ParseLine(const string& filename, const string& line, int lineNum, string& curNamespace, int depth)
7373
{
74+
// primitive trailing removal
75+
string s = SLR::LeftOf(line, '#');
76+
7477
std::size_t firstNonWS = s.find_first_not_of("\n\t ");
7578

7679
// is it a comment?

Diff for: src/Utility/StringUtils.h

+39
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,45 @@ inline std::string UnQuote(const std::string& s)
8686
return arg;
8787
}
8888

89+
inline std::vector<string> SimpleFunctionParser(string cmd)
90+
{
91+
std::vector<string> ret;
92+
93+
if (cmd.empty()) return ret;
94+
if (cmd[cmd.size() - 1] != ')') return ret;
95+
96+
string f = SLR::LeftOf(cmd, '(');
97+
if (f.find_first_of('"') != string::npos) return ret;
98+
99+
string args = cmd.substr(f.size() + 1, cmd.size() - f.size() - 2);
100+
101+
ret.push_back(f);
102+
103+
bool quote = false;
104+
unsigned int i = 0, s = 0;
105+
for (i = 0; i < args.size(); i++)
106+
{
107+
if (args[i] == '"')
108+
{
109+
quote = !quote;
110+
if (quote) s = i;
111+
continue;
112+
}
113+
if (args[i] == ',' && !quote)
114+
{
115+
ret.push_back(SLR::Trim(args.substr(s, i - s)));
116+
s = i + 1;
117+
}
118+
}
119+
120+
if (s != i)
121+
{
122+
ret.push_back(SLR::Trim(args.substr(s, i - s)));
123+
}
124+
125+
return ret;
126+
}
127+
89128
inline std::vector<string> Split(const char* str, char c = ' ')
90129
{
91130
std::vector<std::string> result;

0 commit comments

Comments
 (0)