holonomic.c: In function 'Holonomic':
holonomic.c:64: warning: incompatible implicit declaration of built-in function 'cos'
holonomic.c:68: warning: incompatible implicit declaration of built-in function 'sin'
C:\Users\sparramc\AppData\Local\Temp\cceZc4vx.o: In function `Holonomic':
holonomic.c:(.text+0xd8): undefined reference to `cos'
holonomic.c:(.text+0x11c): undefined reference to `sin'
holonomic.c:(.text+0x160): undefined reference to `sin'
collect2: ld returned 1 exit status
make: *** [holonomic] Error 1
#include <stdio.h>
#include <unistd.h>
#include "I:\BricxCC\API\ev3_lcd.h"
#include "I:\BricxCC\API\ev3_timer.h"
#include "I:\BricxCC\API\ev3_command.h"
#include "I:\BricxCC\API\ev3_output.h"
//=================================================//
// This demo program is to demonstrate how to move //
// a robot fitted with 3 Holonomic wheels to move //
// in a specified direction. //
//=================================================//
// This routine is to get an angle using the EV3
// controller buttons for demo use only.
int GetAngle (void)
{ int angle;
TextOut(0, LCD_LINE1, "Right = increase");
TextOut(0, LCD_LINE2, "Left = decrease");
TextOut(0, LCD_LINE4, "Angle = ");
angle=0;
do
{ if ((BUTTON_ID_RIGHT) != 0)
angle+=2;
if ((BUTTON_ID_LEFT) != 0)
angle-=2;
TextOut(50, LCD_LINE4, " "); // clears displayed number
NumOut(50, LCD_LINE4, angle);
Wait(300);
} while ((BUTTON_ID_ENTER) != 0);
return angle;
}
// -------------------------------
// Works on 3 Holonomic wheels
// using 3 EV3 motors at 60 degrees.
void Holonomic(int degree, int power)
{ int angle, powerA, powerB, powerC, max;
powerA=cos(degree);
angle=degree-30;
powerB=sin(angle);
angle=degree+30;
powerC=-sin(angle);
max=abs(powerA);
if (max<abs(powerB))
max=abs(powerB);
if (max<abs(powerC))
max=abs(powerC);
powerA=powerA*power/max;
powerB=powerB*power/max;
powerC=powerC*power/max;
SetPower(OUT_A,powerA);
SetPower(OUT_B,powerB);
SetPower(OUT_C,powerC);
}
int main()
{ int angle;
angle=GetAngle();
Holonomic(angle,100);
Wait(3000);
}
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
i guess what Xander meant was:
link in the make file list!
don't link a header file (.h) by the project manager, the PM is just for .c files which have to be linked together to an object file (.o).
I am not sure why you get this error. I am using sine and cosine functions in my code and I have not to specifically the the math libraries. In any case, if you want to add this flag, you would have to do it under "Preferences" in the GCC linker settings. Something similar to what is shown at: http://www.robotnav.com/wp-content/uplo ... mpiler.png
Instead of adding -static, add -lm.
you're welcome!
yes indeed, it's the same issue about multitasking:
if you #include <pthread> you'd also have to link to it in the make file list by -lpthread additionally.
I'm really curious about if your whole code now compiles without any error msg and if it's now working over all completely correctly as expected
The #include part is for the (pre) compiler and the -l part is for the linker. The header file simply contains the prototypes for the functions and that sort of thing but the actual stuff you want to link in, is contained within the .so (library) file. You may want to take a look at the compilation and linking process here: http://stackoverflow.com/questions/6264 ... ocess-work
= Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)