CLEARPATH Turtlebot4 User Manual page 134

Table of Contents

Advertisement

# 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
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
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)
rclpy
and creating the
TurtleBot4Navigator
pose')
object. This will initialise any

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Turtlebot4 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Turtlebot 4 lite

Table of Contents