helsinkiAUV / auv

Software for the Autonomous Underwater Vehicle developed by the University of Helsinki physics students.
GNU General Public License v3.0
1 stars 0 forks source link

Modify the atlanticSimulator to read a configuration file #19

Open helsinkiAUV opened 8 years ago

helsinkiAUV commented 8 years ago

Make the atlanticSimulator to read the following values from a config file:

    std::ifstream inputFile("../../raspiMain/route/routeAtlantic.csv"); // File names.
    std::string outputName = "../../raspiMain/route/routeAtlantic_simOut.csv";

    double boatSpeed = 0.8; // Speed of boat in m/s.
    double driftSpeed = 0.15; // Speed of unwanted drift [m/s] into the direction of wind.
    double windDir = 45; // DEGREES where the wind is blowing.
    double GpsAccuracy = 5; // Meters
    double writeInterval = 3600; // Seconds.

    int numAver = 5; // Number of GPS averaging points.

You may choose the best design for the config file. However, Keep It Simple! No XML files or such.

shamaanikala commented 8 years ago

I did a quick and dirty code for this. Check it out from my branch. Also the desired configuration file format should be decided.

helsinkiAUV commented 8 years ago

I checked it out and it seems quite good.

Line 95 of atlanticSimulator.cpp is an excellent example of how you'll learn something new every time you have to deal with a language as monstrous as C++. For almost ten years have I programmed in C-based languages not knowing that you can shadow a variable of an outer scope by declaring a new variable with the same name in an inner scope!

However, in this case I think it could be a bug, since now the declaration (line 95) is thrown into bit space and the inputFile remains unchanged.

Also, I think it could be considered an error if "nameString" is not in the list of configuration options.

What do you think of these suggestions, mr. shamaanikala?

-Juho

shamaanikala commented 8 years ago

However, in this case I think it could be a bug, since now the declaration (line 95) is thrown into bit space and the inputFile remains unchanged.

I just realized that I didn't test this at all. Ofcourse everything seems to be fine when the config file is exact copy of the hard coded values...

Also, I think it could be considered an error if "nameString" is not in the list of configuration options.

I was thinking about that too, but didn't do anything yet. I'll implement this too. I wonder if there exist a nice way to parse values from config files.

What should be obligatory and optional config parameters? Also if some parameter is optional, what would be the default value for it?

helsinkiAUV commented 8 years ago

I think at this point only the input and output file names should be obligatory. The rest can have the above values.