We have acquired a new version of the code. This one has a workaround for the imview problem. We are about to test it.
The code works. We are speculating on solutions for our problem:
Currently discussing:
We're working out this idea first.
Here is our pseudocode for calibration:
While ((Ay != By || Cy != Dy) || (abs(Bx-Dx) != abs(Ax-Cx))) (we appoint a precision margin)
1. If By > Ay rotate clockwise (negative) While By > Ay (we appoint a precision margin) Else If By < Ay rotate counter clockwise (positive) While By < Ay (we appoint a precision margin)
2. If Bx > Dx translate left upon x-axis (negative) While Bx > Dx (we appoint a precision margin) Else If Ax < Cx translate right upon x-axis (positive) While Ax < Cx (we appoint a precision margin)
We are now speculating on how to project the cartesian location of a poin on the 2d camera image, upon the 3d cartesian location of the chessboard.
For this we need:
We shall attempt to make a projection matrix for this.
Partial implementation of the projection algorithm:
//Has? the ability to project a 2d camera coordinate upon board.
public class CameraPoint? { double xcam, ycam, ycampos = 0, //set distance from zero point of the camera manually xcampos = 0, //must remain zero since the camera is looking directly through the middle of the board zcampos = 0, //set height of the camera manually ycamdist, //y coordinate of aibocam - y coordinate of the middle of the board zcamdist, //height of aibocam - height of board xchess, ychess;
String chesspos = "";
double camangle, //the angle between the camera viewing direction and the normal of the board f = 0; //aibocam focuspoint.
ChessBoard? b;
public CameraPoint?(int xcam, int ycam, ChessBoard? board) { this.xcam = xcam; this.ycam = ycam; b = board;
ycamdist = ycampos - (b.coords.y+b.sur_y+b.delta_y*4); zcamdist = zcampos - b.coords.z; camangle = Math.atan(ycamdist/zcamdist); }
public void projectToChess?() { //first we rotate around x-axis of the board in the positive direction //than we translate to the chessboard double[][] projection = {{1, 0, 0, 0}, {0, Math.cos(camangle), - Math.sin(camangle), - ycamdist}, {0, Math.sin(camangle), Math.cos(camangle), - zcamdist}, {0, 0, 0, 1}};
xchess = xcam; ychess = ycam*projection[1][1] + projection[1][3];
char column = (char)('h' - (b.coords.x - xchess - b.sur_x)/(double)b.delta_x); //amount of squares from h to a on the board char row = (char)('8' -(ychess - b.coords.y - b.sur_y)/(double)b.delta_y); chesspos = chesspos + column + row; } }
// calibration.java probeerd het midden van het bord recht voor de aibo te leggen. // author: marc bron & aziz baibabaev // cknr: 0130486 & 0222704
import tio.*;
public class Calibration {
private point A; private point B; private point C; private point D;
public void Calibration(point A, point B, point C, point D) {
A = this.A; B = this.B; C = this.C; D = this.D;
} public void doCalibration() { While ( (A.y != B.y || C.y != D.y) || ( Math.abs(B.x - D.x) != Math.abs(A.x - C.x) ) ) { System.out.println(" rotate ")
if(B.y > A.y) System.out.println(" rotate clockwise "); else if (B.y < A.y) System.out.println(" rotate counter clockwise ");
System.out.println(" translate ");
if(B.x > D.x) System.out.println(" translate left upon x-axis "); else if (A.x < C.x) System.out.println(" translate right upon x-axis ");
} }
}
End of Day 3