Пример #1
0
void setup_renderer_navigator(Viewer *viewer, int priority) 
{
    RendererNavigator *self = 
        (RendererNavigator*) calloc(1, sizeof(RendererNavigator));    

    Renderer *renderer = &self->renderer;

    renderer->draw = my_draw;
    renderer->destroy = my_free;
    renderer->name = "Navigator";
    renderer->enabled = 1;
    renderer->user = self;

    self->lc = globals_get_lcm();
    self->ctrans = globals_get_ctrans();
    self->rndf = globals_get_rndf ();
    self->config = globals_get_config ();
    self->viewer = viewer;
    self->nav = NULL;
    
    lcmtypes_navigator_plan_t_subscribe(self->lc, "NAVIGATOR_PLAN",
            on_navigator_plan, self);

    viewer_add_renderer(viewer, renderer, priority);
}
Пример #2
0
void setup_renderer_lcmgl(Viewer *viewer, int priority)
{
    RendererLcmgl *self = 
        (RendererLcmgl*) calloc(1, sizeof(RendererLcmgl));

    Renderer *renderer = &self->renderer;

    self->lcm = globals_get_lcm();
    self->viewer = viewer;
    self->pw = BOT_GTK_PARAM_WIDGET(bot_gtk_param_widget_new());

    renderer->draw = my_draw;
    renderer->destroy = my_free;
    renderer->name = "LCM GL";
    renderer->widget = GTK_WIDGET(self->pw);
    renderer->enabled = 1;
    renderer->user = self;

    self->channels = g_hash_table_new(g_str_hash, g_str_equal);

    g_signal_connect (G_OBJECT (self->pw), "changed", 
                      G_CALLBACK (on_param_widget_changed), self);

    botlcm_lcmgl_data_t_subscribe(self->lcm, "LCMGL.*", on_lcgl_data, self);

    viewer_add_renderer(viewer, renderer, priority);
}
Пример #3
0
void setup_renderer_rrt_debug(Viewer *viewer, int priority) 
{
    RendererRrtDebug *self = 
        (RendererRrtDebug*) calloc(1, sizeof(RendererRrtDebug));    

    Renderer *renderer = &self->renderer;

    renderer->draw = my_draw;
    renderer->destroy = my_free;
    renderer->name = "RRT Debug";
    renderer->widget = gtk_vbox_new(FALSE, 0);
    renderer->enabled = 1;
    renderer->user = self;

    self->lc = globals_get_lcm();
    self->ctrans = globals_get_ctrans();
    self->viewer = viewer;
    self->data = NULL;
    self->min_node_id = 0;
    self->plot_ctrl = 0;
    self->plot_state = 1;

    self->pw = GTKU_PARAM_WIDGET(gtku_param_widget_new());
 
    gtk_box_pack_start(GTK_BOX(renderer->widget), GTK_WIDGET(self->pw), TRUE, TRUE, 0);

    gtku_param_widget_add_double (self->pw, PARAM_MIN0, 
            GTKU_PARAM_WIDGET_SLIDER, 0, 1e4, 1e2, 0);
    gtku_param_widget_add_int (self->pw, PARAM_MIN_PLOT, 
            GTKU_PARAM_WIDGET_SLIDER, 0, 5e2, 1, 0);
    gtku_param_widget_add_double (self->pw, PARAM_MAX0, 
            GTKU_PARAM_WIDGET_SLIDER, 0, MAX_ID_TO_PLOT, 1e2, MAX_ID_TO_PLOT);
    gtku_param_widget_add_int (self->pw, PARAM_MAX_PLOT, 
            GTKU_PARAM_WIDGET_SLIDER, 0, 5e2, 1, 5e2);
    gtku_param_widget_add_booleans (self->pw, 0,
            PARAM_NAME_RENDER_CTRL, self->plot_ctrl, 
            PARAM_NAME_RENDER_STATE, self->plot_state, NULL);
            
    gtk_widget_show_all(renderer->widget);
   
    g_signal_connect (G_OBJECT (self->pw), "changed", 
            G_CALLBACK (on_param_widget_changed), self);
            
    lcmtypes_rrt_debug_t_subscribe(self->lc, "RRT_DEBUG", on_rrt_debug, self);

    viewer_add_renderer(viewer, renderer, priority);
}
Пример #4
0
void setup_renderer_textured(Viewer *viewer, int render_priority)
{
    viewer_add_renderer(viewer, renderer_textured_new(viewer), render_priority);
}
void setup_renderer_scrolling_plots (Viewer *viewer, int render_priority)
{
    viewer_add_renderer(viewer, 
            renderer_scrolling_plots_new(viewer), render_priority);
}
Пример #6
0
void setup_renderer_car(Viewer *viewer, int render_priority)
{
    RendererCar *self = (RendererCar*) calloc (1, sizeof (RendererCar));

    Renderer *renderer = &self->renderer;

    renderer->draw = car_draw;
    renderer->destroy = car_free;

    renderer->widget = gtk_vbox_new(FALSE, 0);
    renderer->name = RENDERER_NAME;
    renderer->user = self;
    renderer->enabled = 1;

    EventHandler *ehandler = &self->ehandler;
    ehandler->name = RENDERER_NAME;
    ehandler->enabled = 1;
    ehandler->pick_query = pick_query;
    ehandler->key_press = key_press;
    ehandler->hover_query = pick_query;
    ehandler->mouse_press = mouse_press;
    ehandler->mouse_release = mouse_release;
    ehandler->mouse_motion = mouse_motion;
    ehandler->user = self;

    self->viewer = viewer;
    self->lc = globals_get_lcm ();
    self->config = globals_get_config ();

    self->pw = GTKU_PARAM_WIDGET(gtku_param_widget_new());
    self->ctrans = globals_get_ctrans ();
    self->path = gu_ptr_circular_new (MAX_POSES, free_path_element, NULL);

    gtk_box_pack_start(GTK_BOX(renderer->widget), GTK_WIDGET(self->pw), TRUE, 
            TRUE, 0);

    gtku_param_widget_add_booleans (self->pw, 0, PARAM_FOLLOW_POS, 1, NULL);
    gtku_param_widget_add_booleans (self->pw, 0, PARAM_FOLLOW_YAW, 0, NULL);

    char * model;
    char path[256];
    if (config_get_str (self->config, "renderer_car.chassis_model",
                &model) == 0) {
        snprintf (path, sizeof (path), "%s/%s", MESH_MODEL_PATH, model);
        self->chassis_model = rwx_model_create (path);
    }
    if (config_get_str (self->config, "renderer_car.wheel_model",
                &model) == 0) {
        snprintf (path, sizeof (path), "%s/%s", MESH_MODEL_PATH, model);
        self->wheel_model = rwx_model_create (path);
    }

    if (self->chassis_model)
        gtku_param_widget_add_booleans (self->pw, 0, PARAM_NAME_BLING, 1,
                NULL);
    if (self->wheel_model)
        gtku_param_widget_add_booleans (self->pw, 0, PARAM_NAME_WHEELS, 1,
                NULL);
 
    self->max_draw_poses = 1000;
    gtku_param_widget_add_int (self->pw, PARAM_MAXPOSES, 
            GTKU_PARAM_WIDGET_SLIDER, 0, MAX_POSES, 100, self->max_draw_poses);
 
    GtkWidget *find_button = gtk_button_new_with_label("Find");
    gtk_box_pack_start(GTK_BOX(renderer->widget), find_button, FALSE, FALSE, 0);
    g_signal_connect(G_OBJECT(find_button), "clicked", 
            G_CALLBACK (on_find_button), self);

    GtkWidget *clear_button = gtk_button_new_with_label("Clear path");
    gtk_box_pack_start(GTK_BOX(renderer->widget), clear_button, FALSE, FALSE, 
            0);
    g_signal_connect(G_OBJECT(clear_button), "clicked", 
            G_CALLBACK (on_clear_button), self);

    gtk_widget_show_all(renderer->widget);

    g_signal_connect (G_OBJECT (self->pw), "changed", 
                      G_CALLBACK (on_param_widget_changed), self);
    on_param_widget_changed(self->pw, "", self);

    ctrans_subscribe (self->ctrans, pose_listener, self);

#ifdef USE_CANDECODE
    self->can = can_decode_new (self->lc);
    can_decode_subscribe (self->can, CAN_MSG_WHEELSPEEDS, on_wheelspeeds, self);
    can_decode_subscribe (self->can, CAN_MSG_STEERING_WHEEL,
            on_steering, self);
    can_decode_subscribe (self->can, CAN_MSG_SUSPENSION_HEIGHT,
            on_suspension, self);
#endif

    viewer_add_renderer(viewer, &self->renderer, render_priority);
    viewer_add_event_handler(viewer, &self->ehandler, render_priority);

    self->footprint = config_util_get_vehicle_footprint (self->config);
    assert (self->footprint);

    g_signal_connect (G_OBJECT (viewer), "load-preferences", 
            G_CALLBACK (on_load_preferences), self);
    g_signal_connect (G_OBJECT (viewer), "save-preferences",
            G_CALLBACK (on_save_preferences), self);
}
Пример #7
0
void setup_renderer_cam_thumb (Viewer *viewer, int render_priority)
{
    viewer_add_renderer(viewer, _new(viewer), render_priority);
}
Пример #8
0
void setup_renderer_car(Viewer *viewer, int render_priority)
{
    RendererCar *self = (RendererCar*) calloc (1, sizeof (RendererCar));

    Renderer *renderer = &self->renderer;

    renderer->draw = car_draw;
    renderer->destroy = car_free;

    renderer->widget = gtk_vbox_new(FALSE, 0);
    renderer->name = RENDERER_NAME;
    renderer->user = self;
    renderer->enabled = 1;

    EventHandler *ehandler = &self->ehandler;
    ehandler->name = RENDERER_NAME;
    ehandler->enabled = 1;
    ehandler->pick_query = pick_query;
    ehandler->key_press = key_press;
    ehandler->hover_query = pick_query;
    ehandler->mouse_press = mouse_press;
    ehandler->mouse_release = mouse_release;
    ehandler->mouse_motion = mouse_motion;
    ehandler->user = self;

    self->viewer = viewer;
    self->lcm = globals_get_lcm ();
    self->config = globals_get_config ();

    self->pw = BOT_GTK_PARAM_WIDGET(bot_gtk_param_widget_new());
    self->atrans = globals_get_atrans ();
    self->path = bot_ptr_circular_new (MAX_POSES, free_path_element, NULL);

    gtk_box_pack_start(GTK_BOX(renderer->widget), GTK_WIDGET(self->pw), TRUE, 
            TRUE, 0);

    bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_FOLLOW_POS, 1, NULL);
    bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_FOLLOW_YAW, 0, NULL);

    char * model;
    char path[256];
    if (bot_conf_get_str (self->config, "renderer_car.chassis_model",
                &model) == 0) {
        snprintf (path, sizeof (path), "%s/%s", MODELS_DIR, model);
        self->chassis_model = rwx_model_create (path);
    }
    if (bot_conf_get_str (self->config, "renderer_car.wheel_model",
                &model) == 0) {
        snprintf (path, sizeof (path), "%s/%s", MODELS_DIR, model);
        self->wheel_model = rwx_model_create (path);
    }

    if (self->chassis_model)
        bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_NAME_BLING, 1,
                NULL);
    if (self->wheel_model)
        bot_gtk_param_widget_add_booleans (self->pw, 0, PARAM_NAME_WHEELS, 1,
                NULL);
 
    self->max_draw_poses = 1000;
    bot_gtk_param_widget_add_int (self->pw, PARAM_MAXPOSES, 
            BOT_GTK_PARAM_WIDGET_SLIDER, 0, MAX_POSES, 100, self->max_draw_poses);
 
    GtkWidget *find_button = gtk_button_new_with_label("Find");
    gtk_box_pack_start(GTK_BOX(renderer->widget), find_button, FALSE, FALSE, 0);
    g_signal_connect(G_OBJECT(find_button), "clicked", 
            G_CALLBACK (on_find_button), self);

    GtkWidget *clear_button = gtk_button_new_with_label("Clear path");
    gtk_box_pack_start(GTK_BOX(renderer->widget), clear_button, FALSE, FALSE, 
            0);
    g_signal_connect(G_OBJECT(clear_button), "clicked", 
            G_CALLBACK (on_clear_button), self);

    gtk_widget_show_all(renderer->widget);

    g_signal_connect (G_OBJECT (self->pw), "changed", 
                      G_CALLBACK (on_param_widget_changed), self);
    on_param_widget_changed(self->pw, "", self);

    botlcm_pose_t_subscribe(self->lcm, "POSE", on_pose, self);


    viewer_add_renderer(viewer, &self->renderer, render_priority);
    viewer_add_event_handler(viewer, &self->ehandler, render_priority);

    self->footprint = pointlist2d_new (4);
    fbconf_get_vehicle_footprint (self->config, 
            (double*)self->footprint->points);

    g_signal_connect (G_OBJECT (viewer), "load-preferences", 
            G_CALLBACK (on_load_preferences), self);
    g_signal_connect (G_OBJECT (viewer), "save-preferences",
            G_CALLBACK (on_save_preferences), self);
}
Пример #9
0
void setup_renderer_velodyne(Viewer *viewer, int render_priority)
{
    viewer_add_renderer(viewer, renderer_velodyne_new(viewer), render_priority);
}
Пример #10
0
void setup_renderer_simtraffic(Viewer *viewer, int render_priority)
{
    RendererSimTraffic *self = 
        (RendererSimTraffic*) calloc (1, sizeof (RendererSimTraffic));

    // renderer administrativa
    Renderer *renderer = &self->renderer;

    renderer->draw = simtraffic_draw;
    renderer->destroy = simtraffic_free;

    renderer->widget = gtk_vbox_new(FALSE, 0);
    renderer->name = "SimTraffic";
    renderer->user = self;
    renderer->enabled = 1;

    // event handler
    EventHandler *ehandler = &self->ehandler;
    ehandler->name = "SimTraffic";
    ehandler->enabled = 1;
    ehandler->pick_query = pick_query;
    ehandler->hover_query = pick_query;
    ehandler->mouse_press = mouse_press;
    ehandler->mouse_motion = mouse_motion;
    ehandler->mouse_release = mouse_release;
    ehandler->key_press = key_press;
    ehandler->user = self;

    // member variables
    self->viewer = viewer;
    self->lc = globals_get_lcm();
    self->ctrans = globals_get_ctrans();
    self->tracks = NULL;
    self->lchandler = lcmtypes_track_list_t_subscribe (self->lc, 
            "LIDAR_TRACKS_SIM", on_track_list, self);

    // parameter widget
    self->pw = GTKU_PARAM_WIDGET(gtku_param_widget_new());
    g_signal_connect (G_OBJECT (self->pw), "changed", 
                      G_CALLBACK (on_param_widget_changed), self);
    on_param_widget_changed(self->pw, "", self);

    gtk_box_pack_start(GTK_BOX(renderer->widget), GTK_WIDGET(self->pw), 
            TRUE, TRUE, 0);

    // add car button
    GtkWidget *add_bt = gtk_button_new_with_label ("Add car");
    gtk_box_pack_start (GTK_BOX (renderer->widget), add_bt,
            FALSE, FALSE, 0);
    gtk_widget_show (add_bt);
    g_signal_connect (G_OBJECT(add_bt), "clicked", 
            G_CALLBACK(on_add_bt_clicked), self);

    gtk_widget_show_all(renderer->widget);
    
    // popup menu
    self->context_menu = GTK_MENU (gtk_menu_new ());
    g_object_ref_sink (self->context_menu);

    GtkWidget *pause_mi = gtk_menu_item_new_with_label ("Pause");
    GtkWidget *unpause_mi = gtk_menu_item_new_with_label ("Unpause");
    gtk_menu_shell_append (GTK_MENU_SHELL(self->context_menu), pause_mi);
    gtk_menu_shell_append (GTK_MENU_SHELL(self->context_menu), unpause_mi);
    g_signal_connect (G_OBJECT(pause_mi), "activate", 
            G_CALLBACK(on_pause_mi_activate), self);
    g_signal_connect (G_OBJECT(unpause_mi), "activate", 
            G_CALLBACK(on_unpause_mi_activate), self);
    gtk_widget_show_all (GTK_WIDGET (self->context_menu));

    // administrativa
    viewer_add_renderer(viewer, renderer, render_priority);
    viewer_add_event_handler(viewer, ehandler, render_priority);
}