4 on any new /initialpose, do full rotation, then delay (to hone in amcl) 6 follow something ~15th pose in global path for all moves (about 0.3m away?) 7 -maximum path length seems to be about 35*5 (45*5 max) for 2-3 meter path 8 -(longer if more turns -- go for 15th or 20th pose, or max if less, should be OK) 10 ignore local path, except for determining if at goal or not 11 if no recent local path, must be at goal: followpath = False, goalpose = true 13 requires dwa_base_controller, global path updated continuously as bot moves 19 import oculusprimesocket
20 from nav_msgs.msg
import Odometry
22 from nav_msgs.msg
import Path
23 from geometry_msgs.msg
import PoseWithCovarianceStamped
25 from move_base_msgs.msg
import MoveBaseActionGoal
40 minturn = math.radians(8)
49 globalpathposenum = 20
54 global goalpose, lastpath
56 lastpath = rospy.get_time()
60 global targetx, targety, targetth , followpath, pathid
66 if n-1 < globalpathposenum:
69 p = data.poses[globalpathposenum]
71 targetx = p.pose.position.x
72 targety = p.pose.position.y
73 quaternion = ( p.pose.orientation.x, p.pose.orientation.y,
74 p.pose.orientation.z, p.pose.orientation.w )
75 targetth = tf.transformations.euler_from_quaternion(quaternion)[2]
78 pathid = data.header.seq
81 global odomx, odomy, odomth
82 odomx = data.pose.pose.position.x
83 odomy = data.pose.pose.position.y
84 quaternion = ( data.pose.pose.orientation.x, data.pose.pose.orientation.y,
85 data.pose.pose.orientation.z, data.pose.pose.orientation.w )
86 odomth = tf.transformations.euler_from_quaternion(quaternion)[2]
91 (trans,rot) = listener.lookupTransform(
'/map',
'/odom', rospy.Time(0))
92 quaternion = (rot[0], rot[1], rot[2], rot[3])
93 tfth = tf.transformations.euler_from_quaternion(quaternion)[2]
98 if data.pose.pose.position.x == 0
and data.pose.pose.position.y == 0:
108 global goalth, goalpose, lastpath, initialturn, followpath, nextmove
111 lastpath = rospy.get_time()
115 data = d.goal.target_pose
116 quaternion = ( data.pose.orientation.x, data.pose.orientation.y,
117 data.pose.orientation.z, data.pose.orientation.w )
118 goalth = tf.transformations.euler_from_quaternion(quaternion)[2]
121 nextmove = lastpath + 2
126 if len(data.status_list) == 0:
128 status = data.status_list[len(data.status_list)-1]
129 if status.status == 1:
132 def move(ox, oy, oth, tx, ty, tth, gth):
133 global followpath, goalpose, tfth, pathid, initialturn, waitonaboutface
134 global odomx, odomy, odomth
136 currentpathid = pathid
143 distance = math.sqrt( pow(dx,2) + pow(dy,2) )
147 th = math.acos(dx/distance)
159 dth = -math.pi*2 + dth
161 dth = math.pi*2 + dth
164 if distance > 0
and distance < minlinear:
167 if distance > maxlinear:
171 if dth < minturn*0.5
and dth > -minturn*0.5:
173 elif dth >= minturn*0.5
and dth < minturn:
175 elif dth <= -minturn*0.5
and dth > -minturn:
181 if abs(dth) > 2.0944
and not goalrotate
and not initialturn
and waitonaboutface < 1:
190 if not pathid == currentpathid:
202 rospy.sleep(distance/meterspersec)
218 rospy.init_node(
'global_path_follower', anonymous=
False)
221 rospy.on_shutdown(cleanup)
223 rospy.Subscriber(
"odom", Odometry, odomCallback)
224 rospy.Subscriber(
"move_base/DWAPlannerROS/local_plan", Path, pathCallback)
225 rospy.Subscriber(
"move_base/goal", MoveBaseActionGoal, goalCallback)
226 rospy.Subscriber(
"move_base/status", GoalStatusArray, goalStatusCallback)
227 rospy.Subscriber(
"move_base/DWAPlannerROS/global_plan", Path, globalPathCallback)
228 rospy.Subscriber(
"initialpose", PoseWithCovarianceStamped, intialPoseCallback)
238 while not rospy.is_shutdown():
243 if goalseek
and (followpath
or goalpose):
244 move(odomx, odomy, odomth, targetx, targety, targetth, goalth)
245 nextmove = rospy.get_time() + listentime
def waitForReplySearch(pattern)
def goalStatusCallback(data)
def intialPoseCallback(data)
def globalPathCallback(data)
def move(ox, oy, oth, tx, ty, tth, gth)