armarx_localization_and_mapping HowTos

How To

Record a new map

Preparation

  • make sure the room is cleaned up
  • if there is no map excisting yet, define an easy to detect world frame in the room (ideally a corner). If there is already an excisting map, use the coordinate system shown in the previous map

Recording of the map

  1. turn on the robot, start start all scenarios on the planning PC necessary for
    • moving the robot
    • mapping and localization
    • ArViz
  2. start ArViz
  3. Either:
    • If you want to create a new map for a known environment: ensure that the robot is localized in the existing map. In the PlatformUnitGui (position tab), you can read out the robot's current global pose. Note down those numbers.
    • If you create a map for an unknown environment:
      • define the world frame (some corner that can be identified in the occupancy grid)
      • optional: rotate the robot so that its orientation matches the world frame sleected in the preparation
  4. Either (depending on the available scenarios - might differ between robots):
    • legacy: in the scenario manager adapt the properties of cathographer_mapping_and_localization componentent. Set the property mode to mapping (instead of localization)
    • preferred: If there are already two instances of the cathographer_mapping_and_localization componentent available in the scenario: disable the localization.cathographer_mapping_and_localization component and enable mapping.cathographer_mapping_and_localization.
  5. the newly recorded map will later be saved on the planning PC under $WORKSPACENAME/h2t/PriorKnowledgeData/data/PriorKnowledgeData/maps/cartographer and named after the date and time of the recording. There is also a property mapStorageSubDir which you can set relative to the aforementioned path. This will then be the default when starting the component (but can be changed in the RemoteGUI later on).
GUI: set property of mapping
  1. restart the scenario and check in log that everything is running correctly
  2. now ArViz visualization should not contain old map anymore, but laserscanner data
  3. you should see how the map is generated when moving the robot
GUI: ArViz while generating map
  1. drive the robot through the room you want to record. Make sure that you visit all locations that the robot will have to reach autonomously. This will improve localization accuracy.
  2. when all parts of the room are covered, open the RemoteGUI widget in ArViz
  3. under the CartographerMappingAndLocalization tab press the button Create map! to end the recording process and safe the map {-update description and image to new state-}. There you will also find the path where the map will be saved. Ensure that it is correct. Otherwise you will have to move the files on the disk.
GUI: Create map using the remote GUI

Postprocessing

  • Ensure that the new map files (.carto and .json file) are in the correct folder (i.e., the maps for R005 can be found under /h2t/PriorKnowledgeData/data/PriorKnowledgeData/maps/cartographer/50_19/R005). You can have a look at the CartographerMappingAndLocalization's log. If not: move the files before adding them to git.
  • A map is represented by two files having the same file name but different file endings. The .carto file is a binary file containing the map itself, while the .json file registers the map relative to the world frame.
  • to use the new map, again modify the properties of the localization.cathographer_mapping_and_localization component.
    • Legacy: First, make sure mode is set back to localization instead of mapping.
    • Adapt the ArmarX.CartographerMappingAndLocalization.map_to_load.path property so that the path matches the path to the newly recorded .carto file
  • take a look at the map (and the objects) in ArViz. Identify the world frame. If the world frame is not at the correct position (and the object positions do not match yet), open the new .json file and x,y and yaw values so that the map matches the locations of the object models. Eventually, you have to update the location of the objects if they have been moved around.
  • then localize the robot using the laserscanner as usual