Example Programs
Recording Service Command Line
This program demonstrates how to record a new Graph Nav map.
Setting up for Recording
Before you start, make sure that the robot is in a location where it can see a fiducial. The robot will later use this fiducial to initialize to the map.
The recording_command_line example does not require a robot lease, and does not acquire the estop of the robot. It passively runs while another service (such as the tablet, or another example) controls the robot. So, before you run this example, you should be connected to the robot via a tablet (if available), or some other service which is able to drive the robot.
How to Run
To run the example:
python3 -m recording_command_line --download-filepath <path_to_downloaded_map> ROBOT_IP
Note that the download-filepath
command line argument must be a full path. This argument is optional; if not provided, then the current working directory will be used. When a map is downloaded, it will be downloaded into a subfolder called downloaded_graph
in the specified folder the layout is:
download-filepath
- downloaded_graph
- graph # Serialized protobuf containing the waypoints and edges.
- waypoint_snapshots # Large sensor data associated with waypoints.
- snapshot_... # Waypoints may share snapshots. The IDs of snapshots are unrelated to the IDs of waypoints.
- snapshot_...
- edge_snapshots # Large sensor data associated with edges.
- edge_snapshot_...
Using the Example to Record a Map
Running the recording command line example shows a prompt with options. Type a number or letter and press enter to execute one of the options. Here are the options you should see:
Options:
(0) Clear map.
(1) Start recording a map.
(2) Stop recording a map.
(3) Get the recording service's status.
(4) Create a default waypoint in the current robot's location.
(5) Download the map after recording.
(6) List the waypoint ids and edge ids of the map on the robot.
(7) Create new edge between existing waypoints using odometry.
(8) Create new edge from last waypoint to first waypoint using odometry.
(9) Automatically find and close loops.
(a) Optimize the map's anchoring.
(q) Exit.
To record a basic map, do the following:
Using the tablet or another service, stand the robot up.
Enter 1 to start recording a map.
Using the tablet or another service, walk the robot around.
Enter 2 to stop recording a map.
Enter 5 to download the map. It will be saved to the download directory.
Enter q to quit the application.
Advanced Usage
Simply starting and stopping recording will cause the recording service to create a chain of waypoints and edges from the start to the end. This means that the robot can only walk along this chain (as if it were on a rail). However, the recording service is also capable of making branches and loops.
To manually create an edge, use option 7. This will prompt you for two waypoint ids (which you can find using option 6, or using the view_map.py example after you download the map). It will create an edge using these two waypoints and kinematic odometry as a guess to how those two waypoints are connected.
You can also create an edge between the start and end of a chain by using option 8. This is commonly used when a robot returns back to the location it started recording in.
Option 9 allows the recording service to automatically identify and close loops (including at the start and end of the map), using fiducials, odometry, and other methods (see here for details.)
Option a creates an anchoring for the map, which allows it to be more accurately drawn and used for data export (see here for more details.)