mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-24 00:03:45 +08:00
89b03fa2ee
* template funcion fill_meta
* add function get_plan_max_idx
* add function get_mdn_max_idx
* remove temp builder variables
* get_mdn_max_idx->get_lead_data
* get_pan_max_idx->get_plan_data
* fill_lane_line
* combine fill_lane_line&fill_path into one function
* fill_lead_vw
* using unique_ptr
* prefer using constexpr
* more constexpr,remove duplicate defined TRAJECTORY_SIZE
* remove suffix _arr from variable name
* misc
* remove extern c
* refactor model_publish
* remove unused paramaters
* traffic_convention to c style array
* c style array:prev_desire&pulse_desire
* fix error&make easy for review
* const mat3 &transform
* move cl_command_queue into ModelState
* use maco LEAD_MHP_SELECTION
* move constexpr from .h to .cc
* remove #define MODEL_NAME
* modeldata.h: contexpr
* remove param temporal from model_init
* helper function get_best_data
* fix probs
* int
Co-authored-by: deanlee <deanlee3@gmail.com>
old-commit-hash: 630c7309a5
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#pragma once
|
|
|
|
// gate this here
|
|
#define TEMPORAL
|
|
#define DESIRE
|
|
#define TRAFFIC_CONVENTION
|
|
|
|
#include "common/mat.h"
|
|
#include "common/util.h"
|
|
#include "common/modeldata.h"
|
|
|
|
#include "commonmodel.h"
|
|
#include "runners/run.h"
|
|
|
|
#include <memory>
|
|
#include "messaging.hpp"
|
|
|
|
constexpr int DESIRE_LEN = 8;
|
|
constexpr int TRAFFIC_CONVENTION_LEN = 2;
|
|
constexpr int MODEL_FREQ = 20;
|
|
struct ModelDataRaw {
|
|
float *plan;
|
|
float *lane_lines;
|
|
float *lane_lines_prob;
|
|
float *road_edges;
|
|
float *lead;
|
|
float *lead_prob;
|
|
float *desire_state;
|
|
float *meta;
|
|
float *desire_pred;
|
|
float *pose;
|
|
};
|
|
|
|
|
|
typedef struct ModelState {
|
|
ModelFrame frame;
|
|
std::unique_ptr<float[]> output;
|
|
std::unique_ptr<float[]> input_frames;
|
|
std::unique_ptr<RunModel> m;
|
|
cl_command_queue q;
|
|
#ifdef DESIRE
|
|
float prev_desire[DESIRE_LEN] = {};
|
|
float pulse_desire[DESIRE_LEN] = {};
|
|
#endif
|
|
#ifdef TRAFFIC_CONVENTION
|
|
float traffic_convention[TRAFFIC_CONVENTION_LEN] = {};
|
|
#endif
|
|
} ModelState;
|
|
|
|
void model_init(ModelState* s, cl_device_id device_id, cl_context context);
|
|
ModelDataRaw model_eval_frame(ModelState* s, cl_mem yuv_cl, int width, int height,
|
|
const mat3 &transform, float *desire_in);
|
|
void model_free(ModelState* s);
|
|
void poly_fit(float *in_pts, float *in_stds, float *out);
|
|
void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id, float frame_drop,
|
|
const ModelDataRaw &net_outputs, const float *raw_pred, uint64_t timestamp_eof,
|
|
float model_execution_time);
|
|
void posenet_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t vipc_dropped_frames,
|
|
const ModelDataRaw &net_outputs, uint64_t timestamp_eof);
|