unit test now works
parent
bdeeb48c6e
commit
afcddf823a
|
@ -2,4 +2,5 @@
|
|||
/doc*
|
||||
*.pyc
|
||||
*.DS_Store
|
||||
/examples/Data/dubrovnik-3-7-pre-rewritten.txt
|
||||
/examples/Data/dubrovnik-3-7-pre-rewritten.txt
|
||||
/examples/Data/pose2example-rewritten.txt
|
|
@ -0,0 +1,80 @@
|
|||
3 7 19
|
||||
|
||||
0 0 -385.989990234375 387.1199951171875
|
||||
1 0 -38.439998626708984 492.1199951171875
|
||||
2 0 -667.91998291015625 123.11000061035156
|
||||
0 1 383.8800048828125 -15.299989700317383
|
||||
1 1 559.75 -106.15000152587891
|
||||
0 2 591.54998779296875 136.44000244140625
|
||||
1 2 863.8599853515625 -23.469970703125
|
||||
2 2 494.72000122070312 112.51999664306641
|
||||
0 3 592.5 125.75
|
||||
1 3 861.08001708984375 -35.219970703125
|
||||
2 3 498.54000854492187 101.55999755859375
|
||||
0 4 348.72000122070312 558.3800048828125
|
||||
1 4 776.030029296875 483.52999877929687
|
||||
2 4 7.7800288200378418 326.35000610351562
|
||||
0 5 14.010009765625 96.420013427734375
|
||||
1 5 207.1300048828125 118.36000061035156
|
||||
0 6 202.75999450683594 340.989990234375
|
||||
1 6 543.18011474609375 294.80999755859375
|
||||
2 6 -58.419979095458984 110.83000183105469
|
||||
|
||||
-0.016943983733654022
|
||||
0.011171804741024973
|
||||
0.0024643507786095142
|
||||
0.73030996322631825
|
||||
-0.2649081945419311
|
||||
-1.7127892971038821
|
||||
1430.031982421875
|
||||
-7.5572756941255648e-008
|
||||
3.2377570134516087e-014
|
||||
|
||||
0.015049724839627745
|
||||
-0.18504564464092257
|
||||
-0.29278403520584112
|
||||
-1.05904757976532
|
||||
-0.036017861217260333
|
||||
-1.5720340013504028
|
||||
1432.137451171875
|
||||
-7.317191830225056e-008
|
||||
3.1759419042137055e-014
|
||||
|
||||
-0.30793598294258112
|
||||
0.32077908515930176
|
||||
0.22253985702991483
|
||||
8.5034484863281268
|
||||
6.74996042251587
|
||||
-3.6383814811706534
|
||||
1572.047119140625
|
||||
-1.5962623223231276e-008
|
||||
-1.6507904730136101e-014
|
||||
|
||||
-12.055994987487793
|
||||
12.838775634765625
|
||||
-41.099369049072266
|
||||
|
||||
6.4168906211853027
|
||||
0.38897031545639038
|
||||
-23.586282730102539
|
||||
|
||||
13.051100730895996
|
||||
3.8387587070465088
|
||||
-29.777933120727539
|
||||
|
||||
13.060946464538574
|
||||
3.5910520553588867
|
||||
-29.75908088684082
|
||||
|
||||
14.265764236450195
|
||||
24.096216201782227
|
||||
-54.823970794677734
|
||||
|
||||
-0.25292283296585083
|
||||
2.2166082859039307
|
||||
-21.712127685546875
|
||||
|
||||
7.6465740203857422
|
||||
14.185332298278809
|
||||
-52.070301055908203
|
||||
|
|
@ -67,6 +67,21 @@ string findExampleDataFile(const string& name) {
|
|||
INSTALLED_DATASET_DIR " named\n" +
|
||||
name + ", " + name + ".graph, or " + name + ".txt");
|
||||
}
|
||||
|
||||
string createRewrittenFileName(const string& name) {
|
||||
// Search source tree and installed location
|
||||
if(!exists(fs::path(name))) {
|
||||
throw std::invalid_argument(
|
||||
"gtsam::createRewrittenFileName could not find a matching file in\n"
|
||||
+ name);
|
||||
}
|
||||
|
||||
fs::path p(name);
|
||||
fs::path newpath = fs::path(p.parent_path().string()) / fs::path(p.stem().string() + "-rewritten.txt" );
|
||||
|
||||
printf("New path = %s\n", newpath.string().c_str() );
|
||||
return newpath.string();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace gtsam {
|
|||
/**
|
||||
* Find the full path to an example dataset distributed with gtsam. The name
|
||||
* may be specified with or without a file extension - if no extension is
|
||||
* give, this function first looks for the .graph extension, then .txt. We
|
||||
* given, this function first looks for the .graph extension, then .txt. We
|
||||
* first check the gtsam source tree for the file, followed by the installed
|
||||
* example dataset location. Both the source tree and installed locations
|
||||
* are obtained from CMake during compilation.
|
||||
|
@ -44,6 +44,12 @@ namespace gtsam {
|
|||
* search process described above.
|
||||
*/
|
||||
GTSAM_EXPORT std::string findExampleDataFile(const std::string& name);
|
||||
|
||||
/**
|
||||
* searches for the file using the findExample funtion, if not found ,
|
||||
* creates one in the source tree and returns the full path
|
||||
*/
|
||||
GTSAM_EXPORT std::string createRewrittenFileName(const std::string& name);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -175,7 +175,7 @@ TEST( dataSet, writeG2o)
|
|||
Values expectedValues;
|
||||
readG2o(g2oFile, expectedGraph, expectedValues);
|
||||
|
||||
const string filenameToWrite = findExampleDataFile("pose2example-rewritten");
|
||||
const string filenameToWrite = createRewrittenFileName(g2oFile);
|
||||
writeG2o(filenameToWrite, expectedGraph, expectedValues);
|
||||
|
||||
NonlinearFactorGraph actualGraph;
|
||||
|
@ -249,7 +249,7 @@ TEST( dataSet, writeBAL_Dubrovnik)
|
|||
readBAL(filenameToRead, readData);
|
||||
|
||||
// Write readData to file filenameToWrite
|
||||
const string filenameToWrite = findExampleDataFile("dubrovnik-3-7-pre-rewritten");
|
||||
const string filenameToWrite = createRewrittenFileName(filenameToRead);
|
||||
CHECK(writeBAL(filenameToWrite, readData));
|
||||
|
||||
// Read what we wrote
|
||||
|
@ -311,7 +311,7 @@ TEST( dataSet, writeBALfromValues_Dubrovnik){
|
|||
}
|
||||
|
||||
// Write values and readData to a file
|
||||
const string filenameToWrite = findExampleDataFile("dubrovnik-3-7-pre-rewritten");
|
||||
const string filenameToWrite = createRewrittenFileName(filenameToRead);
|
||||
writeBALfromValues(filenameToWrite, readData, value);
|
||||
|
||||
// Read the file we wrote
|
||||
|
|
Loading…
Reference in New Issue