Rose-Hulman Robotics Team

Changeset 488

Show
Ignore:
Timestamp:
05/13/09 23:47:45 (3 years ago)
Author:
spenceal
Message:

fixing memory leaks, currently working on course navigatin

Location:
trunk/software/rb
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/software/rb/auto.py

    r482 r488  
    4444        def __init__(self, controller): 
    4545                self.controller = controller 
     46 
     47                # self.nav_func = navigate_points 
     48                self.nav_func = navigate_course 
    4649         
    4750        def _main(self): 
     51                if self.controller.navigator == 'auto': 
     52                        self.nav_func() 
     53                        # update motors  
     54 
     55        def process(self, type, data): 
     56                if type == 'vision_points': 
     57                        self.points = data[0] 
     58 
     59        def navigate_course(self): 
     60                for point in self.points(): 
     61                        # count points `in front' of us 
     62                        # If it's `mostly' clear 
     63                        #       go forward 
     64                        # else 
     65                        #       count points on left/right 
     66                        #       turn in most clear direction 
     67 
     68        def navigate_points(self): 
    4869                ''' 
    4970                Update the output based on `current_data`. 
     
    91112                                time.sleep(1) 
    92113                                self.wiimote.rumble = False 
    93  
    94 class ForwardNavigator(object): 
    95         ''' 
    96         Class to go forward, staying between lines and avoiding obsticles 
    97         ''' 
    98         pass 
  • trunk/software/rb/controller.py

    r487 r488  
    4343                self.data_queue = Queue() 
    4444                self.init_drive() 
    45                 #self.init_camera() 
     45                self.init_camera() 
    4646                #self.init_gps() 
    4747                #self.init_microstrain() 
  • trunk/software/rb/vision/_vision.c

    r486 r488  
    3232classifier_t *classifier = NULL; 
    3333 
     34void free_pixbuf_data(guchar *pixels, gpointer _ipl_image) 
     35{ 
     36        printf("freeing ipl image data\n"); 
     37        IplImage *ipl_image = _ipl_image; 
     38        cvReleaseImage(&ipl_image); 
     39} 
     40 
     41/** 
     42 * Convert a IplImage to a GdkPixbuf 
     43 * The input image is left untouched 
     44 * The returned image should be freeded/g_object_unrefd by the caller 
     45 */ 
    3446GdkPixbuf *ipl_image_to_gtk_pixbuf(IplImage *image) {  
    3547        /* OpenCV uses BRG */ 
     
    4557                rgb->height,  
    4658                rgb->widthStep,  
    47                 NULL,  
    48                 NULL 
     59                free_pixbuf_data,  
     60                rgb 
    4961        );  
    50         cvReleaseImageHeader(&rgb); 
    5162        return pixbuf; 
    5263}  
     
    7384                return NULL; 
    7485        } 
     86 
    7587        // TODO: start with a larger list 
     88        printf("generating new pixbuf\n"); 
    7689        PyObject *points = PyList_New(0); 
    7790 
     
    93106 
    94107        GdkPixbuf *pixbuf = ipl_image_to_gtk_pixbuf(input); 
    95         PyObject  *py_pixbuf  = pygobject_new((GObject*)pixbuf); 
     108        PyObject  *py_pixbuf = pygobject_new((GObject*)pixbuf); 
     109        g_object_unref(pixbuf); 
    96110 
    97111        cvReleaseMemStorage(&seq->storage); 
     
    100114        cvReleaseMat(&classes); 
    101115 
    102         return Py_BuildValue("(OO)", points, py_pixbuf); 
     116        PyObject *rval = Py_BuildValue("(OO)", points, py_pixbuf); 
     117        Py_DecRef(points); 
     118        Py_DecRef(py_pixbuf); 
     119        return rval; 
    103120} 
    104121 
  • trunk/software/rb/vision/makefile

    r484 r488  
    1 CFLAGS   = -p -pg -g -Wall -Werror -pedantic -fPIC --std=gnu99 -fgnu89-inline -O3 $(shell pkg-config --cflags opencv gsl) 
     1CFLAGS   = -p -pg -g -Wall -Werror -Wno-unused -pedantic -fPIC --std=gnu99 -fgnu89-inline -O3 $(shell pkg-config --cflags opencv gsl) 
    22#CFLAGS   = -p -pg -g -Wall -Werror -pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 
    3 CPPFLAGS = -p -pg -g -Wall -Werror -pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 
     3CPPFLAGS = -p -pg -g -Wall -Werror --Wno-unused pedantic -fPIC -O3 $(shell pkg-config --cflags opencv gsl) 
    44LDFLAGS  = $(shell pkg-config --libs opencv gsl) 
    55DLFLAGS  = -shared -nostartfiles 
  • trunk/software/rb/vision/vision.c

    r485 r488  
    6868        return transformed; 
    6969} 
     70 
     71int [3]point_to_ 
    7072 
    7173CvSeq *get_points(CvMat *classes) 
  • trunk/software/rb/vision/vision.h

    r479 r488  
    2727        CvPoint end; 
    2828} CvLine; 
     29 
     30/** 
     31 * Structure representing points in the field, contains x/y coord centered at 
     32 * the robot and the value at the location. 
     33 */ 
     34typedef struct { 
     35        int x;     // Distance in front/behind the robot in meters 
     36        int y;     // Distance left/right      the robot in meters 
     37        int value; // Value of the point. See classify.h for values (e.g. RB_GRASS) 
     38} point_t; 
     39 
    2940 
    3041/**