Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
Build started 20.9.2010 at 17:48:23avr-gcc -I"C:\Robotics\AXON2\My_New_Code\..\WebBtLib" -I"C:\Robotics\AXON2\My_New_Code\." -mmcu=atmega640 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT Axon.o -MF dep/Axon.o.d -c ../Axon.cIn file included from ../SoR_Utils.h:25, from ../Axon.c:16:../global.h:37:1: warning: "F_CPU" redefined<command-line>: warning: this is the location of the previous definitionavr-gcc -I"C:\Robotics\AXON2\My_New_Code\..\WebBtLib" -I"C:\Robotics\AXON2\My_New_Code\." -mmcu=atmega640 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT control.o -MF dep/control.o.d -c ../control.c../control.c: In function 'autocalibrate':../control.c:49: warning: implicit declaration of function 'a2dConvert8bit'../control.c: In function 'scan':../control.c:80: warning: implicit declaration of function 'servo_scan'../control.c: In function 'control':../control.c:110: warning: implicit declaration of function 'rprintf'../control.c:113: error: called object 'wheel_left' is not a function../control.c:114: error: called object 'wheel_right' is not a function../control.c:115: warning: implicit declaration of function 'delay_ms'make: *** [control.o] Error 1Build failed with 2 errors and 6 warnings...
/****************************************************************************** Copyright (c) 2008 [url=http://www.societyofrobots.com]www.societyofrobots.com[/url]* (please link back if you use this code!)** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License version 2 as* published by the Free Software Foundation.** Alternatively, this software may be distributed under the terms of BSD* license.*****************************************************************************///Add your code here//global variablesint sharp_ir=0;//Here, we declare the variable sharp_ir and setting it's inital value to be 0.int scan_thresh=50;//threshold value of scanning sensorint scan_angle=1000;//position of scanner, in units of servo commandint max_scan_angle=1000;//maximum position scanner can rotate to (57)long int wheel_left=600;//Here, we declare the variable wheel_left and setting it's inital value to be 600.long int wheel_right=600;//Here, we declare the variable wheel_right and setting it's inital value to be 600.void robot_right(void)//This function takes no parameters and returns no value hence the 2 voids. { wheel_left=500; wheel_right=500; }void robot_left(void)//This function takes no parameters and returns no value hence the 2 voids. { wheel_left=800; wheel_right=800; }void robot_straight(void)//This function takes no parameters and returns no value hence the 2 voids. { wheel_left=500; wheel_right=800; }void robot_reverse(void)//This function takes no parameters and returns no value hence the 2 voids. { wheel_left=800; wheel_right=500; }void autocalibrate(void)//rather than using a predefined scan threshold, you can use this so that the first reading the sharp_ir takes is set as the threshold.This function takes no parameters and returns no value hence the 2 voids. { scan_thresh=a2dConvert8bit(3);//sensor reading }void scan(void)//this function makes the sensor center on the left edge of an object.This function takes no parameters and returns no value hence the 2 voids. { //lower (-) goes left //higher (+) goes right //1000 far right, 700 straight, 300 far left (until it jams) /*psuedocode object is detected scan right object detected object not detected scan left until object detected*/ sharp_ir=a2dConvert8bit(3);//read the analogue port 3 and it will be referred to as sharp_ir if (sharp_ir > scan_thresh)//object detected { if (scan_angle>300) //overflow protection scan_angle-=20;//scan left } else //object not detected { if (scan_angle<=max_scan_angle) //maximum servo angle scan_angle+=20; //scan right else scan_angle=830; } //servo scan code servo_scan(scan_angle);//this is where I am telling the code that when I say scan_angle, I really mean the servo that I defined in hardware.c }void control(void)//this is where I am defining my control function to be called by stampy_v2.c.This function takes no parameters and returns no value hence the 2 voids. { autocalibrate(); while(1)//This is what's called a while loop. If there is a 1 in between the parentheses it means that what is in the while loop will repeat forever. { scan(); //object on left and not too close if(scan_angle < 600 && sharp_ir < 150) { robot_left(); } //object on right and not too close else if(scan_angle > 700 && sharp_ir < 150) { robot_right(); } //object is centered and not too close else if(sharp_ir < 150 && sharp_ir < 150) { robot_straight(); } //object too close else { robot_reverse(); } //print data through usb to be read from hyperterminal rprintf("Sharp_IR=%d, IR_Servo=%d%d, L_wheel=%d%d, R_wheel=%d%d\r\n",sharp_ir, scan_angle, wheel_left, wheel_right); //these 2 things tell the code that wheel_left and wheel_right are the two servos that I defined in hardware.c wheel_left(wheel_left); wheel_right(wheel_right); delay_ms(20); } }
wheel_left(wheel_left);wheel_right(wheel_right);
/****************************************************************************** Copyright (c) 2008 [url=http://www.societyofrobots.com]www.societyofrobots.com[/url]* (please link back if you use this code!)** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License version 2 as* published by the Free Software Foundation.** Alternatively, this software may be distributed under the terms of BSD* license.*****************************************************************************//******define servo functions******///define electronics/motors/servos to specific hardware pins#define servo_scan( position ) servo(PORTE,5,position)#define wheel_left( position ) servo(PORTE,6,position)#define wheel_right( position ) servo(PORTE,7,position)/**********************************//***********define UART************//*int bluetooth=0;int USB=1;int uart2=2;int black_fin=3*//**********************************//*********define positions*********//*long int arm_left_base=600;long int arm_left_J1=600;long int arm_left_J2=600;long int wheel_left=600;long int wheel_right=600;long int camera_hor=600;long int camera_ver=600;*//**********************************/
#include 'hardware.c'
Started by DomoArigato Software
Started by Kirk Software
Started by CALEB Software
Started by Hertz32 Software