Move the Wheelbot models to the SIM_wheelbot directory

This commit is contained in:
John M. Penn 2016-02-22 11:59:11 -06:00
parent da08efe546
commit 9e481703a1
63 changed files with 56 additions and 46 deletions

View File

@ -1,12 +1,13 @@
2, 0, 0,images/wp1.png 2.0, 0.0, 0.0,images/wp1.png
2, 2, 0,images/wp2.png 2.0, 2.0, 0.0,images/wp2.png
0, 2, 0,images/wp3.png 0.0, 2.0, 0.0,images/wp3.png
0, 4, 0,images/wp4.png 0.0, 4.0, 0.0,images/wp4.png
-2, 4, 0,images/wp5.png -2.0, 4.0, 0.0,images/wp5.png
-2, 2, 0,images/wp6.png -2.0, 2.0, 0.0,images/wp6.png
-4, 2, 0,images/wp7.png -4.0, 2.0, 0.0,images/wp7.png
-4, 0, 0,images/wp8.png -4.0, 0.0, 0.0,images/wp8.png
-2, 0, 0,images/wp9.png -2.0, 0.0, 0.0,images/wp9.png
-2,-2, 0,images/wp10.png -2.0,-2.0, 0.0,images/wp10.png
0,-2, 0,images/wp11.png 0.0,-2.0, 0.0,images/wp11.png
0, 0, 0,images/wp0.png 0.0, 0.0, 0.0,images/wp0.png
3.5,-3.5, 0.0,images/CompassRose.png

View File

@ -1,4 +1,4 @@
#SIM\_rover #SIM\_wheelbot
--- ---
This is a simulation of a two-wheeled robotic electric vehicle. This is a simulation of a two-wheeled robotic electric vehicle.

View File

@ -30,8 +30,7 @@ for line in fp:
# Start the display VarServer Client # Start the display VarServer Client
#========================================== #==========================================
varServerPort = trick.var_server_get_port(); varServerPort = trick.var_server_get_port();
trick_home = os.environ['TRICK_HOME'] EVDisplay_path = "models/Graphics/dist/EVDisplay.jar"
EVDisplay_path = trick_home + "/trick_models/Wheelbot/Graphics/dist/EVDisplay.jar"
if (os.path.isfile(EVDisplay_path)) : if (os.path.isfile(EVDisplay_path)) :
EVDisplay_cmd = "java -jar " \ EVDisplay_cmd = "java -jar " \

View File

