mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-03 08:41:47 +08:00
f70a79b838
* use cstring instead of string.h
* use cstdio instead of stdio.h
* remove inttypes.h
* use cstdlib instead of stdlib.h
* use cstdint instead of stdint.h
* #include <cstddef>
* cstdlib
* use cmath
* remove stddef.h
* use cassert
* use csignal
* use ctime
* use cerror
* rebase master
old-commit-hash: c53cb5d570
43 lines
987 B
C++
43 lines
987 B
C++
#include "selfdrive/modeld/runners/thneedmodel.h"
|
|
|
|
#include <cassert>
|
|
|
|
ThneedModel::ThneedModel(const char *path, float *loutput, size_t loutput_size, int runtime) {
|
|
thneed = new Thneed(true);
|
|
thneed->record = 0;
|
|
thneed->load(path);
|
|
thneed->clexec();
|
|
thneed->find_inputs_outputs();
|
|
|
|
recorded = false;
|
|
output = loutput;
|
|
}
|
|
|
|
void ThneedModel::addRecurrent(float *state, int state_size) {
|
|
recurrent = state;
|
|
}
|
|
|
|
void ThneedModel::addTrafficConvention(float *state, int state_size) {
|
|
trafficConvention = state;
|
|
}
|
|
|
|
void ThneedModel::addDesire(float *state, int state_size) {
|
|
desire = state;
|
|
}
|
|
|
|
void ThneedModel::execute(float *net_input_buf, int buf_size) {
|
|
float *inputs[4] = {recurrent, trafficConvention, desire, net_input_buf};
|
|
if (!recorded) {
|
|
thneed->record = THNEED_RECORD;
|
|
thneed->copy_inputs(inputs);
|
|
thneed->clexec();
|
|
thneed->copy_output(output);
|
|
thneed->stop();
|
|
|
|
recorded = true;
|
|
} else {
|
|
thneed->execute(inputs, output);
|
|
}
|
|
}
|
|
|