FrogPilot base

This commit is contained in:
James
2025-12-01 12:00:00 -07:00
parent 4726bdce29
commit 41bf1bd2cb
144 changed files with 1254 additions and 39 deletions
+2
View File
@@ -19,5 +19,7 @@ class CV:
# Mass
LB_TO_KG = 0.453592
# FrogPilot variables
ACCELERATION_DUE_TO_GRAVITY = 9.81 # m/s^2
+9
View File
@@ -94,6 +94,8 @@ private:
Params::Params(const std::string &path) {
params_prefix = "/" + util::getenv("OPENPILOT_PREFIX", "d");
params_path = ensure_params_path(params_prefix, path);
// FrogPilot variables
}
Params::~Params() {
@@ -169,6 +171,9 @@ int Params::put(const char* key, const char* value, size_t value_size) {
int Params::remove(const std::string &key) {
FileLock file_lock(params_path + "/.lock");
int result = unlink(getParamPath(key).c_str());
// FrogPilot variables
if (result != 0) {
return result;
}
@@ -215,6 +220,8 @@ void Params::clearAll(ParamKeyFlag key_flag) {
auto it = keys.find(de->d_name);
if (it == keys.end() || (it->second.flags & key_flag)) {
unlink(getParamPath(de->d_name).c_str());
// FrogPilot variables
}
}
}
@@ -240,3 +247,5 @@ void Params::asyncWriteThread() {
put(p.first, p.second);
}
}
// FrogPilot variables
+6
View File
@@ -35,6 +35,8 @@ struct ParamKeyAttributes {
uint32_t flags;
ParamKeyType type;
std::optional<std::string> default_value = std::nullopt;
// FrogPilot variables
};
class Params {
@@ -78,6 +80,8 @@ public:
putNonBlocking(key, val ? "1" : "0");
}
// FrogPilot variables
private:
void asyncWriteThread();
@@ -87,4 +91,6 @@ private:
// for nonblocking write
std::future<void> future;
SafeQueue<std::pair<std::string, std::string>> queue;
// FrogPilot variables
};
+2
View File
@@ -131,4 +131,6 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"UptimeOffroad", {PERSISTENT, FLOAT, "0.0"}},
{"UptimeOnroad", {PERSISTENT, FLOAT, "0.0"}},
{"Version", {PERSISTENT, STRING}},
// FrogPilot variables
};
+11
View File
@@ -45,6 +45,8 @@ cdef extern from "common/params.h":
void clearAll(ParamKeyFlag)
vector[string] allKeys()
# FrogPilot variables
PYTHON_2_CPP = {
(str, STRING): lambda v: v,
(builtins.bool, BOOL): lambda v: "1" if v else "0",
@@ -75,12 +77,19 @@ cdef class Params:
cdef c_Params* p
cdef str d
# FrogPilot variables
def __cinit__(self, d=""):
cdef string path = <string>d.encode()
# FrogPilot variables
with nogil:
self.p = new c_Params(path)
self.d = d
# FrogPilot variables
def __reduce__(self):
return (type(self), (self.d,))
@@ -194,3 +203,5 @@ cdef class Params:
cdef string k = self.check_key(key)
cdef ParamKeyType t = self.p.getKeyType(k)
return self._cpp2python(t, value, None, key)
# FrogPilot variables
+2
View File
@@ -37,6 +37,8 @@ const double MS_TO_MPH = MS_TO_KPH * KM_TO_MILE;
const double METER_TO_MILE = KM_TO_MILE / 1000.0;
const double METER_TO_FOOT = 3.28084;
// FrogPilot variables
#define ALIGNED_SIZE(x, align) (((x) + (align)-1) & ~((align)-1))
namespace util {