Ex. 4.4 - why bot not moves between 3 spots?

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.


#! /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


client = actionlib.SimpleActionClient(’/move_base’, MoveBaseAction)


while True:

if result.status.status == 3:

    count += 1

    i += 1

    gi = feedback.base_position.pose


if count>2 and count%3 == 0:

    goal.target_pose.header.frame_id = 'map'

    goal.target_pose.pose = g1




if count>2 and count%3 == 1:

    goal.target_pose.header.frame_id = 'map'

    goal.target_pose.pose = g2




if count>2 and count%3 == 2:

    goal.target_pose.header.frame_id = 'map'

    goal.target_pose.pose = g3






!-- 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" />


p.s.: “<” somehow makes the launch file content invisible, so it is intentionally deleted.

Hello @Kane168 ,

From what I see in your code, the program is never entering any of the if statements you have. The first if statement depends on the result value, but this value is never updated, it’s just being initialized:

result = MoveBaseActionResult()

Therefore, the other if statements will never be triggered neither.

Thanks Alberto. Does this mean I need to assign an initial value to result?

Another inquiry. Will it be an issue that there is no definition for the result in MoveBase.action file (under /opt/ros/noetic/share/move_base_msgs/action)?

geometry_msgs/PoseStamped target_pose

geometry_msgs/PoseStamped base_position

Hello @Kane168 ,

No, what you have to do is to capture the result returned by the Action Server. Even though the message does not have a result variable (like you show in your post), the result is still generated. I’d suggest you have a look at the ROS Basics in 5 Days course, where actions are covered more in-depth so that you can get a better idea.

Though I have completed the course you mentioned, maybe something important is missed.
I will take a look.