Skip to content

Commit 1fb1212

Browse files
author
Aaron Roller
authored
Merge pull request #7 from AutoModality/AM-367/user-config
Finding UserConfig.txt in installation dir
2 parents 7391264 + c7e5551 commit 1fb1212

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ debian/ros-melodic-am-osdk-ros*
1111
debian/ros-melodic-dji-onboard-sdk-ros.debhelper.log
1212
ros-melodic-dji-onboard-sdk-build-deps_*_all.deb
1313
build
14+
catkin_ws
15+
.vscode
16+

include/dji_sdk_obsoleted/dji_linux_environment.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class DJI_Environment
4343
~DJI_Environment();
4444

4545
static std::string findFile(std::string file);
46+
/**
47+
* @return a string of the path to a file, if found. Empty otherwise.
48+
*/
49+
static std::string findFileInDir(std::string file, std::string dir);
50+
4651
int getApp_id() const;
4752
const std::string& getEnc_key() const;
4853
const std::string& getDevice() const;

src/dji_sdk_obsoleted/dji_linux_environment.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,17 @@ DJI_Environment::findFile(std::string file)
5252
throw std::runtime_error("Error getting current directory");
5353

5454
std::string strCWD(cwd);
55-
// configFile = strCWD + "/osdk-core/" + file;
56-
configFile = strCWD + "/" + file; // just in the current working directory
55+
return findFileInDir(file,strCWD);
56+
}
57+
58+
59+
/**
60+
* @return a string of the path to a file, if found. Empty otherwise.
61+
*/
62+
std::string
63+
DJI_Environment::findFileInDir(std::string file, std::string dir)
64+
{
65+
std::string configFile = dir + "/" + file;
5766

5867
std::ifstream fStream(configFile.c_str());
5968

src/dji_sdk_obsoleted/dji_linux_helpers.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,15 @@ LinuxSetup::setupEnvironment(int argc, char** argv)
170170
}
171171
else
172172
{
173-
config_file_path = DJI_Environment::findFile("UserConfig.txt");
174-
173+
std::string config_filename = "UserConfig.txt";
174+
config_file_path = DJI_Environment::findFile(config_filename);
175+
176+
//look in installation dir if not found in expected places
177+
if(config_file_path.empty()){
178+
//FIXME: find a better place to declare this without ros distro (melodic)
179+
std::string installationDir = "/opt/ros/melodic/share/dji_sdk/launch";
180+
config_file_path = DJI_Environment::findFileInDir(config_filename,installationDir);
181+
}
175182
if (config_file_path.empty())
176183
throw std::runtime_error("User configuration file not found");
177184
}

0 commit comments

Comments
 (0)