ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Seeing this:
rospy.init_node('ArmMovement')
pub1=rospy.Publisher("/rrbot/joint1_position_controller/command",Float64,,queue_size=10 )
rate = rospy.Rate(50)
ArmCor1= Float64()
ArmCor1.data=0
pub1.publish(ArmCor1)
rate.sleep()
It's likely that there simply isn't any chance for the Subscriber
(on Gazebo's / ros_control
's side) to actually receive the message. rate.sleep()
is single-shot. There is no periodicity here, so after 1/50
seconds (ie: 20 milliseconds), your program terminates and the Publisher
is destroyed with it.
In those 20 milliseconds, the Subscriber
needs to become aware of your Publisher
, register interest with the ROS master, request a subscription, set up the actual network connection, negotiate with the Publisher
to see whether it can actually exchange messages, complete negotiation and only then can it receive the message.
2 | No.2 Revision |
Seeing this:
rospy.init_node('ArmMovement')
pub1=rospy.Publisher("/rrbot/joint1_position_controller/command",Float64,,queue_size=10 )
rate = rospy.Rate(50)
ArmCor1= Float64()
ArmCor1.data=0
pub1.publish(ArmCor1)
rate.sleep()
It's likely that there simply isn't any chance for the Subscriber
(on Gazebo's / ros_control
's side) to actually receive the message. rate.sleep()
is single-shot. There is no periodicity here, so after 1/50
seconds (ie: 20 milliseconds), your program terminates and the Publisher
is destroyed with it.
In those 20 milliseconds, the Subscriber
needs to to:
Publisher
Publisher
to see whether it can actually exchange Just to see whether this is indeed the problem, at a rospy.sleep(5)
after the pub1=rospy.Publisher(..)
line.
If things start working, you'll want to either make your script periodic, or use a state-based approach (ie: check there are subscribers) with rospy.Publisher.get_num_connections().