Publish on different topics using the same
Hello, I have 12 different topics, which correspond to the state position of 12 different joints. I am trying to publish on the 12 different topics using only one publisher node. However, I can not find a way to do it using only one python file. I tried to initialize different nodes on the same python file and then publish the message after each node's initialization, but it did not work. Is there any way to do it?
This is the code I tried for two different topics.
#! /usr/bin/env python
import rospy
from std_msgs.msg import Float64
rospy.init_node('joint_angle')
pub = rospy.Publisher('/rrbot/joint1_position_controller/command', Float64, queue_size=10)
rate = rospy.Rate(0.5)
rate.sleep()
move = Float64()
move.data = 0.5
pub.publish(move)
pub = rospy.Publisher('/rrbot/joint2_position_controller/command', Float64, queue_size=10)
rate.sleep()
pub.publish(move)
Thanks for your help.
What does
mean? In reference to you trying to using the same node 12 different times.
why?