-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c853223
commit 33ad4dd
Showing
12 changed files
with
77 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef INCLUDE_UTILITIES_OBC_CONFIG_HPP_ | ||
#define INCLUDE_UTILITIES_OBC_CONFIG_HPP_ | ||
|
||
#include <string> | ||
|
||
struct OBCConfig { | ||
std::string network_mavlink_connect; | ||
int network_gcs_port; | ||
|
||
// Load user specified config json, or make a new one | ||
OBCConfig(int argc, char* argv[]); | ||
|
||
private: | ||
const std::string configsPath = "/workspaces/obcpp/configs/"; | ||
|
||
void makeDefault(); | ||
}; | ||
|
||
#endif // INCLUDE_UTILITIES_OBC_CONFIG_HPP_ |
Submodule protos
updated
4 files
+4 −4 | .gitignore | |
+1 −1 | README.md | |
+35 −35 | houston.proto | |
+89 −79 | obc.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ SET(FILES | |
common.cpp | ||
datatypes.cpp | ||
logging.cpp | ||
OBCConfig.cpp | ||
obc_config.cpp | ||
rng.cpp | ||
) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "utilities/obc_config.hpp" | ||
|
||
#include <fstream> | ||
#include <stdexcept> | ||
#include <string> | ||
|
||
#include "nlohmann/json.hpp" | ||
|
||
using json = nlohmann::json; | ||
|
||
|
||
OBCConfig::OBCConfig(int argc, char* argv[]) { | ||
// If config-json name is passed in | ||
if (argc > 1) { | ||
// Load in json file | ||
std::ifstream configStream(configsPath + std::string(argv[1])); | ||
if (!configStream.is_open()) { | ||
throw std::invalid_argument("Invalid config-json name"); | ||
} | ||
json configs = json::parse(configStream); | ||
|
||
// Set configs | ||
this->network_mavlink_connect = configs["network"]["mavlink"]["connect"]; | ||
this->network_gcs_port = configs["network"]["gcs"]["port"]; | ||
} else { | ||
makeDefault(); // Detect if there is already a default-config.json? | ||
} | ||
} | ||
|
||
void OBCConfig::makeDefault() { | ||
// Set configs | ||
this->network_mavlink_connect = "tcp://172.17.0.1:5760"; | ||
this->network_gcs_port = 5010; | ||
|
||
// Create default configs | ||
json configs; | ||
configs["network"]["mavlink"]["connect"] = this->network_mavlink_connect; | ||
configs["network"]["gcs"]["port"] = this->network_gcs_port; | ||
std::ofstream configFile(configsPath + "default-config.json"); | ||
configFile << configs.dump(4); // Dump to file with 4 space indents | ||
} |