14.11.2012 Views

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

Submitted version of the thesis - Airlab, the Artificial Intelligence ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

B.1. Microprocessor Code 111<br />

#include "math.h"<br />

#include "Misc.h"<br />

/* Include <strong>of</strong> o<strong>the</strong>r module interface headers ---------------------------------*/<br />

/* Local includes ------------------------------------------------------------*/<br />

/* Private typedef -----------------------------------------------------------*/<br />

/* Private define ------------------------------------------------------------*/<br />

/* Private macro -------------------------------------------------------------*/<br />

/* Private variables ---------------------------------------------------------*/<br />

/* Private function prototypes -----------------------------------------------*/<br />

void Triskar(s16* destination, s8 omega, s16* vt);<br />

void Direct_Motion(s16* destination, s8 angle, s16* speed);<br />

/* Private functions ---------------------------------------------------------*/<br />

void Triskar(s16* destination, s8 omega, s16* vt) {<br />

s16 frontal_speed = destination[0];<br />

s16 lateral_speed = destination[1];<br />

double alpha = 0;<br />

s16 velocity[2];<br />

velocity[0] = frontal_speed * cos(-alpha)<br />

- lateral_speed * sin(-alpha);<br />

velocity[1] = frontal_speed * sin(-alpha)<br />

+ lateral_speed * cos(-alpha);<br />

#ifdef NO_DEBUG<br />

USB_WriteString("Calculating Motion \n");<br />

Print_Int(velocity[0],"frontal");<br />

Print_Int(velocity[1],"lateral");<br />

#endif<br />

u8 R_robot = 250;<br />

s16 v_F = velocity[0];<br />

s16 v_L = velocity[1];<br />

double d_cosA = 0.8660;<br />

double d_sinA = 0.5000;<br />

u8 cosA = d_cosA * 100;<br />

u8 sinA = d_sinA * 100;<br />

s16 v[3] = { v_F, v_L, (omega * R_robot) / 100 };<br />

#ifdef NO_DEBUG<br />

//print velocity vector<br />

Print_Int(v[0],"v0");<br />

Print_Int(v[1],"v1");<br />

Print_Int(v[2],"v2");<br />

#endif<br />

u8 k, l;<br />

s16 MF[3][3] = { { -cosA, sinA, -100 }, { cosA, sinA,<br />

-100 }, { 0, -100, -100 } };

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!