@@ -19,7 +19,6 @@ def __init__(self):
19
19
self .pose = Odometry ()
20
20
self .rate = rospy .Rate (10 )
21
21
22
-
23
22
24
23
#Callback function implementing the pose value received
25
24
def callback (self , data ):
@@ -28,16 +27,9 @@ def callback(self, data):
28
27
self .pose .pose .pose .position .y = round (self .pose .pose .pose .position .y , 4 )
29
28
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 )
30
29
euler = tf .transformations .euler_from_quaternion (quaternion )
31
- roll = euler [0 ]
32
- pitch = euler [1 ]
33
30
global yaw
34
31
yaw = euler [2 ]
35
32
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
-
41
33
def move2goal (self ):
42
34
#goal_pose = Pose()
43
35
goal_pose = Odometry ()
@@ -67,15 +59,15 @@ def move2goal(self):
67
59
# sets the direction of turn
68
60
clockwise = False
69
61
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
74
66
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
79
71
80
72
#Turns the robot
81
73
while abs (yaw - direction ) >= angle_tolerance :
@@ -110,8 +102,6 @@ def move2goal(self):
110
102
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 )
111
103
current_distance = 0
112
104
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:'''
115
105
while (target_distance - current_distance >= distance_tolerance ):
116
106
117
107
#Proportional Controller
0 commit comments