Skip to content

Commit

Permalink
Fix commIssue due to frame drop and power draw (commaai#2689)
Browse files Browse the repository at this point in the history
Co-authored-by: robbederks <[email protected]>
Co-authored-by: Willem Melching <[email protected]>
  • Loading branch information
3 people committed Dec 4, 2020
1 parent 0b384ea commit 29d9e1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 6 additions & 1 deletion panda/board/boards/uno.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ void uno_set_gps_load_switch(bool enabled) {
}

void uno_set_bootkick(bool enabled){
set_gpio_output(GPIOB, 14, !enabled);
if(enabled){
set_gpio_output(GPIOB, 14, false);
} else {
// We want the pin to be floating, not forced high!
set_gpio_mode(GPIOB, 14, MODE_INPUT);
}
}

void uno_bootkick(void) {
Expand Down
8 changes: 4 additions & 4 deletions selfdrive/modeld/models/driving.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ void model_publish_v2(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id,
float model_execution_time) {
// make msg
MessageBuilder msg;
auto framed = msg.initEvent(frame_drop < MAX_FRAME_DROP).initModelV2();
auto framed = msg.initEvent().initModelV2();
uint32_t frame_age = (frame_id > vipc_frame_id) ? (frame_id - vipc_frame_id) : 0;
framed.setFrameId(vipc_frame_id);
framed.setFrameAge(frame_age);
framed.setFrameDropPerc(frame_drop * 100);
framed.setTimestampEof(timestamp_eof);
framed.setModelExecutionTime(model_execution_time);

// plan
// plan
int plan_mhp_max_idx = 0;
for (int i=1; i<PLAN_MHP_N; i++) {
if (net_outputs.plan[(i + 1)*(PLAN_MHP_GROUP_SIZE) - 1] >
Expand Down Expand Up @@ -393,7 +393,7 @@ void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id,

uint32_t frame_age = (frame_id > vipc_frame_id) ? (frame_id - vipc_frame_id) : 0;
MessageBuilder msg;
auto framed = msg.initEvent(frame_drop < MAX_FRAME_DROP).initModel();
auto framed = msg.initEvent().initModel();
framed.setFrameId(vipc_frame_id);
framed.setFrameAge(frame_age);
framed.setFrameDropPerc(frame_drop * 100);
Expand Down Expand Up @@ -429,7 +429,7 @@ void model_publish(PubMaster &pm, uint32_t vipc_frame_id, uint32_t frame_id,

auto lpath = framed.initPath();
fill_path(lpath, &net_outputs.plan[plan_mhp_max_idx*(PLAN_MHP_GROUP_SIZE)], valid_len, valid_len_idx);

auto left_lane = framed.initLeftLane();
int ll_idx = 1;
fill_lane_line(left_lane, net_outputs.lane_lines, ll_idx, valid_len, valid_len_idx,
Expand Down
1 change: 0 additions & 1 deletion selfdrive/modeld/models/driving.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#define POSE_SIZE 12

#define MODEL_FREQ 20
#define MAX_FRAME_DROP 0.05

struct ModelDataRaw {
float *plan;
Expand Down

0 comments on commit 29d9e1c

Please sign in to comment.