Difference between revisions of "Trajectory from gyro/accellerometer/compas with 9DOF IMU (Michal Zemko, Peter Svitok)"

From RoboWiki
Jump to: navigation, search
(2. etapa)
(2. etapa)
Line 31: Line 31:
 
'''Nieco'''
 
'''Nieco'''
  
dfgadrgadrgsfdvdarbd
+
public class project{
srgardgdrgad
+
static int[] data_old=new int[9];
RGADRGDRGADRG
+
static int[] data_new=new int[9];
DARGADRGDG&SEKFJBESkj
+
ArrayList<Integer> array = new ArrayList<Integer>();
DAHDR&HG
+
    int startx=400;
 +
    int starty=300;
 +
    static int counter=0;
 +
 +
public project() {
 +
super();
 +
}
  
 +
    static JFrame frame = new JFrame("Points");
 +
 +
public class pokus extends JPanel{
 +
  public void paintComponent(Graphics g) {
 +
      //super.paintComponent(g);
 +
 +
      Graphics2D g2d = (Graphics2D) g;
 +
 +
      g2d.setColor(Color.black);
 +
 +
      Dimension size = getSize();
 +
      Insets insets = getInsets();
 +
 +
      int w =  size.width - insets.left - insets.right;
 +
      int h =  size.height - insets.top - insets.bottom;
 +
 +
      Random r = new Random();
 +
 +
//       int x = Math.abs(r.nextInt()) % w;
 +
//       int y = Math.abs(r.nextInt()) % h;
 +
      int x = data_new[0]-data_old[0];
 +
      int y = data_new[1]-data_old[1];
 +
      startx+=x;
 +
      starty+=y;
 +
      x=startx;
 +
      y=starty;
 +
      int x2 = 0;
 +
      int y2 = 0;
 +
     
 +
      if(((x>0)&&(x<800))&&((y>0)&&(y<600))){
 +
      array.add(x);
 +
      array.add(y);
 +
 +
      for(int i=0;i<array.size();i+=2){
 +
        x=array.get(i).intValue();
 +
        y=array.get(i+1).intValue();
 +
        if(i>1){
 +
        x2=array.get(i-2).intValue();
 +
        y2=array.get(i-1).intValue();
 +
        g2d.drawLine(x, y, x2, y2);
 +
        }
 +
        g2d.drawLine(x, y, x, y);
 +
      g2d.drawLine(x+1, y, x-1, y);
 +
      g2d.drawLine(x, y+1, x, y-1);
 +
      }
 +
      }
 +
  }
 +
}
 +
 
   
 
   
 
   
 
   

Revision as of 17:02, 28 June 2013

Zadanie

Trajectory from gyro/accellerometer/compas. Requirement: must use this part: 9DOF IMU

O súčiastke

9DOF IMU

V projekte sme mali využiť súčiastku 9DOF IMU a následne zo získaných dát vykresliť prejdenú trajektóriu robota.

Na doske 9DOF IMU sa nachádzajú nasledujúce komponenty:


Etapy

  • 1. Oboznamánie sa s projektom
  • 2. Naprogramovanie v Jave
  • 3. Záverečné prípravy

1. etapa

V prvej etape sme dostali súčiastku a cez program Putty skúšali jej funkčnosť.


9DOF IMU

2. etapa

Nieco

public class project{ static int[] data_old=new int[9]; static int[] data_new=new int[9]; ArrayList<Integer> array = new ArrayList<Integer>();

   int startx=400;
   int starty=300;
   static int counter=0;

public project() { super(); }

   static JFrame frame = new JFrame("Points");

public class pokus extends JPanel{ public void paintComponent(Graphics g) { //super.paintComponent(g);

Graphics2D g2d = (Graphics2D) g;

g2d.setColor(Color.black);

Dimension size = getSize(); Insets insets = getInsets();

int w = size.width - insets.left - insets.right; int h = size.height - insets.top - insets.bottom;

Random r = new Random();

// int x = Math.abs(r.nextInt()) % w; // int y = Math.abs(r.nextInt()) % h; int x = data_new[0]-data_old[0]; int y = data_new[1]-data_old[1]; startx+=x; starty+=y; x=startx; y=starty; int x2 = 0; int y2 = 0;

if(((x>0)&&(x<800))&&((y>0)&&(y<600))){ array.add(x); array.add(y);

for(int i=0;i<array.size();i+=2){ x=array.get(i).intValue(); y=array.get(i+1).intValue(); if(i>1){ x2=array.get(i-2).intValue(); y2=array.get(i-1).intValue(); g2d.drawLine(x, y, x2, y2); } g2d.drawLine(x, y, x, y); g2d.drawLine(x+1, y, x-1, y); g2d.drawLine(x, y+1, x, y-1); } } } }



nieco1

3. etapa