# Set initial pose
initial_pose = navigator.getPoseStamped([
0.0
,
0.0
], TurtleBot4Directions.NORTH)
navigator.setInitialPose(initial_pose)
# Wait for Nav2
navigator.waitUntilNav2Active()
# Set goal poses
goal_pose = navigator.getPoseStamped([
13.0
,
5.0
], TurtleBot4Directions.EAST)
# Undock
navigator.undock()
# Go to each goal pose
navigator.startToPose(goal_pose)
rclpy.shutdown()
Initialise the node
We start by initialising
rclpy
and creating the
TurtleBot4Navigator
object. This will initialise any
ROS2 publishers, subscribers and action clients that we need.
rclpy.init()
navigator = TurtleBot4Navigator()
Dock the robot
Next, we check if the robot is docked. If it is not, we send an action goal to dock the robot. By
docking the robot we guarantee that it is at the [0.0, 0.0] coordinates on the map.
if not
navigator.getDockedStatus():
navigator.info(
'Docking before intialising pose'
)
navigator.dock()
Set the initial pose
Now that we know the robot is docked, we can set the initial pose to [
0.0
,
0.0
], facing "North".
initial_pose = navigator.getPoseStamped([
0.0
,
0.0
], TurtleBot4Directions.NORTH)
navigator.setInitialPose(initial_pose)
Summary of Contents for TurtleBot 4 Lite
Page 50: ...Running the Light Ring test...
Page 61: ...Adding Displays in Rviz2...
Page 63: ...Camera image displayed in Rviz2...
Page 82: ...TurtleBot 4 Lite with a NED2 arm...
Page 147: ...Color camera diagnostics...