Skip to content

Commit c70e283

Browse files
Add files via upload
1 parent dcd8f6b commit c70e283

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

gotoXY_straight.py

+8-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def __init__(self):
1919
self.pose = Odometry()
2020
self.rate = rospy.Rate(10)
2121

22-
2322

2423
#Callback function implementing the pose value received
2524
def callback(self, data):
@@ -28,16 +27,9 @@ def callback(self, data):
2827
self.pose.pose.pose.position.y = round(self.pose.pose.pose.position.y, 4)
2928
quaternion = (self.pose.pose.pose.orientation.x, self.pose.pose.pose.orientation.y, self.pose.pose.pose.orientation.z, self.pose.pose.pose.orientation.w)
3029
euler = tf.transformations.euler_from_quaternion(quaternion)
31-
roll = euler[0]
32-
pitch = euler[1]
3330
global yaw
3431
yaw = euler[2]
3532

36-
37-
def get_distance(self, goal_x, goal_y):
38-
distance = sqrt(pow((goal_x - self.pose.position.x), 2) + pow((goal_y - self.pose.position.y), 2))
39-
return distance
40-
4133
def move2goal(self):
4234
#goal_pose = Pose()
4335
goal_pose = Odometry()
@@ -67,15 +59,15 @@ def move2goal(self):
6759
# sets the direction of turn
6860
clockwise = False
6961
if (direction - yaw) <= math.pi:
70-
if abs(direction - yaw) > 0:
71-
clockwise = False
72-
else:
73-
clockwise = True
62+
if abs(direction - yaw) > 0:
63+
clockwise = False
64+
else:
65+
clockwise = True
7466
if (direction - yaw) > math.pi:
75-
if abs(direction - yaw) > 0:
76-
clockwise = True
77-
else:
78-
clockwise = False
67+
if abs(direction - yaw) > 0:
68+
clockwise = True
69+
else:
70+
clockwise = False
7971

8072
#Turns the robot
8173
while abs(yaw - direction) >= angle_tolerance:
@@ -110,8 +102,6 @@ def move2goal(self):
110102
target_distance = math.sqrt((goal_pose.pose.pose.position.x-self.pose.pose.pose.position.x)**2 + (goal_pose.pose.pose.position.y-self.pose.pose.pose.position.y)**2)
111103
current_distance = 0
112104

113-
'''
114-
while sqrt(pow((goal_pose.pose.pose.position.x - self.pose.pose.pose.position.x), 2) + pow((goal_pose.pose.pose.position.y - self.pose.pose.pose.position.y), 2)) >= distance_tolerance:'''
115105
while (target_distance - current_distance >= distance_tolerance):
116106

117107
#Proportional Controller

0 commit comments

Comments
 (0)