Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions STP move to point
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from communications.grsim import Grsim
from communications.vision import Vision
from classes.detection import Ball, Robot
vision : Vision = Vision()
import threading
import time
vision.initSocket("224.5.23.2", 10020) #Socket for grSim (10020) or SSL_Vision (10006)
vision_t = threading.Thread(target=vision.vision_loop)
vision_t.start()
time.sleep(1)

radio=Grsim()
def is_within_range(point1, point2) -> bool:
robot : Robot = vision.get_robot_by_id(0,"blue")
if 1 > distancia( point1, point2 ):
return True
return False

def distancia(punto1, punto2):
x1, y1 = punto1
x2, y2 = punto2
distancia = ((x2 - x1)**2 + (y2 - y1)**2)**0.5
return distancia


def seguir_camino(pto_inicial,pto_final):
dif_tuplas=(pto_final[0] - pto_inicial[0],pto_final[1] - pto_inicial[1])
vecdir=normalize_2d_vector(self, x,y)(dif_tuplas)
while True:
velocidad=vecdir
Comment on lines +29 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si la velocidad es igual al vecdir escalado, por que no me mejor escalarla en esa misma linea?

radio.communicate_grsim(0,0, veltangent=10*velocidad[0], velnormal=10*velocidad[1])
if is_within_range((Robot.posx,Robot.posy), pto_final):
break

seguir_camino((Robot.posx,Robot.posy),(2.3, -1.3))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Donde se define la variable Robot?