-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstabilize_position.cpp
31 lines (24 loc) · 963 Bytes
/
stabilize_position.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "wall_painter.hpp"
/*
Takes x,y,z coordinates and reactively stabilizes the drone in these coordinates
THis coordinate is for painting on teh wall so the z ccordinate is a slight distance from the wall
@param x: x coordinate on the wall
@param y: y coordinate on the wall
@param z: z coordinate on the wall
@return bool: true if the position is reached, false if the position is not reached
*/
void wallpainter::stabilize_position(int x, int y, int z){
// move to the position (x,y,z) on the wall
// return true if the position is reached
while(true){
coordinate current = get_current_coordinates();
double error_x = find_error(current.x, x);
double error_y = find_error(current.y, y);
double error_z = find_error(current.z, z);
move_to_position(x, y, z);
}
// return false if the position is not reached
}
double find_error(double current, double target){
return target - current;
}