DaniGarciaLopez / ros2_explorer

In this repo we use Turtlebot 3 along with ROS 2 and Gazebo to explore an unknown csv environment, navigate through it and create a map
82 stars 21 forks source link

nav.launch.py fails due to recoveries_server package not being avail on humble #5

Closed altineller closed 1 year ago

altineller commented 1 year ago

Hello, I am on ros humble, and nav.launch.py fails due to recoveries_server package not being avail on humble. Is there any solution or substitution to this? Best Regards, Can

DaniGarciaLopez commented 1 year ago

Hi @altineller,

Nav2 recovery sever was renamed to behavior server from Galactic to Humble (check the migration guide). This repo doesn't do any changes to Nav2 so the fix should be pretty straight forward, just take a recent nav2 launch file and do the correct remappings to the turtlebot3.

Currently I don't have time to keep updating this repo, but if you want to open PR with the Humble corrections I will be happy to take a look!

altineller commented 1 year ago

Hello @DaniGarciaLopez

Using default navigation_launch from ros humble, I made it somehow work.

Wanderer mode works, I had to tune the speed - and distance_from_wall - to avoid crashing to wall. From reading your code I understand that wanderer is a simple random graph explorer, where each time an obstacle is detected, robot performs a turn, and decide to go in some other way. I have some questions though:

About wanderer:

The listener callback has the following statements: self.forward_distance = msg.ranges[0] self.left_distance = msg.ranges[90] self.back_distance = msg.ranges[180] self.right_distance = msg.ranges[270] self.left_forward_distance = msg.ranges[45] self.right_forward_distance = msg.ranges[315]

Here we just measure some points in different directions, but just one data point per angle? is that true?

The distance_from_wall is in meters, but at init we have self.forward_distance = 1000.0 - those are just initialized to a large number?

About discovery_server:

It makes a call to cartographer, and gets the occupancy grid, and decides where to move, then submits a goal to nav server. My nav server works, and robot reaches points when given over rviz, but with the discoverer_server, it always fails with Goal failed with status: 6 - I have searched for this fail code but have not been able to find it. Could it be for example timeout?

Also, could you elaborate on the function of watchtower? Is this used when we are exploring a known map, and it gives the percentage of map exploration or some other testing function? Currently I am not using the watchtower as I am running it on my separate gazebo setup and only using the discoverer_server and manager.

Finally, I would be very interested in maintaining this package or a rewrite of it, I think I could do it with a little support.

Thanks for the good work.

Best Regards, Can Altineller

DaniGarciaLopez commented 1 year ago

Glad you made it work on humble!

From reading your code I understand that wanderer is a simple random graph explorer, where each time an obstacle is detected, robot performs a turn, and decide to go in some other way. I have some questions though:

Yes, wanderer mode measures the nearest obstacle and performs a random turn to avoid collision.

Here we just measure some points in different directions, but just one data point per angle? is that true?

You're right, it just measures one point per angle within the LaserScan range. Due to this project was aimed to run in simulation, this method was enough for us. For a real world robot, where you have noisy sensor, I would suggest changing those lines because the angle you're measuring might be an outlier. Maybe spliting the ranges field into 6 sets, filter out the outliers and get the closest distance per set.

The distance_from_wall is in meters, but at init we have self.forward_distance = 1000.0 - those are just initialized to a large number?

Yes, just a quick and dirty initialization to a large value.

My nav server works, and robot reaches points when given over rviz, but with the discoverer_server, it always fails with Goal failed with status: 6 - I have searched for this fail code but have not been able to find it. Could it be for example timeout?

The status code 6 stands for STATUS_ABORTED which means that the goal was terminated by the action server without an external request (source). It might be because of a timeout on the server, but without replicating the error I cannot give you further assitance

Also, could you elaborate on the function of watchtower? Is this used when we are exploring a known map, and it gives the percentage of map exploration or some other testing function?

The watchtower nodes compares the surface of the simulated map with the current map to send a signal to stop exploring when a certain threshold has been reached. It only makes sense to use it when you know in advance the size of your map or you only want to map a certain surface. To automatically stop the exploration you might want to use something like the watchtower or, for example, by the time spent in the exploration. Although is perfectly fine to manually stop the exploration, depends on your usecase.

Finally, I would be very interested in maintaining this package or a rewrite of it, I think I could do it with a little support.

Most of the values of this package are hardcoded and it would be necessary to refactor it to be easily applied to other robots and environments. If you feel like it, I'd be happy to look at your changes!

altineller commented 1 year ago

Hi @DaniGarciaLopez

I have also solved the STATUS_ABORTED problem from the action server. I noticed a TF warning error from the navigation stack, and in the lines where we send the goal:

    # write command
    goal_msg = NavigateToPose.Goal()
    goal_msg.pose.pose.position.x = float(waypoint[0])
    goal_msg.pose.pose.position.y = float(waypoint[1])
    # goal_msg.pose.pose.orientation.w = 1.0

we also need to add: goal_msg.pose.header.frame = 'base_footprint'

Because the nav server in humble expects a frame. Once a frame in header is defined, the action server will not return status 6 any more.