Society of Robots - Robot Forum

Software => Software => Topic started by: Popcorn97 on July 31, 2010, 11:45:21 PM

Title: cant get code with servos to compile
Post by: Popcorn97 on July 31, 2010, 11:45:21 PM
hi,

i've got an axon 2 but cant get any code with servos or sensors to compile.

im trying to get the computer controlled example from the sample axon2 programs to compile and i get these errors:

../ServosandLED.c: In function 'appInitHardware':
../ServosandLED.c:113: warning: passing argument 2 of 'servosInit' from incompatible pointer type
../ServosandLED.c: In function 'appControl':
../ServosandLED.c:133: error: 'USB_GET' undeclared (first use in this function)
../ServosandLED.c:133: error: (Each undeclared identifier is reported only once
../ServosandLED.c:133: error: for each function it appears in.)
../ServosandLED.c:145: error: 'servo_1' undeclared (first use in this function)
../ServosandLED.c:147: error: 'servo_2' undeclared (first use in this function)
../ServosandLED.c:149: error: 'servo_3' undeclared (first use in this function)
../ServosandLED.c:156: error: 'read_sensor_1' undeclared (first use in this function)
../ServosandLED.c:158: error: 'read_sensor_2' undeclared (first use in this function)
make: *** [ServosandLED.o] Error 1
Build failed with 8 errors and 1 warnings...

i think it might be something to do with .h files not including properly (maybe - im just guessing). I've followed the instruction for getting started multiple times to try and get it to work. I can get USB communications to work with my compter and the LED to work tho.

can anyone help?

thanks
Title: Re: cant get code with servos to compile
Post by: Conscripted on August 01, 2010, 12:09:51 AM
can you post your code?
Title: Re: cant get code with servos to compile
Post by: Popcorn97 on August 01, 2010, 02:55:29 AM
yeah - its exactly the same as the sample code for the axon2 (its called computer controlled example)

//allows for printing with features, but uses more memory
#define RPRINTF_FLOAT
#define RPRINTF_COMPLEX

//additional math capabilities
//#include <math.h>

//WebbotLib includes
#include "sys/axon.h"   //defines your MCU (change to axon.h if you use the original Axon)
#include "servos.h"      //use for software servo PWM
#include "a2d.h"      //use for ADC
#include "rprintf.h"   //use for UART
//#include "i2c_master.h"   //use for I2C
//#include "buffer.h"   //use for GPS and other serial stuff

//user includes
#include "hardware.h"


// In my initialising code - pass the list of servos to control
void appInitHardware(void)
   {
   //initialize UART ports (see hardware.h to change baud/names)
   uartInit(GPS_UART, GPS_BAUD);         //UART0
   uartInit(USB_UART, USB_BAUD);         //USB
   uartInit(WIRELESS_UART, WIRELESS_BAUD);   //UART2
   uartInit(OTHER_UART, OTHER_BAUD);      //UART3

   // declare USB for output
   rprintfInit(USB_ACTIVATE);

   // Initialise the servo controller
   //servoPWMInit(&bank1);               //use PWM to control servos (must use PWM pins!)
   servosInit(&bank1, TIMER1_COMPAREA);   //use software PWM to control servos (can use any pin)

   // Initiate Sensors (examples commented out)
   //accelerometerInit(accm3d2);
   //compassInit(hmc6343);
   //gyroInit(idg300);

   }

TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
   rprintf("\nAxon Initiated.\n\n");
return 0;
}


int tempbyte;

// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart)
   {
   tempbyte=USB_GET;//get a single character


   //power servos
   if (tempbyte=='1')
      servosDisconnect(&bank1);//turn servos off
   else if (tempbyte=='2')
      servosConnect(&bank1);//turn servos on


   //move some servos around   
   if (tempbyte=='3')
      act_setSpeed(&servo_1,0);
   if (tempbyte=='4')
      act_setSpeed(&servo_2,50);
   if (tempbyte=='5')
      act_setSpeed(&servo_3,-50);
   if (tempbyte=='6')
      act_setSpeed(&servo_3,90);


   //print out sensor data   
   if (tempbyte=='6')
      rprintf("%d", read_sensor_1);
   if (tempbyte=='7')
      rprintf("%d", read_sensor_2);


   return 2000; // wait for 20ms to stop crazy oscillations (long story)
   }