@ -1,2 +1,2 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models/Wheelbot TRICK_CFLAGS += -Imodels
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models/Wheelbot TRICK_CXXFLAGS += -Imodels

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -30,26 +30,26 @@ import javax.swing.JPanel;
class Feature { class Feature {
public double x, y; public double north, west;
public double heading; public double heading;
public BufferedImage bufImage; public BufferedImage bufImage;
public Feature(double X, double Y, double H, String imageFile) { public Feature(double N, double W, double H, String imageFile) {
x = X; north = N;
y = Y; west = W;
heading = H; heading = H;
Image img = new ImageIcon(imageFile).getImage(); Image img = new ImageIcon(imageFile).getImage();
bufImage = new BufferedImage(img.getWidth(null), img.getHeight(null), bufImage = new BufferedImage(img.getWidth(null), img.getHeight(null),
BufferedImage.TYPE_INT_ARGB); BufferedImage.TYPE_INT_ARGB);
Graphics2D gContext = bufImage.createGraphics(); Graphics2D gContext = bufImage.createGraphics();
gContext.drawImage(img,0,0,null); gContext.drawImage(img,0,0,null);
gContext.dispose(); gContext.dispose();
} }
public void setState(double X, double Y, double H) { public void setState(double N, double W, double H) {
x = X; north = N;
y = Y; west = W;
heading = H; heading = H;
} }
} }
@ -57,19 +57,19 @@ class Feature {
class ArenaMap extends JPanel { class ArenaMap extends JPanel {
private List<Feature> featureList; private List<Feature> featureList;
private double unitsPerPixel; private double metersPerPixel;
public ArenaMap(List<Feature> flist, double mapScale) { public ArenaMap(List<Feature> flist, double mapScale) {
featureList = flist; featureList = flist;
unitsPerPixel = mapScale; metersPerPixel = mapScale;
SetScale(mapScale); SetScale(mapScale);
} }
public void SetScale (double mapScale) { public void SetScale (double mapScale) {
if (mapScale < 0.00001) { if (mapScale < 0.00001) {
unitsPerPixel = 0.00001; metersPerPixel = 0.00001;
} else { } else {
unitsPerPixel = mapScale; metersPerPixel = mapScale;
} }
} }
@ -79,20 +79,30 @@ class ArenaMap extends JPanel {
int width = getWidth(); int width = getWidth();
int height = getHeight(); int height = getHeight();
// Translate origin to the center of the panel. // Translate map origin to the center of the panel.
Graphics2D gCenter = (Graphics2D)g2d.create(); Graphics2D gCenter = (Graphics2D)g2d.create();
gCenter.translate(width/2, height/2); gCenter.translate(width/2, height/2);
//gCenter.scale(2.0, 2.0); // Makes pixels bigger.
for (int ii=0 ; ii < featureList.size() ; ++ii ) { for (int ii=0 ; ii < featureList.size() ; ++ii ) {
Feature feature = featureList.get(ii); Feature feature = featureList.get(ii);
BufferedImage featureImage = feature.bufImage;
int ImgOffsetX = featureImage.getWidth()/2; int featureX = (int) -(feature.west / metersPerPixel);
int ImgOffsetY = featureImage.getHeight()/2; int featureY = (int) -(feature.north / metersPerPixel);
int drawLocationX = (int)(feature.x / unitsPerPixel) - ImgOffsetX;
int drawLocationY = (int)(feature.y / unitsPerPixel) - ImgOffsetY; double drawHeading = -feature.heading;
AffineTransform tx = AffineTransform.getRotateInstance(feature.heading, ImgOffsetX, ImgOffsetY);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); int ImgOffsetX = feature.bufImage.getWidth()/2;
gCenter.drawImage(op.filter(featureImage, null), drawLocationX, drawLocationY, null); int ImgOffsetY = feature.bufImage.getHeight()/2;
int drawLocationX = featureX - ImgOffsetX;
int drawLocationY = featureY - ImgOffsetY;
AffineTransform tx = AffineTransform.getRotateInstance( drawHeading, ImgOffsetX, ImgOffsetY);
AffineTransformOp op = new AffineTransformOp( tx, AffineTransformOp.TYPE_BILINEAR);
gCenter.drawImage( op.filter( feature.bufImage, null), drawLocationX, drawLocationY, null);
} }
gCenter.dispose(); gCenter.dispose();
} }
@ -195,18 +205,18 @@ public class EVDisplay extends JFrame {
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
String field[] = line.split(","); String field[] = line.split(",");
double X = Double.parseDouble(field[0]); double N = Double.parseDouble(field[0]);
double Y = Double.parseDouble(field[1]); double W = Double.parseDouble(field[1]);
double H = Double.parseDouble(field[2]); double H = Double.parseDouble(field[2]);
String imageFileName = field[3]; String imageFileName = field[3];
featureList.add(new Feature( X, Y, H, imageFileName)); featureList.add(new Feature( N, W, H, imageFileName));
} }
} }
Feature vehicle = new Feature(0, 0, Math.toRadians(0), vehicleImageFile); Feature vehicle = new Feature(0, 0, Math.toRadians(0), vehicleImageFile);
featureList.add(vehicle); featureList.add(vehicle);
EVDisplay evd = new EVDisplay( new ArenaMap( featureList, 0.015)); EVDisplay evd = new EVDisplay( new ArenaMap( featureList, 0.01));
evd.setVisible(true); evd.setVisible(true);
System.out.println("Connecting to: " + host + ":" + port); System.out.println("Connecting to: " + host + ":" + port);
@ -233,10 +243,10 @@ public class EVDisplay extends JFrame {
String line; String line;
line = evd.in.readLine(); line = evd.in.readLine();
field = line.split("\t"); field = line.split("\t");
double X = Double.parseDouble(field[1]); double N = Double.parseDouble( field[1] );
double Y = Double.parseDouble(field[2]); double W = Double.parseDouble( field[2] );
double H = Double.parseDouble(field[3]) + 1.570796325; double H = Double.parseDouble( field[3] );
vehicle.setState(X,Y,H); vehicle.setState(N,W,H);
} catch (IOException | NullPointerException e ) { } catch (IOException | NullPointerException e ) {
go = false; go = false;