Revision bdac5bec devices/DiWheelDrive/userthread.cpp

View differences:

devices/DiWheelDrive/userthread.cpp
785 785
      // Test suit for amiro map
786 786

  
787 787

  
788
      setAttributes(global.testmap, 0, 1, 2, 1);
789
      setAttributes(global.testmap, 1, 2, 2, 0);
790
      setAttributes(global.testmap, 2, 1, 0, 0);
791
      setAttributes(global.testmap, 3, 0, 0, 0xff);
788

  
792 789
      // AmiroMap map = AmiroMap(&global);
793 790

  
794 791
      // --------------------------------------------------
795 792

  
796 793
      global.tcase = 0;
797
      map.initialize();
794
      // Set basic valid map configuration
795
      setAttributes(global.testmap, 0, 1, 2, 1);
796
      setAttributes(global.testmap, 1, 2, 2, 0);
797
      setAttributes(global.testmap, 2, 1, 0, 0);
798
      setAttributes(global.testmap, 3, 0, 0, 0xff);
799
      chprintf((BaseSequentialStream *)&global.sercanmux1, "Init Case: %d, res: %d\n",global.tcase, map.initialize());
798 800
      global.testres[global.tcase] = map.get_state()->valid;
799 801

  
800
        global.tcase++; // 1
802
      global.tcase++; // 1
803
      // Test map fail if first node is flagged with end
801 804
      setAttributes(global.testmap, 0, 1, 2, 0xff);
802 805
      map.initialize();
803 806
      global.testres[global.tcase] = !map.get_state()->valid;
804 807

  
805 808
      global.tcase++; // 2
809
      // Test if node 2 is set as start node
806 810
      setAttributes(global.testmap, 0, 1, 2, 0);
807 811
      setAttributes(global.testmap, 2, 1, 0, 1);
808 812
      map.initialize();
809 813
      global.testres[global.tcase] = map.get_state()->current == 2;
810 814

  
811 815
      global.tcase++; // 3
816
      // Test if non reachable nodes will trigger invalid map
812 817
      setAttributes(global.testmap, 3, 0, 0, 0);
813 818
      setAttributes(global.testmap, 4, 0, 0, 0xff);
814 819
      map.initialize();
815 820
      global.testres[global.tcase] = !map.get_state()->valid;
816 821

  
822
      global.tcase++; // 4
823
      // Test Reinitialization
824
      setAttributes(global.testmap, 0, 1, 2, 1);
825
      setAttributes(global.testmap, 1, 2, 2, 0);
826
      setAttributes(global.testmap, 2, 1, 0, 0);
827
      setAttributes(global.testmap, 3, 0, 0, 0xff);
828
      map.initialize();
829
      global.testres[global.tcase] = map.get_state()->valid;
830

  
831
      global.odometry.resetPosition();
832
      uint8_t ret = 0;
833
      global.tcase++; // 5
834
      // Test update under normal linefollowing without fixpoint
835
      ret = map.update(20000, 20000, LineFollowStrategy::EDGE_RIGHT);
836
      chprintf((BaseSequentialStream *)&global.sercanmux1,
837
               "Update test %d: Ret %d, cur %d, nex %d\n", global.tcase, ret,
838
               map.get_state()->current, map.get_state()->next);
839
      // No case should be true because neither was a node visited nor
840
      // was a fixpoint detected.
841
      global.testres[global.tcase] = (ret == 0x4);
842

  
843

  
844
      global.odometry.setPosition(1.0, 0.0, 0.0);
845
      global.tcase++; // 6
846
      // Fixpoint on left side
847
      ret = map.update(0, 20000, LineFollowStrategy::EDGE_RIGHT);
848
      chprintf((BaseSequentialStream *)&global.sercanmux1,
849
               "Update test %d: Ret %d, cur %d, nex %d\n", global.tcase, ret,
850
               map.get_state()->current, map.get_state()->next);
851
      // No case should be true because neither was a node visited nor
852
      // was a fixpoint detected.
853
      // global.odometry
854
      global.testres[global.tcase] = (ret == 0x1)
855
        && (map.get_state()->strategy == 0x01)
856
        && (map.get_state()->dist == 0)
857
        && (map.get_state()->current == 2);
858

  
859

  
860
      global.odometry.setPosition(1.5, 0.0, 0.0);
861
      global.tcase++; // 7
862
      // Fixpoint on left side, no update should appear because fixpoint already
863
      // marked
864
      ret = map.update(0, 20000, LineFollowStrategy::EDGE_RIGHT);
865
      chprintf((BaseSequentialStream *)&global.sercanmux1,
866
               "Update test %d: Ret %d, cur %d, nex %d\n", global.tcase, ret,
867
               map.get_state()->current, map.get_state()->next);
868
      // No case should be true because neither was a node visited nor
869
      // was a fixpoint detected.
870
      global.testres[global.tcase] = (ret == 0x00)
871
        && (map.get_state()->strategy == 0x01);
872
        // && (map.get_state()->dist == 0);
873

  
874

  
875

  
876

  
877

  
817 878
      int failed = 0;
818 879
      int passed = 0;
819 880
      for (int i = 0; i <= global.tcase; i++) {

Also available in: Unified diff