麥輪車巡線

freedragon發表於2024-03-12

from uexplore_interfaces import Event
from uexplore_interfaces import AIVision
from uexplore_interfaces import Screen
from uexplore_interfaces import Model
from uexplore_interfaces import Math
import math
from uexplore_interfaces import Utils

_E6_88_91_E7_9A_84_E5_8F_98_E9_87_8F = 0
_E6_97_8B_E8_BD_AC_E5_80_BC = 0


def on_start_event():
  global _E6_97_8B_E8_BD_AC_E5_80_BC

  AIVision.load_model([AIVision.Model.track_recognition])
  AIVision.set_track_recognition_line(AIVision.LineType.single)
  while True:
      _E6_97_8B_E8_BD_AC_E5_80_BC = (0.25 * AIVision.get_single_track_offset())
      Screen.print_text_newline(((str('單軌偏移量:') + str(AIVision.get_single_track_offset()))),Screen.Color.white)
      Model.mecanum_move_xyz(0,20,Math.round_up(Utils.parseToNumber(_E6_97_8B_E8_BD_AC_E5_80_BC)))
      if (AIVision.check_single_track_intersection(AIVision.Intersection.noline)):
          Model.mecanum_stop()
          break

      Screen.print_text_newline(((str('旋轉值:') + str(Utils.parseToNumber(_E6_97_8B_E8_BD_AC_E5_80_BC)))),Screen.Color.yellow)

Event.register_start(on_start_event)

 

  

相關文章