-
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.
* Loaded in user specified JSON, Got Values Additionally: -Did fix Anthony said for Magick++.h no such file or directory for Playground and MavlinkClient to get it to make -Some modification in protos which I don't remember touching * Generate default config can't read from one * Generate default config when can't read from one * Put config values into OBC constructor - Changed parameters for OBC constuctor and connectMavlink - Made it so connectMavlink will use config value * pass mavlink_url into connectMavThread account for changes to obc * Made OBCConfig struct Generate struct based on command line input - throw error if file not found - generate default if no filename passed Pass struct into OBC instead of unwrapped configs * fix lint & mavlink url not working * add logging dir to config --------- Co-authored-by: Tyler Lentz <[email protected]>
- Loading branch information
1 parent
1f2a558
commit 2c0b92a
Showing
12 changed files
with
130 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"logging": { | ||
"dir": "/workspaces/obcpp/logs" | ||
}, | ||
"network": { | ||
"mavlink": { | ||
"connect": "serial:///dev/ttyACM0" | ||
}, | ||
"gcs": { | ||
"port": 5010 | ||
} | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"logging": { | ||
"dir": "/workspaces/obcpp/logs" | ||
}, | ||
"network": { | ||
"gcs": { | ||
"port": 5010 | ||
}, | ||
"mavlink": { | ||
"connect": "tcp://172.17.0.1:5760" | ||
} | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"logging": { | ||
"dir": "/workspaces/obcpp/logs" | ||
}, | ||
"network": { | ||
"mavlink": { | ||
"connect": "tcp://172.17.0.1:5760" | ||
}, | ||
"gcs": { | ||
"port": 5010 | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef INCLUDE_UTILITIES_OBC_CONFIG_HPP_ | ||
#define INCLUDE_UTILITIES_OBC_CONFIG_HPP_ | ||
|
||
#include <string> | ||
|
||
struct OBCConfig { | ||
std::string logging_dir; | ||
|
||
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_ |
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,6 +4,7 @@ SET(FILES | |
common.cpp | ||
datatypes.cpp | ||
logging.cpp | ||
obc_config.cpp | ||
rng.cpp | ||
) | ||
|
||
|
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,44 @@ | ||
#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->logging_dir = configs["logging"]["dir"]; | ||
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->logging_dir = "/workspaces/obcpp/logs"; | ||
this->network_mavlink_connect = "tcp://172.17.0.1:5760"; | ||
this->network_gcs_port = 5010; | ||
|
||
// Create default configs | ||
json configs; | ||
configs["logging"]["dir"] = this->logging_dir; | ||
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 | ||
} |