Skip to content

Commit

Permalink
Improved steps and aliases for cartographer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-robb committed Oct 24, 2023
1 parent 49a8dde commit 6705501
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
34 changes: 34 additions & 0 deletions locobot_bash_aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,37 @@ alias test_motion="rostopic pub --once /locobot/mobile_base/commands/velocity ge
# Record a bag with the standard name.
alias record_bag="rosbag record --output-name=~/data/test_bag.bag -a"

# Save and view the TF tree.
view_tf_frames() {
rosrun tf view_frames
evince frames.pdf
}

# Setup static transforms for cartographer to work.
setup_static_tf() {
rosrun tf static_transform_publisher 0 0 0 0 0 0 base_link camera_depth_frame 100 &
rosrun tf static_transform_publisher 0 0 0 0 0 0 base_link target_frame 100 &
rosrun tf static_transform_publisher 0 0 0 0 0 0 locobot/laser_frame_link laser 100 &
rosrun tf static_transform_publisher 0 0 0 0 0 0 locobot/laser_frame_link locobot/base_link 100 &
}
# Kill the static transform publishers in the background.
alias kill_static_tf_pubs="pkill static_transform_publisher"
# Alternatively, search for them with
# ps -eaf | grep static_transform_publisher
# or
# pgrep static_transform_publisher
# then for each process ID, run
# kill <process_id>

# Start cartographer.
start_cartographer() {
cd ~/cartographer_ws
source install_isolated/setup.bash
roslaunch cartographer_ros my_robot.launch
}

# Save and view a map being created by cartographer.
save_map() {
rosrun map_server map_saver -f mapname
feh mapname.pgm
}
4 changes: 3 additions & 1 deletion locobot_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ rosrun tf static_transform_publisher 0 0 0 0 0 0 base_link target_frame 100
rosrun tf static_transform_publisher 0 0 0 0 0 0 locobot/laser_frame_link laser 100
rosrun tf static_transform_publisher 0 0 0 0 0 0 locobot/laser_frame_link locobot/base_link 100
```
Note that you can analyze the tf tree by running `rosrun tf view_frames`.
Note that you can analyze the tf tree by running `rosrun tf view_frames`. This will generate a file `frames.pdf` in the current working directory, which you can quickly view with `evince frames.pdf`.

3. Now we need to control the robot to drive around the space. We can do this using the built-in turtlebot keyboard control node, or start our own node to command random/test motions. These methods are described in prior sections of this document.

4. At any point while it's running, we can run the following command on the host PC to save the current map being built.
```
rosrun map_server map_saver -f mapname
```
This will save the map image as `mapname.pgm`, as well as some descriptive info to `mapname.yaml`. We can quickly view the map image with the command `feh mapname.pgm`.

<p align="center">
<img src="images/carto_first_map.png"/>

Expand Down

0 comments on commit 6705501

Please sign in to comment.