Title: Re: cant get code with servos to compile
Post by: Webbot on August 01, 2010, 05:30:19 AM
Looks like its not picking up the hardware.h correctly.

This needs to be in the same folder as the C file and each of Admins examples has its own hardware.h so make sure you got the correct one.
Title: Re: cant get code with servos to compile
Post by: Popcorn97 on August 01, 2010, 05:49:19 AM
thanks for the help

i just tried using the right hardware.h but got 71 errors. most are refering to device.h and led.h . actually i'll post all the errors you can can see exactly what they are.

Build started 1.8.2010 at 21:47:06
avr-gcc -mmcu=atmega640 -Wl,-Map=ServosandLED.map ServosandLED.o   -L"C:\Robotics\WebbotLib"   -o ServosandLED.elf
c:/winavr-20090313/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm640.o:(.init9+0x0): undefined reference to `main'
ServosandLED.o: In function `__vector_23':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:200: undefined reference to `__timer_overflowService'
ServosandLED.o: In function `__vector_21':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:207: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_22':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:214: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_20':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:251: undefined reference to `__timer_overflowService'
ServosandLED.o: In function `__vector_17':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:258: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_18':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:265: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_19':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:272: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_16':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:286: undefined reference to `__timer_captureService'
ServosandLED.o: In function `__vector_15':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:295: undefined reference to `__timer_overflowService'
ServosandLED.o: In function `__vector_13':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:302: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_14':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:309: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_35':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:345: undefined reference to `__timer_overflowService'
ServosandLED.o: In function `__vector_32':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:352: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_33':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:359: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_34':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:366: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_31':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:380: undefined reference to `__timer_captureService'
ServosandLED.o: In function `__vector_45':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:389: undefined reference to `__timer_overflowService'
ServosandLED.o: In function `__vector_42':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:396: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_43':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:403: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_44':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:410: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_41':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:424: undefined reference to `__timer_captureService'
ServosandLED.o: In function `__vector_50':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:433: undefined reference to `__timer_overflowService'
ServosandLED.o: In function `__vector_47':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:440: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_48':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:447: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_49':
\..\WebbotLib/sys/../device.h:454: undefined reference to `__timer_compareService'
ServosandLED.o: In function `__vector_46':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:468: undefined reference to `__timer_captureService'
ServosandLED.o: In function `uart0SendByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:564: undefined reference to `_uartSendByte'
ServosandLED.o: In function `uart0GetByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:567: undefined reference to `__uartGetByte'
ServosandLED.o: In function `__vector_27':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:578: undefined reference to `__uartTransmitService'
ServosandLED.o: In function `__vector_25':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:583: undefined reference to `__uartReceiveService'
ServosandLED.o: In function `uart1SendByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:591: undefined reference to `_uartSendByte'
ServosandLED.o: In function `uart1GetByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:594: undefined reference to `__uartGetByte'
ServosandLED.o: In function `__vector_38':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:606: undefined reference to `__uartTransmitService'
ServosandLED.o: In function `__vector_36':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:611: undefined reference to `__uartReceiveService'
ServosandLED.o: In function `uart2SendByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:619: undefined reference to `_uartSendByte'
ServosandLED.o: In function `uart2GetByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:622: undefined reference to `__uartGetByte'
ServosandLED.o: In function `__vector_53':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:634: undefined reference to `__uartTransmitService'
ServosandLED.o: In function `__vector_51':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:639: undefined reference to `__uartReceiveService'
ServosandLED.o: In function `uart3SendByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:646: undefined reference to `_uartSendByte'
ServosandLED.o: In function `uart3GetByte':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:649: undefined reference to `__uartGetByte'
ServosandLED.o: In function `__vector_56':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:660: undefined reference to `__uartTransmitService'
ServosandLED.o: In function `__vector_54':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../device.h:664: undefined reference to `__uartReceiveService'
ServosandLED.o: In function `statusLEDregister':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:61: undefined reference to `statusLED'
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:61: undefined reference to `statusLED'
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:62: undefined reference to `statusLED'
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:62: undefined reference to `statusLED'
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:63: undefined reference to `statusLED'
ServosandLED.o:C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:63: more undefined references to `statusLED' follow
ServosandLED.o: In function `LED_on':
C:\Robotics\Projects\ServosandLED\..\..\WebbotLib/sys/../led.h:53: undefined reference to `LED_set'
ServosandLED.o: In function `appInitHardware':
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:52: undefined reference to `_uartInit'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:53: undefined reference to `_uartInit'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:54: undefined reference to `_uartInit'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:55: undefined reference to `_uartInit'
8: undefined reference to `rprintfInit'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:62: undefined reference to `servosInit'
ServosandLED.o: In function `appInitSoftware':
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:72: undefined reference to `rprintf2RamRom'
ServosandLED.o: In function `appControl':
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:87: undefined reference to `servosSetConnected'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:89: undefined reference to `servosSetConnected'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:94: undefined reference to `__act_setSpeed'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:96: undefined reference to `__act_setSpeed'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:98: undefined reference to `__act_setSpeed'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:100: undefined reference to `__act_setSpeed'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:105: undefined reference to `a2dConvert8bit'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:105: undefined reference to `rprintf2RamRom'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:107: undefined reference to `a2dConvert8bit'
C:\Robotics\Projects\ServosandLED\default/../ServosandLED.c:107: undefined reference to `rprintf2RamRom'
ServosandLED.o:(.data+0x11): undefined reference to `c_hw_uart'
ServosandLED.o:(.data+0x36): undefined reference to `c_hw_uart'
ServosandLED.o:(.data+0x5b): undefined reference to `c_hw_uart'
ServosandLED.o:(.data+0x80): undefined reference to `c_hw_uart'
make: *** [ServosandLED.elf] Error 1
Build failed with 71 errors and 0 warnings...
Title: Re: cant get code with servos to compile
Post by: Webbot on August 01, 2010, 04:21:19 PM
And by the looks of it: then it appears that you haven't set up the library locations for WebbotLib, libm,libc etc as shown in my manual under Getting Started with AVRStudio
Title: Re: cant get code with servos to compile
Post by: madsci1016 on August 01, 2010, 06:05:48 PM
Use the Project Designer to setup your code and you will overcome all these headaches.

Video Tutorial:

Axon 2, Webbotlib and Project Designer Tutorial (http://www.youtube.com/watch?v=FPhMES0PFEw#ws)
Title: Re: cant get code with servos to compile
Post by: Webbot on August 01, 2010, 08:01:35 PM
@madscii
Combining Project Designer (PD) with the current Admin examples will make stuff more confusing and introduce new issues with the way Admins code is currently laid out (only looked ar it today).

IMHO -  Admins non-PD examples should be a single C file without all of its rather over-complicated  :D and heavily commented out header files.

But yes  - PD is the way to go.

Project Designer versions should include a copy of the project file - so that people can re-generate it themselves using different pins etc.

IMHO then ONLY the Project Designer examples should be supported as 'examples'.

I've got stacks of examples which I use, but haven't released, prior to making a new release (mainly to check that no compile errors exist across EVERY micro processor supported - not just the ATMega640)

Eventually I will add these to my website
Title: Re: cant get code with servos to compile
Post by: Popcorn97 on August 07, 2010, 09:49:32 PM
ive got the servos working now. i used project developer and it fixed all the compiler errors i was having.

thanks guys for the help