EV3 'C' Maths
Posted: 05 Dec 2013, 02:09
Hi all,
I'm having issues getting my little-grey-cells around the following Trig Function Errors from my EV3 'C' Code:
The code I'm playing around with is as follows:
Any help will be greatly accepted?
I'm having issues getting my little-grey-cells around the following Trig Function Errors from my EV3 'C' Code:
Code: Select all
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
Code: Select all
#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);
}