Skip to content

Quick Topological Navigation in simulation tutorial

Katherine James edited this page Jul 2, 2024 · 3 revisions

Getting started tutorial in simulation (ROS 1)

A tutorial on getting started with topo-nav in ROS 1 using the Riseholme vineyard_demo and thorvald simulator.

Set up a simulation:

We have a dockerized simulation available, or please use your own: https://github.com/LCAS/bacchus_lcas/wiki/Phenorob-2021-Setting-Up

roslaunch ./vineyard_demo.launch launch_move_base:=true

Topological navigation (in simulation):

Setup simulation with topo-nav:

  • git clone https://github.com/LCAS/topological_navigation into src
  • checkout bacchus branch for melodic (or noetic, use git branch -a)
  • catkin_make
  • sudo apt-get install ros-melodic-mongodb-store ros-melodic-rospy-message-converter

Topological map file creation:

  1. A metric map is required as a pre-requisite:

    Resource: https://github.com/LCAS/bacchus_lcas/wiki/Phenorob-2021-Activities

    Use gmapping or slam to create a metric map:

     roslaunch bacchus_slam hector_slam.launch
     roslaunch  bacchus_slam throvald_teleop.launch
     rosrun map_server map_saver -f my_map
    

    Note: to navigate using teleop, you must be clicked on the terminal. Use keys to drive, i is forward,l/j make it spin.

    Note2: map_saver doesn’t take too long - something may be wrong in the running of the slam script if it does. This outputs a yaml and a pgm where the line was run. Place these in bacchus_lcas/bacchus_slam/maps.

  2. Create the .tmap2 file:

    We now need to collect x,y,z positions for nodes and create .tmap2 file:

    Update ~/row_ws/src/bacchus_lcas/bacchus_slam/launch/amcl_localization.launch to use nav_map_yaml=my_map.yaml

     roslaunch bacchus_slam amcl_localization.launch
     rostopic echo /clicked_point
    

    Use the Publish Point tool in Rviz to click where you want nodes, these will be output to the terminal.

    Copy the template from: https://github.com/LCAS/environment_common/blob/main/environment_common/convertors/templating/tmap.py

    Modify this file to use the node values you have just received from /clicked_point. The first line should be meta: Note: {location} and {gentime} can be any strings and this file is EXTREMELY case and space sensitive!

Launch and visualise the topological map

Modify vineyard_demo.launch to use my_map.yaml and set X_INIT, Y_INIT and Z_INIT to 0.

  1. View topological map in Rviz

Then:

roslaunch ./vineyard_demo.launch launch_move_base:=true
rosrun topological_navigation map_manager2.py demo.tmap2 # publishes the file to a rostopic
rosrun topological_navigation topological_transform_publisher.py
rosrun topological_navigation visualize_map2.py

In Rviz:

  • Add markerarray: topological_map_visualisation
  • Add markerarray: topological_route_visualisation
  • NB: if you messed up the positions, they may be off the map.
  • Add interactivemarkers for go_to_node/update (add direction arrows to the nodes)

You can add edges:

rosservice call /topological_map_manager2/add_edges_between_nodes “
origin: node0
destination: node1
action: move_base
edge_id: stringid”

If edges should be bi-directional, another edge will need to be added with origin: node1, destination: node0.

And save the updates: rosservice call /topological_map_manager2/write_topological_map "filename: '`pwd`/updated.tmap2'"

  1. Use the topological map for navigation:

    rosrun topological_navigation localisation.py rosrun topological_navigation navigation.py