Hi @sree,
I will do my best to answer properly all your questions.
- If you want to save all your goals at once and execute each sequentially you can use a
move_base_msgs::MoveBaseGoal goal
vector and store each goal in it. You also can read them as parameter from a yaml file with the ROS parameter server. Then in the code just perform a loop for each vector goal, waiting for result and resuming in the next step when the action server returns a success. Since the move_base is based on the actionlib
paradigm you will be able to check goal status and success state in each moment, cancel goals and traverse the vector in the order you decide. - Simulation are just approximations to real life. You can expect that you real robot is going to behave relatively equal than in the simulation but you need to understand that there are a lot of variables that are not present in the simulation and can variate the output in real life. For instance, sensor reading errors (that in simulation tend to be perfect), constrained movement (traversed floor or any mechanical problem the robot has), etc. For this reason you may end adjusting several params and configuration to suit not only your robot/sensor but also you environment.
- Hope solution 1. helps you with it.
Regards.
EDIT:
In order to give a use case for the approach 1 I will post a chunk of code.
Disclaimer: I am not an expert on using action_lib
with python, the functioning is strictly different when comparing roscpp
and rospy
. There may be solutions that are better and more suitable in this environment, but as a simple example I think it would be good.
First of all, since you want to have a set of goals at once you can load them with a yaml file and parameter server, this can be a good points.yaml
config file to parametrize all your goals:
point_list: [
{x_pos: 1.0, y_pos: 1.0, z_pos: 0.0, w: 1.0},
{x_pos: 2.0, y_pos: 2.0, z_pos: 0.0, w: 1.0},
{x_pos: 3.0, y_pos: 3.0, z_pos: 0.0, w: 1.0},
{x_pos: 4.0, y_pos: 4.0, z_pos: 0.0, w: 1.0}
]
Take into account that you can convert this param to a simple vector instead of a dictionary.
Second, I changed the code you linked a bit so I can iterate all the goal list, and then pass every goal to the move_base
server to process:
#!/usr/bin/env python
# license removed for brevity
import rospy
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
import actionlib
from actionlib_msgs.msg import *
class GoForwardAvoid():
def __init__(self):
rospy.init_node('nav_test', anonymous=False)
#what to do if shut down (e.g. ctrl + C or failure)
rospy.on_shutdown(self.shutdown)
self._point_list = rospy.get_param('/nav_test/point_list')
self._sleep_timer = rospy.Rate(5.0)
def spin(self):
#tell the action client that we want to spin a thread by default
self.move_base = actionlib ...
(more)