openpilot v0.6.3 release

old-commit-hash: d5f9caa82d
This commit is contained in:
Vehicle Researcher
2019-08-13 01:36:45 +00:00
parent eb89041a6a
commit 02cedeadd9
95 changed files with 1754 additions and 625 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ void slplay_destroy() {
(*engine)->Destroy(engine);
}
void slplay_stop (uri_player* player, char **error) {
void slplay_stop(uri_player* player, char **error) {
SLPlayItf playInterface = player->playInterface;
SLresult result;
+1 -1
View File
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:11953df252f1cd63d7cd2101508b89c96f5de073b3181c4262f1a26d3c871ca1
oid sha256:7a4f45d19c1d85792e4c48a60f7d9beb0264ce187ff5edccf8532fda37fe831d
size 239976
+1 -1
View File
@@ -35,7 +35,7 @@ int main(int argc, char** argv) {
NVGcontext *vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
assert(vg);
int font = nvgCreateFont(vg, "Bold", "../../assets/OpenSans-SemiBold.ttf");
int font = nvgCreateFont(vg, "Bold", "../../assets/fonts/opensans_semibold.ttf");
assert(font >= 0);
int spinner_img = nvgCreateImage(vg, "../../assets/img_spinner_track.png", 0);
+53 -35
View File
@@ -107,6 +107,8 @@ const mat3 intrinsic_matrix = (mat3){{
0., 0., 1.
}};
typedef enum cereal_CarControl_HUDControl_AudibleAlert AudibleAlert;
typedef struct UIScene {
int frontview;
int fullview;
@@ -161,8 +163,6 @@ typedef struct UIScene {
// Used to show gps planner status
bool gps_planner_active;
bool is_playing_alert;
} UIScene;
typedef struct {
@@ -253,6 +253,7 @@ typedef struct UIState {
int awake_timeout;
int volume_timeout;
int alert_sound_timeout;
int speed_lim_off_timeout;
int is_metric_timeout;
int longitudinal_control_timeout;
@@ -265,7 +266,7 @@ typedef struct UIState {
float speed_lim_off;
bool is_ego_over_limit;
char alert_type[64];
char alert_sound[64];
AudibleAlert alert_sound;
int alert_size;
float alert_blinking_alpha;
bool alert_blinked;
@@ -431,25 +432,25 @@ static const mat4 full_to_wide_frame_transform = {{
}};
typedef struct {
const char* name;
AudibleAlert alert;
const char* uri;
bool loop;
} sound_file;
sound_file sound_table[] = {
{ "chimeDisengage", "../assets/sounds/disengaged.wav", false },
{ "chimeEngage", "../assets/sounds/engaged.wav", false },
{ "chimeWarning1", "../assets/sounds/warning_1.wav", false },
{ "chimeWarning2", "../assets/sounds/warning_2.wav", false },
{ "chimeWarningRepeat", "../assets/sounds/warning_2.wav", true },
{ "chimeError", "../assets/sounds/error.wav", false },
{ "chimePrompt", "../assets/sounds/error.wav", false },
{ NULL, NULL, false },
{ cereal_CarControl_HUDControl_AudibleAlert_chimeDisengage, "../assets/sounds/disengaged.wav", false },
{ cereal_CarControl_HUDControl_AudibleAlert_chimeEngage, "../assets/sounds/engaged.wav", false },
{ cereal_CarControl_HUDControl_AudibleAlert_chimeWarning1, "../assets/sounds/warning_1.wav", false },
{ cereal_CarControl_HUDControl_AudibleAlert_chimeWarning2, "../assets/sounds/warning_2.wav", false },
{ cereal_CarControl_HUDControl_AudibleAlert_chimeWarningRepeat, "../assets/sounds/warning_2.wav", true },
{ cereal_CarControl_HUDControl_AudibleAlert_chimeError, "../assets/sounds/error.wav", false },
{ cereal_CarControl_HUDControl_AudibleAlert_chimePrompt, "../assets/sounds/error.wav", false },
{ cereal_CarControl_HUDControl_AudibleAlert_none, NULL, false },
};
sound_file* get_sound_file_by_name(const char* name) {
for (sound_file *s = sound_table; s->name != NULL; s++) {
if (strcmp(s->name, name) == 0) {
sound_file* get_sound_file(AudibleAlert alert) {
for (sound_file *s = sound_table; s->alert != cereal_CarControl_HUDControl_AudibleAlert_none; s++) {
if (s->alert == alert) {
return s;
}
}
@@ -462,7 +463,7 @@ void ui_sound_init(char **error) {
slplay_setup(error);
if (*error) return;
for (sound_file *s = sound_table; s->name != NULL; s++) {
for (sound_file *s = sound_table; s->alert != cereal_CarControl_HUDControl_AudibleAlert_none; s++) {
slplay_create_player_for_uri(s->uri, error);
if (*error) return;
}
@@ -502,13 +503,13 @@ static void ui_init(UIState *s) {
s->vg = nvgCreateGLES3(NVG_ANTIALIAS | NVG_STENCIL_STROKES | NVG_DEBUG);
assert(s->vg);
s->font_courbd = nvgCreateFont(s->vg, "courbd", "../assets/courbd.ttf");
s->font_courbd = nvgCreateFont(s->vg, "courbd", "../assets/fonts/courbd.ttf");
assert(s->font_courbd >= 0);
s->font_sans_regular = nvgCreateFont(s->vg, "sans-regular", "../assets/OpenSans-Regular.ttf");
s->font_sans_regular = nvgCreateFont(s->vg, "sans-regular", "../assets/fonts/opensans_regular.ttf");
assert(s->font_sans_regular >= 0);
s->font_sans_semibold = nvgCreateFont(s->vg, "sans-semibold", "../assets/OpenSans-SemiBold.ttf");
s->font_sans_semibold = nvgCreateFont(s->vg, "sans-semibold", "../assets/fonts/opensans_semibold.ttf");
assert(s->font_sans_semibold >= 0);
s->font_sans_bold = nvgCreateFont(s->vg, "sans-bold", "../assets/OpenSans-Bold.ttf");
s->font_sans_bold = nvgCreateFont(s->vg, "sans-bold", "../assets/fonts/opensans_bold.ttf");
assert(s->font_sans_bold >= 0);
assert(s->img_wheel >= 0);
@@ -1218,8 +1219,8 @@ static void ui_draw_vision_speedlimit(UIState *s) {
if (is_speedlim_valid && s->is_ego_over_limit) {
nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255));
}
nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 50 : 45), "SPEED", NULL);
nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 90 : 85), "LIMIT", NULL);
nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 50 : 45), "SMART", NULL);
nvgText(s->vg, viz_speedlim_x+viz_speedlim_w/2 + (is_speedlim_valid ? 6 : 0), viz_speedlim_y + (is_speedlim_valid ? 90 : 85), "SPEED", NULL);
// Draw Speed Text
nvgFontFace(s->vg, "sans-bold");
@@ -1414,7 +1415,7 @@ static void ui_draw_vision_footer(UIState *s) {
ui_draw_vision_face(s);
#ifdef SHOW_SPEEDLIMIT
ui_draw_vision_map(s);
// ui_draw_vision_map(s);
#endif
}
@@ -1633,26 +1634,28 @@ void handle_message(UIState *s, void *which) {
s->scene.decel_for_model = datad.decelForModel;
if (datad.alertSound.str && datad.alertSound.str[0] != '\0' && strcmp(s->alert_type, datad.alertType.str) != 0) {
s->alert_sound_timeout = 1 * UI_FREQ;
if (datad.alertSound != cereal_CarControl_HUDControl_AudibleAlert_none && datad.alertSound != s->alert_sound) {
char* error = NULL;
if (s->alert_sound[0] != '\0') {
sound_file* active_sound = get_sound_file_by_name(s->alert_sound);
if (s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) {
sound_file* active_sound = get_sound_file(s->alert_sound);
slplay_stop_uri(active_sound->uri, &error);
if (error) {
LOGW("error stopping active sound %s", error);
}
}
sound_file* sound = get_sound_file_by_name(datad.alertSound.str);
sound_file* sound = get_sound_file(datad.alertSound);
slplay_play(sound->uri, sound->loop, &error);
if(error) {
LOGW("error playing sound: %s", error);
}
snprintf(s->alert_sound, sizeof(s->alert_sound), "%s", datad.alertSound.str);
s->alert_sound = datad.alertSound;
snprintf(s->alert_type, sizeof(s->alert_type), "%s", datad.alertType.str);
} else if ((!datad.alertSound.str || datad.alertSound.str[0] == '\0') && s->alert_sound[0] != '\0') {
sound_file* sound = get_sound_file_by_name(s->alert_sound);
} else if ((!datad.alertSound || datad.alertSound == cereal_CarControl_HUDControl_AudibleAlert_none) && s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none) {
sound_file* sound = get_sound_file(s->alert_sound);
char* error = NULL;
@@ -1661,7 +1664,7 @@ void handle_message(UIState *s, void *which) {
LOGW("error stopping sound: %s", error);
}
s->alert_type[0] = '\0';
s->alert_sound[0] = '\0';
s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none;
}
if (datad.alertText1.str) {
@@ -1798,8 +1801,6 @@ void handle_message(UIState *s, void *which) {
} else if (eventd.which == cereal_Event_liveMapData) {
struct cereal_LiveMapData datad;
cereal_read_LiveMapData(&datad, eventd.liveMapData);
s->scene.speedlimit = datad.speedLimit;
s->scene.speedlimit_valid = datad.speedLimitValid;
s->scene.map_valid = datad.mapValid;
}
capn_free(&ctx);
@@ -2230,7 +2231,10 @@ int main(int argc, char* argv[]) {
float smooth_brightness = BRIGHTNESS_B;
set_volume(s, 13);
const int MIN_VOLUME = LEON ? 12 : 8;
const int MAX_VOLUME = LEON ? 15 : 13;
set_volume(s, MIN_VOLUME);
#ifdef DEBUG_FPS
vipc_t1 = millis_since_boot();
double t1 = millis_since_boot();
@@ -2304,10 +2308,24 @@ int main(int argc, char* argv[]) {
if (s->volume_timeout > 0) {
s->volume_timeout--;
} else {
int volume = min(13, 11 + s->scene.v_ego / 15); // up one notch every 15 m/s, starting at 11
int volume = min(MAX_VOLUME, MIN_VOLUME + s->scene.v_ego / 5); // up one notch every 5 m/s
set_volume(s, volume);
}
// stop playing alert sounds if no controlsState msg for 1 second
if (s->alert_sound_timeout > 0) {
s->alert_sound_timeout--;
} else if (s->alert_sound != cereal_CarControl_HUDControl_AudibleAlert_none){
sound_file* sound = get_sound_file(s->alert_sound);
char* error = NULL;
slplay_stop_uri(sound->uri, &error);
if(error) {
LOGW("error stopping sound: %s", error);
}
s->alert_sound = cereal_CarControl_HUDControl_AudibleAlert_none;
}
read_param_bool_timeout(&s->is_metric, "IsMetric", &s->is_metric_timeout);
read_param_bool_timeout(&s->longitudinal_control, "LongitudinalControl", &s->longitudinal_control_timeout);
read_param_bool_timeout(&s->limit_set_speed, "LimitSetSpeed", &s->limit_set_speed_timeout);