slam_toolbox map not updating
I am trying to create a map using data from a LiDAR (rplidar a1 model) that's plugged into my computer. The map will generate one time but it will not update when the lidar is moved. I think the issue probably has something to do with the transforms, but I don't know how to fix it. These are my steps:
- Launch the "rplidara1launch.py" file from the rplidar_ros package
- Launch the dynamic transform publisher for laser -> base_footprint. here is the file: import rclpy from rclpy.node import Node from tf2ros import TransformBroadcaster from geometrymsgs.msg import TransformStamped
class TransformPublisher(Node): def init(self): super().init('lasertransformpublisher') self.broadcaster = TransformBroadcaster(self)
self.timer = self.create_timer(0.1, self.publish_transform)
self.transformStamped = TransformStamped()
self.transformStamped.header.frame_id = 'base_footprint'
self.transformStamped.child_frame_id = 'laser'
self.transformStamped.transform.translation.x = 1.0
self.transformStamped.transform.rotation.w = 1.0
def publish_transform(self):
self.transformStamped.header.stamp = self.get_clock().now().to_msg()
self.broadcaster.sendTransform(self.transformStamped)
def main(args=None): rclpy.init(args=args) transformpublisher = TransformPublisher() rclpy.spin(transformpublisher) rclpy.shutdown()
if name == 'main': main()
- Launch the dynamic transform publisher for base_footprint -> odom. This is the file:
import rclpy from rclpy.node import Node from tf2ros import TransformBroadcaster from geometrymsgs.msg import TransformStamped
class TransformPublisher(Node): def init(self): super().init('odomtransformpublisher') self.broadcaster = TransformBroadcaster(self)
self.timer = self.create_timer(0.1, self.publish_transform)
self.transformStamped = TransformStamped()
self.transformStamped.header.frame_id = 'odom'
self.transformStamped.child_frame_id = 'base_footprint'
self.transformStamped.transform.translation.x = 1.0
self.transformStamped.transform.rotation.w = 1.0
def publish_transform(self):
self.transformStamped.header.stamp = self.get_clock().now().to_msg()
self.broadcaster.sendTransform(self.transformStamped)
def main(args=None): rclpy.init(args=args) transformpublisher = TransformPublisher() rclpy.spin(transformpublisher) rclpy.shutdown()
if name == 'main': main()
Launch slam_toolbox: ros2 launch slamtoolbox onlineasynclaunch.py usesim_time:=false
Launch rviz and add a map and laser frame. The map generates and I can see the LiDAR data moving on screen when I move the LiDAR. This line is printed in the terminal I launched rviz in: [INFO] [1690391887.815470686] [rviz2]: Trying to create a map of size 157 x 312 using 1 swatches
My TF tree goes laser, basefootprint, odom, map and it all looks good. The only notable thing is the average rate from map to odom is 50.218. My rqt graph has the laser transform, odom transform, and slamtoolbox all pointing to /tf. /tf is in a sqaure and has 2 arrows pointing to a transform listener and 2 more arrows pointing to a different transform listener.
Asked by user123 on 2023-07-26 15:16:10 UTC
Comments