notesforproj

notesforproj - The ROBOT class The class robot is defined...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
The ROBOT class The class robot is defined in the files robot.cpp and robot.h The robix kit has a configuration file roboVis.rbc and a script file (contains the macros) roboVis.rbx . These files are in the WORKSPACE folder. In robot_main.cpp the robot class is included using: #include "robot.h" and an object from this class is defined using the code: robot *r=NULL; r = new robot; The functions that can be used with the robot class are defined in the robot.h file: int readSensor(int sensor_no); int readSwitch(int switch_no); int executeMacro(char*); These are called for the object using: val = r->readSensor(SENSOR_NUMBER) ; ret = r->readSwitch(SWITCH_NUMBER) ; r->executeMacro("safe"); Note that the macro names should match the names in the roboVis.rbx file. The values of SENSOR_NUMBER and SWITCH_NUMBER must match the pin to which the sensor/switch has been connected. Switches are numbered 1-7 and sensors 1-8. Switches return a 0 or 1 and sensors return an integer value between 0 and 255. When finished, the object can be destroyed using: delete r; r = NULL;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The CAMERA class The class camera is defined in the file camera.h (in the INCLUDES folder ). The camera uses calls from the Microsoft Visual SDK using the VFW (video for windows) libraries. In robot_main.cpp the camera class is included using: #include "camera.h" and an object from this class is defined using the code: Camera *cam=NULL; cam = new Camera(); The functions that can be used with the robot class are defined in the camera.h file: IplImage *Grab(DWORD cmsTimeout = 2000); int width(void); int height(void); These are called for the object using: w = cam->width() ; h = cam->height() ; img = cam->Grab(); Note that the grab routine has an optional time that can be used to “give up” if an image cannot be obtained in that time. The Grab routine returns a pointer to an image structure which can be used in the GEOMETRICBLOBANALYSIS class, described below. When finished, the object can be destroyed using: if (cam) delete cam; cam = NULL; A note on MEMORY: each time you call GRAB, space for the image is allocated. To avoid “memory leaks” you need to release the space when done (before grabbing a new image); iplDeallocate(img, IPL_IMAGE_ALL); (the routine “get_new_image()” in robot_main.cpp grabs the image and puts it into a grayscale image for use in the GEO routines).
Background image of page 2
The GeometricBlobAnalysis class The class GeometricBlobAnalysis is defined in the file GeometricBlobAnalysis.h (in the INCLUDES folder ). The class computes the geometric/moment information described in class (and
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

notesforproj - The ROBOT class The class robot is defined...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online