mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 11:06:04 +08:00
ekf2 replay: some cosmetics
This commit is contained in:
+4
-3
@@ -14,6 +14,10 @@ echo program: $program
|
|||||||
echo model: $model
|
echo model: $model
|
||||||
echo build_path: $build_path
|
echo build_path: $build_path
|
||||||
|
|
||||||
|
mkdir -p $build_path/src/firmware/posix/rootfs/fs/microsd
|
||||||
|
mkdir -p $build_path/src/firmware/posix/rootfs/eeprom
|
||||||
|
touch $build_path/src/firmware/posix/rootfs/eeprom/parameters
|
||||||
|
|
||||||
if [ "$chroot" == "1" ]
|
if [ "$chroot" == "1" ]
|
||||||
then
|
then
|
||||||
chroot_enabled=-c
|
chroot_enabled=-c
|
||||||
@@ -95,9 +99,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd $build_path/src/firmware/posix
|
cd $build_path/src/firmware/posix
|
||||||
mkdir -p rootfs/fs/microsd
|
|
||||||
mkdir -p rootfs/eeprom
|
|
||||||
touch rootfs/eeprom/parameters
|
|
||||||
|
|
||||||
if [ "$logfile" != "" ]
|
if [ "$logfile" != "" ]
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#include <px4_time.h>
|
#include <px4_time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -654,6 +654,11 @@ void Ekf2Replay::setUserParams()
|
|||||||
if (myfile.is_open()) {
|
if (myfile.is_open()) {
|
||||||
while (! myfile.eof()) {
|
while (! myfile.eof()) {
|
||||||
getline(myfile, line);
|
getline(myfile, line);
|
||||||
|
|
||||||
|
if (line.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::istringstream mystrstream(line);
|
std::istringstream mystrstream(line);
|
||||||
mystrstream >> param_name;
|
mystrstream >> param_name;
|
||||||
mystrstream >> value_string;
|
mystrstream >> value_string;
|
||||||
@@ -708,6 +713,26 @@ void Ekf2Replay::task_main()
|
|||||||
// open logfile to write
|
// open logfile to write
|
||||||
_write_fd = ::open(path_to_replay_log, O_WRONLY | O_CREAT, S_IRWXU);
|
_write_fd = ::open(path_to_replay_log, O_WRONLY | O_CREAT, S_IRWXU);
|
||||||
|
|
||||||
|
std::ifstream tmp_file;
|
||||||
|
tmp_file.open("./rootfs/replay_params.txt");
|
||||||
|
|
||||||
|
std::string line;
|
||||||
|
bool set_default_params_in_file = false;
|
||||||
|
|
||||||
|
if (tmp_file.is_open() && ! tmp_file.eof()) {
|
||||||
|
getline(tmp_file, line);
|
||||||
|
|
||||||
|
if (line.empty()) {
|
||||||
|
std::cout << tmp_file;
|
||||||
|
set_default_params_in_file = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_file.close();
|
||||||
|
|
||||||
|
std::ofstream myfile("./rootfs/replay_params.txt", std::ios::app);
|
||||||
|
|
||||||
|
|
||||||
// subscribe to estimator topics
|
// subscribe to estimator topics
|
||||||
_att_sub = orb_subscribe(ORB_ID(vehicle_attitude));
|
_att_sub = orb_subscribe(ORB_ID(vehicle_attitude));
|
||||||
_estimator_status_sub = orb_subscribe(ORB_ID(estimator_status));
|
_estimator_status_sub = orb_subscribe(ORB_ID(estimator_status));
|
||||||
@@ -804,6 +829,16 @@ void Ekf2Replay::task_main()
|
|||||||
param_set(handle, (const void *)¶m_data);
|
param_set(handle, (const void *)¶m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (set_default_params_in_file) {
|
||||||
|
if (strncmp(param_name, "EKF2", 4) == 0) {
|
||||||
|
std::ostringstream os;
|
||||||
|
double value = (double)param_data;
|
||||||
|
os << std::string(param_name) << " ";
|
||||||
|
os << value << "\n";
|
||||||
|
myfile << os.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (header[2] == LOG_VER_MSG) {
|
} else if (header[2] == LOG_VER_MSG) {
|
||||||
// version message
|
// version message
|
||||||
if (::read(fd, &data[0], sizeof(log_VER_s)) != sizeof(log_VER_s)) {
|
if (::read(fd, &data[0], sizeof(log_VER_s)) != sizeof(log_VER_s)) {
|
||||||
@@ -829,6 +864,7 @@ void Ekf2Replay::task_main()
|
|||||||
// the first time we arrive here we should apply the parameters specified in the user file
|
// the first time we arrive here we should apply the parameters specified in the user file
|
||||||
// this makes sure they are applied after the parameter values of the log file
|
// this makes sure they are applied after the parameter values of the log file
|
||||||
if (!set_user_params) {
|
if (!set_user_params) {
|
||||||
|
myfile.close();
|
||||||
setUserParams();
|
setUserParams();
|
||||||
set_user_params = true;
|
set_user_params = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user