Commit f93a8a48 authored by René Nilsson's avatar René Nilsson
Browse files

Fix nasty GUI shit

parent 3481375c
......@@ -17,15 +17,15 @@ import lejos.geom.Point;
import lejos.robotics.navigation.Pose;
public class PilotGUI extends JFrame {
// program will automatically adjust if these three constants are changed
static final int VIS_HEIGHT=1500; // visualization height
static final int VIS_WIDTH=1500; // visualization width
static final int Y_OFFSET=600; // vertical offset to visualization
static final int X_OFFSET=400; // horizontal offset to visualization
static final int POINT_WIDTH=4; // width of points shown in the visualization
// VIS_HEIGHT + 2 * Y_OFFSET is the window height
// VIS_WIDTH + 2 * X_OFFSET is the window width
static final int VIS_HEIGHT=400; // visualization height
static final int VIS_WIDTH=1000; // visualization width
static final int Y_OFFSET=30; // vertical offset to visualization
static final int X_OFFSET=600; // horizontal offset to visualization
static final int POINT_WIDTH=4; // width of points shown in the visualization
// VIS_HEIGHT + 2 * Y_OFFSET is the window height
// VIS_WIDTH + 2 * X_OFFSET is the window width
static final int LENGTH_SCALE=5;
......@@ -68,9 +68,9 @@ public class PilotGUI extends JFrame {
super.paint(g);
g2.setColor(Color.RED);
//g2.drawRect(X_OFFSET, Y_OFFSET, VIS_WIDTH, VIS_HEIGHT);
g2.drawLine(0, X_OFFSET, VIS_WIDTH, X_OFFSET);
g2.drawLine(Y_OFFSET, 0, Y_OFFSET, VIS_HEIGHT);
//g2.drawRect(winX(0), winY(VIS_HEIGHT), VIS_WIDTH, VIS_HEIGHT);
g2.drawLine(0, winY(Y_OFFSET)+Y_OFFSET, VIS_WIDTH + 2 * X_OFFSET, winY(Y_OFFSET)+Y_OFFSET);
g2.drawLine(winX(0), 0, winX(0), VIS_HEIGHT*2 + 2 * Y_OFFSET);
g2.setColor(Color.BLUE);
int x1 = winX(0), y1 = winY(0), x2, y2;
......@@ -78,8 +78,8 @@ public class PilotGUI extends JFrame {
for (int i = 1; i < size ; i++)
{
Point current = route.get(i);
x2 = winX((int)current.getX());
y2 = winY((int)current.getY());
x2 = winX((int)current.getX()*LENGTH_SCALE);
y2 = winY((int)current.getY()*LENGTH_SCALE);
g2.drawLine(x1, y1, x2, y2);
x1 = x2; y1 = y2;
}
......@@ -88,8 +88,8 @@ public class PilotGUI extends JFrame {
{
p = particles.getParticle(i).getPose();
g2.setColor(Color.BLACK);
g2.fillRect(winX((int)p.getX()-POINT_WIDTH/2) ,
winY((int)p.getY()+POINT_WIDTH/2),
g2.fillRect(winX((int)p.getX()*LENGTH_SCALE-POINT_WIDTH/2) ,
winY((int)p.getY()*LENGTH_SCALE+POINT_WIDTH/2),
POINT_WIDTH, POINT_WIDTH);
}
......@@ -97,12 +97,12 @@ public class PilotGUI extends JFrame {
private int winX(int x)
{
return x*LENGTH_SCALE + X_OFFSET;
return x + X_OFFSET;
}
private int winY(int y)
{
return VIS_HEIGHT - y*LENGTH_SCALE + Y_OFFSET;
return VIS_HEIGHT - y + Y_OFFSET;
}
}
......@@ -12,6 +12,7 @@
import lejos.robotics.navigation.Move;
import lejos.robotics.navigation.Pose;
import lejos.util.Delay;
public class PilotMonitor
{
......@@ -42,7 +43,7 @@ public class PilotMonitor
m = new Move( (type == 0)? Move.MoveType.TRAVEL : Move.MoveType.ROTATE ,
distance, angle, false);
System.out.println("Move " + distance + " " + angle);
return m;
return new Move(Move.MoveType.TRAVEL,50,0,false);
}
public void go()
......@@ -55,6 +56,7 @@ public class PilotMonitor
view.update(route.getRoute());
Pose p = route.getCurrentPose();
System.out.println("Pose " + p.getX() + " " + p.getY() + " " + p.getHeading());
Delay.msDelay(1000);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment