static void cam_thumb_free (Renderer *renderer) { RendererCamThumb *self = (RendererCamThumb*) renderer; g_hash_table_destroy (self->cam_handlers); globals_release_config (self->config); globals_release_ctrans (self->ctrans); globals_release_lcm (self->lc); free (renderer); }
Renderer *renderer_scrolling_plots_new (Viewer *viewer) { RendererScrollingPlots *self = (RendererScrollingPlots*) calloc (1, sizeof (RendererScrollingPlots)); self->viewer = viewer; self->renderer.draw = scrolling_plots_draw; self->renderer.destroy = scrolling_plots_free; self->renderer.name = "Scrolling Plots"; self->renderer.user = self; self->renderer.enabled = 1; self->renderer.widget = gtk_alignment_new (0, 0.5, 1.0, 0); self->atrans = globals_get_atrans(); self->lcm = globals_get_lcm (); self->pw = BOT_GTK_PARAM_WIDGET (bot_gtk_param_widget_new ()); gtk_container_add (GTK_CONTAINER (self->renderer.widget), GTK_WIDGET(self->pw)); gtk_widget_show (GTK_WIDGET (self->pw)); bot_gtk_param_widget_add_int (self->pw, PARAM_NAME_SIZE, BOT_GTK_PARAM_WIDGET_SLIDER, 50, 800, 10, 150); bot_gtk_param_widget_add_double (self->pw, PARAM_NAME_GRAPH_TIMESPAN, BOT_GTK_PARAM_WIDGET_SLIDER, 1, 20, 0.5, 5); bot_gtk_param_widget_add_booleans (self->pw, BOT_GTK_PARAM_WIDGET_TOGGLE_BUTTON, PARAM_NAME_FREEZE, 0, NULL); bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_NAME_RENDER_NAVIGATOR_ROTATION, 1, PARAM_NAME_RENDER_NAVIGATOR_TRANSLATION, 1, NULL); bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_NAME_RENDER_ENCODER_LEFT, 1, PARAM_NAME_RENDER_ENCODER_RIGHT, 1, NULL); bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_NAME_SHOW_LEGEND, 0, NULL); g_signal_connect (G_OBJECT (self->pw), "changed", G_CALLBACK (on_param_widget_changed), self); BotConf *config = globals_get_config (); self->encoder_left_scale = 1.0;//bot_conf_get_double_or_fail (config, "calibration.encoders.WHEEL_LEFT.scale"); self->encoder_right_scale = 1.0;//bot_conf_get_double_or_fail (config, "calibration.encoders.WHEEL_RIGHT.scale"); globals_release_config (config); self->encoder_left_last = 0; self->encoder_right_last = 0; // navigator rotation self->navigator_rotation_plot = bot_gl_scrollplot2d_new (); bot_gl_scrollplot2d_set_title (self->navigator_rotation_plot, "Nav. Rot. Speed"); bot_gl_scrollplot2d_set_text_color (self->navigator_rotation_plot, 0.7, 0.7, 0.7, 1); bot_gl_scrollplot2d_set_bgcolor (self->navigator_rotation_plot, 0.1, 0.1, 0.1, 0.7); bot_gl_scrollplot2d_set_border_color (self->navigator_rotation_plot, 1, 1, 1, 0.7); bot_gl_scrollplot2d_set_ylim (self->navigator_rotation_plot, -.5, .5); bot_gl_scrollplot2d_add_plot (self->navigator_rotation_plot, "control", 1000); bot_gl_scrollplot2d_set_color (self->navigator_rotation_plot, "control", 0.7, 0, 0.7, 1); bot_gl_scrollplot2d_add_plot (self->navigator_rotation_plot, "status", 1000); bot_gl_scrollplot2d_set_color (self->navigator_rotation_plot, "status", 0, 0, 1, 1); //bot_gl_scrollplot2d_add_plot (self->navigator_rotation_plot, "2500", 1000); //bot_gl_scrollplot2d_set_color (self->navigator_rotation_plot, "2500", 0.8, 0.8, 0.8, 0.5); self->navigator_translation_plot = bot_gl_scrollplot2d_new (); bot_gl_scrollplot2d_set_title (self->navigator_translation_plot, "Nav. Trans. Speed"); bot_gl_scrollplot2d_set_text_color (self->navigator_translation_plot, 0.7, 0.7, 0.7, 1); bot_gl_scrollplot2d_set_bgcolor (self->navigator_translation_plot, 0.1, 0.1, 0.1, 0.7); bot_gl_scrollplot2d_set_border_color (self->navigator_translation_plot, 1, 1, 1, 0.7); bot_gl_scrollplot2d_set_ylim (self->navigator_translation_plot, 0, 2.0); bot_gl_scrollplot2d_add_plot (self->navigator_translation_plot, "control", 1000); bot_gl_scrollplot2d_set_color (self->navigator_translation_plot, "control", 0.7, 0, 0.7, 1); bot_gl_scrollplot2d_add_plot (self->navigator_translation_plot, "status", 1000); bot_gl_scrollplot2d_set_color (self->navigator_translation_plot, "status", 0, 0, 1, 1); // left wheel encoder plot self->encoder_left_plot = bot_gl_scrollplot2d_new (); bot_gl_scrollplot2d_set_title (self->encoder_left_plot, "Left Encoder"); bot_gl_scrollplot2d_set_text_color (self->encoder_left_plot, 0.7, 0.7, 0.7, 1); bot_gl_scrollplot2d_set_border_color (self->encoder_left_plot, 1, 1, 1, 0.7); bot_gl_scrollplot2d_set_bgcolor (self->encoder_left_plot, 0.1, 0.1, 0.1, 0.7); bot_gl_scrollplot2d_set_ylim (self->encoder_left_plot, 0, 2.0); bot_gl_scrollplot2d_add_plot (self->encoder_left_plot, "actual", 1000); bot_gl_scrollplot2d_set_color (self->encoder_left_plot, "actual", 0.7, 0, 0.7, 1); bot_gl_scrollplot2d_add_plot (self->encoder_left_plot, "0", 1000); bot_gl_scrollplot2d_set_color (self->encoder_left_plot, "0", 0.8, 0.8, 0.8, 0.5); // right wheel encoder plot self->encoder_right_plot = bot_gl_scrollplot2d_new (); bot_gl_scrollplot2d_set_title (self->encoder_right_plot, "Right Encoder"); bot_gl_scrollplot2d_set_text_color (self->encoder_right_plot, 0.7, 0.7, 0.7, 1); bot_gl_scrollplot2d_set_border_color (self->encoder_right_plot, 1, 1, 1, 0.7); bot_gl_scrollplot2d_set_bgcolor (self->encoder_right_plot, 0.1, 0.1, 0.1, 0.7); bot_gl_scrollplot2d_set_ylim (self->encoder_right_plot, 0, 2.0); bot_gl_scrollplot2d_add_plot (self->encoder_right_plot, "actual", 1000); bot_gl_scrollplot2d_set_color (self->encoder_right_plot, "actual", 0.7, 0, 0.7, 1); bot_gl_scrollplot2d_add_plot (self->encoder_right_plot, "0", 1000); bot_gl_scrollplot2d_set_color (self->encoder_right_plot, "0", 0.8, 0.8, 0.8, 0.5); // legends? BotGlScrollPlot2dLegendLocation legloc = BOT_GL_SCROLLPLOT2D_HIDDEN; if (bot_gtk_param_widget_get_bool (self->pw, PARAM_NAME_SHOW_LEGEND)) { legloc = BOT_GL_SCROLLPLOT2D_TOP_RIGHT; } bot_gl_scrollplot2d_set_show_legend (self->navigator_rotation_plot, legloc); bot_gl_scrollplot2d_set_show_legend (self->navigator_translation_plot, legloc); // subscribe to LC messages fblcm_motion_cmd_t_subscribe (self->lcm, "MOTION_CMD", on_motion_cmd, self); //arlcm_encoder_t_subscribe (self->lcm, "WHEEL_LEFT", on_encoders, self); //arlcm_encoder_t_subscribe (self->lcm, "WHEEL_RIGHT", on_encoders, self); // periodically pull pose data from ATrans //g_timeout_add (30, get_speed_update, self); return &self->renderer; }