Changeset 510
- Timestamp:
- 06/03/09 18:31:27 (3 years ago)
- Location:
- trunk/software
- Files:
-
- 5 modified
-
rb/auto.py (modified) (3 diffs)
-
rb/vision/__init__.py (modified) (2 diffs)
-
rb/vision/classify.h (modified) (1 diff)
-
rb/vision/classify_hard.c (modified) (1 diff)
-
rbconfig.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/software/rb/auto.py
r508 r510 20 20 import time 21 21 from math import pi 22 from collections import defaultdict23 22 24 23 from rb.core.logging import log_debug, log_info, log_warn, log_error, log_die 25 24 from rb.utils import points_to_vec, rad_delta 26 from rb.vision import Camera25 from rb.vision import GRASS, OBSTACLE 27 26 28 27 from time import sleep … … 68 67 69 68 def navigate_course(self): 70 values = [0.1, 0.1, 0.1, 0.1]69 counts = [0.1, 0.1, 0.1, 0.1] 71 70 72 71 # count points `in front' of us 73 for pointin self.points:74 if (-10 < point[0] and point[0] < 10 and point[0] < 10):75 values[point[2]] += 172 for x, y, type in self.points: 73 if -10 < x < 10: 74 counts[type] += 1 76 75 77 if (values[Camera.GRASS] < 10):78 print "Auto.navigate_course: Not enough data,aborting"79 return False;76 if counts[GRASS] < 10: 77 print "Auto.navigate_course: Not enough clear area; aborting" 78 self.controller.drive.setspeed(0, 0) 80 79 81 80 # If it's `mostly' clear 82 81 print "Auto.navigate_course: values = ", values 83 if ( values[Camera.GRASS]/values[Camera.OBSTICLE]) > 2:82 if (counts[GRASS]/counts[OBSTACLE]) > 2: 84 83 # go forward 85 84 print "Auto.navigate_course: Moving forward" 86 85 self.controller.drive.setspeed(0.5, 0.5) 87 86 else: 88 print "Auto.navigate_course: Obsticle detected" 87 print "Auto.navigate_course: Obstacle detected" 88 self.controller.drive.setspeed(0, 0) 89 89 # TODO: 90 90 # count points on left/right … … 95 95 Update the output based on `current_data`. 96 96 ''' 97 # This is old code --- very old 97 98 SPEED = .75 98 99 if self.accel is not None: -
trunk/software/rb/vision/__init__.py
r508 r510 5 5 from time import sleep 6 6 7 # TODO: import these from the C enum 8 GRASS = 0 9 OBSTACLE = 1 10 LINE = 2 11 IGNORE = 3 12 13 DTREE = 0 14 HARD = 1 15 16 COLORS = { 17 GRASS : [0, 255, 0 ], 18 OBSTACLE : [255, 0, 0 ], 19 LINE : [255, 255, 255], 20 IGNORE : [0, 0, 255], 21 } 22 7 23 class Camera(object): 8 # TODO: import these from the C enum9 GRASS = 010 OBSTICLE = 111 LINE = 212 IGNORE = 313 14 DTREE = 015 HARD = 116 17 COLORS = {18 GRASS : [0, 255, 0 ],19 OBSTICLE : [255, 0, 0 ],20 LINE : [255, 255, 255],21 IGNORE : [0, 0, 255],22 }23 24 24 def __init__(self, controller): 25 25 self.running = True … … 46 46 win = gtk.Window() 47 47 image = gtk.Image() 48 _vision._init(T RUE, Camera.DTREE)48 _vision._init(True, DTREE) 49 49 points, pixbuf = _vision._get_points() 50 50 image.set_from_pixbuf(pixbuf) -
trunk/software/rb/vision/classify.h
r484 r510 6 6 enum { 7 7 RB_GRASS, 8 RB_OBST ICLE,8 RB_OBSTACLE, 9 9 RB_LINE, 10 10 RB_IGNORE , -
trunk/software/rb/vision/classify_hard.c
r479 r510 30 30 /* Mark outputs */ 31 31 CvMat *output = cvCreateMat(size.height, size.width, CV_8U); 32 cvSet(output, cvRealScalar(RB_OBST ICLE), NULL);32 cvSet(output, cvRealScalar(RB_OBSTACLE), NULL); 33 33 cvSet(output, cvRealScalar(RB_GRASS), grass_mask); 34 34 cvSet(output, cvRealScalar(RB_LINE ), line_mask); -
trunk/software/rbconfig.py
r509 r510 3 3 ''' 4 4 5 from rb.vision import Camera5 from rb.vision import DTREE, HARD 6 6 7 7 name = 'RATT' # Human-readable robot name … … 23 23 # This is just the path to the CGI script, without the querystring parameters 24 24 fake_ccam = True 25 classifier = Camera.HARD25 classifier = HARD 26 26 ccam_url = "http://192.168.0.226/admin-bin/ccam.cgi" 27 27

