The sequence is to use Rviz to assign 3 spots first, and then the bot is expected to move between these 3 spots infinitely. But this not happened. After 3 spots were assigned and movement was completed, the bot stayed at the third point.
send_goal_client.py
#! /usr/bin/env python
import rospy
import time
import actionlib
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal, MoveBaseActionResult, MoveBaseFeedback
goal = MoveBaseGoal()
feedback = MoveBaseFeedback()
result = MoveBaseActionResult()
count = 0
i = 0
rospy.init_node(‘three_spots_cycler’)
client = actionlib.SimpleActionClient(’/move_base’, MoveBaseAction)
client.wait_for_server()
while True:
if result.status.status == 3:
count += 1
i += 1
gi = feedback.base_position.pose
continue
if count>2 and count%3 == 0:
goal.target_pose.header.frame_id = 'map'
goal.target_pose.pose = g1
client.send_goal(goal)
client.wait_for_result()
continue
if count>2 and count%3 == 1:
goal.target_pose.header.frame_id = 'map'
goal.target_pose.pose = g2
client.send_goal(goal)
client.wait_for_result()
continue
if count>2 and count%3 == 2:
goal.target_pose.header.frame_id = 'map'
goal.target_pose.pose = g3
client.send_goal(goal)
client.wait_for_result()
continue
three_spots_cruiser.launch
launch>
!-- Run the map server →
arg name=“map_file” default="$(find husky_navigation)/maps/my_map.yaml"/>
node name=“map_server” pkg=“map_server” type=“map_server” args="$(arg map_file)" />
!-- Run the cruiser -->
node name=“three_spots_cycler” pkg=“send_goals” type=“send_goal_client.py” output=“screen” />
!— Run AMCL →
include file="$(find husky_navigation)/launch/amcl.launch" />
!— Run Move Base →
include file="$(find husky_navigation)/launch/move_base.launch" />
/launch>
p.s.: “<” somehow makes the launch file content invisible, so it is intentionally deleted.