ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
The problem has nothing to do with rviz but rather these lines:
self.publisher_ = self.create_publisher(PoseWithCovarianceStamped , '/initialpose', 10)
self.pose_callback()
self.publisher_ = self.create_publisher(PoseStamped , '/goal_pose', 10)
self.goal_callback()
Please refer to ROS2 Writing a simple publisher and subscriber (Python) to better understand how to create publishers and subscribers.
In your code, the same publisher object self.publisher_
is publishing on two topics: /initialpose
and /goal_pose
.
Also, a callback function has to be tied to a subscriber. For every message that arrives on the topic, that callback function gets executed. In your code, the methods pose_callback()
and goal_callback()
are not really callbacks but just methods that get executed only once: minimal_publisher = MinimalPublisher()
.