Robotics StackExchange | Archived questions

Create a new topic

I'm reading some distances and I want to use them to make a controller, so I read that the best way is to create a new topic, publish there the distances and subscribe to that topic with another node. I'm using Python.

How can I create a new topic? I mean, I have a lot of topics but I need one more

Edit: the topic would receive 7 positions/orientations from a marker: marker.pose.pose.position.x, marker.pose.pose.position.y, marker.pose.pose.position.z, marker.pose.pose.orientation.x, marker.pose.pose.orientation.y, marker.pose.pose.orientation.z, marker.pose.pose.orientation.w

Asked by Dylan on 2018-11-06 16:26:07 UTC

Comments

I hate to say it. But if you work through the python publisher tutorial it shows you exactly how to do this.

Asked by PeteBlackerThe3rd on 2018-11-06 19:02:24 UTC

No, it doesnt say how to create a new TOPIC. I invented a possible solution but its not optimal

Asked by Dylan on 2018-11-06 20:13:56 UTC

@PeteBlackerThe3rd is right, as soon as you create a publisher on a topic even if there are no nodes subscribed to it, it is created, hence it's a new topic.

Asked by Delb on 2018-11-07 02:06:21 UTC

According to your edit you just need to publish a geometry_msgs/Pose. Why does this solution isn't what you want ?

from geometry_msgs.msg import Pose
message pub = rospy.Publisher('chatter', Pose, queue_size=10)

Asked by Delb on 2018-11-07 02:10:17 UTC

To be clear you don't actively create and destroy topics. Simply publishing or subscribing to that topic name brings it into existence.

Asked by PeteBlackerThe3rd on 2018-11-07 04:00:54 UTC

Answers