ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hey there,
First, you need to create a publisher it can be either python or cpp file. Let's take an example and create python file.
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Pose
def publisher():
pub = rospy.Publisher('pose', Pose, queue_size=1)
rospy.init_node('pose_publisher', anonymous=True)
rate = rospy.Rate(2) # Hz
while not rospy.is_shutdown():
p = Pose()
p.position.x = 0.5
p.position.y = -0.1
p.position.z = 1.0
# Make sure the quaternion is valid and normalized
p.orientation.x = 0.0
p.orientation.y = 0.0
p.orientation.z = 0.0
p.orientation.w = 1.0
pub.publish(p)
rate.sleep()
if __name__ == '__main__':
try:
publisher()
except rospy:
pass
Now, the pose is published into pose topic.
You can view all topic by:
rostopic list
You can check data for topic by:
rostopic echo pose
You can publish your topic via terminal by:
rostopic pub -r 1000 /cmd_vel geometry_msgs/Pose '{position: [1,2,3], orientation: [0.0,0.0,0.0,0.0]}'
Pose will be published on /cmd_vel topic and 1000 means every 1 sec it will be published
2 | No.2 Revision |
Hey there,
First, you need to create a publisher it can be either python or cpp file. Let's take an example and create python file.
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Pose
def publisher():
pub = rospy.Publisher('pose', Pose, queue_size=1)
rospy.init_node('pose_publisher', anonymous=True)
rate = rospy.Rate(2) # Hz
while not rospy.is_shutdown():
p = Pose()
p.position.x = 0.5
p.position.y = -0.1
p.position.z = 1.0
# Make sure the quaternion is valid and normalized
p.orientation.x = 0.0
p.orientation.y = 0.0
p.orientation.z = 0.0
p.orientation.w = 1.0
pub.publish(p)
rate.sleep()
if __name__ == '__main__':
try:
publisher()
except rospy:
pass
Now, the pose is published into pose topic.
You can view all topic by:
rostopic list
You can check data for topic by:
rostopic echo pose
You can publish your topic via terminal terminal by:
rostopic pub -r 1000 /cmd_vel geometry_msgs/Pose '{position: [1,2,3], orientation: [0.0,0.0,0.0,0.0]}'
Pose will be published on /cmd_vel topic and 1000 means every 1 sec it will be published
Now, the pose is published into pose topic.
You can view all topic by:
rostopic list
You can check data for topic by:
rostopic echo pose
3 | No.3 Revision |
Hey there,
First, you need to create a publisher it can be either python or cpp file. Let's take an example and create python file.
#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Pose
def publisher():
pub = rospy.Publisher('pose', rospy.Publisher('cmd_vel', Pose, queue_size=1)
rospy.init_node('pose_publisher', anonymous=True)
rate = rospy.Rate(2) # Hz
while not rospy.is_shutdown():
p = Pose()
p.position.x = 0.5
p.position.y = -0.1
p.position.z = 1.0
# Make sure the quaternion is valid and normalized
p.orientation.x = 0.0
p.orientation.y = 0.0
p.orientation.z = 0.0
p.orientation.w = 1.0
pub.publish(p)
rate.sleep()
if __name__ == '__main__':
try:
publisher()
except rospy:
pass
You can publish your topic via terminal by:
rostopic pub -r 1000 /cmd_vel geometry_msgs/Pose '{position: [1,2,3], orientation: [0.0,0.0,0.0,0.0]}'
Pose will be published on /cmd_vel topic and 1000 means every 1 sec it will be published
Now, the pose is published into pose topic.
You can view all topic by:
rostopic list
You can check data for topic by:
rostopic echo pose
You can view type by :
rostopic type /cmd_vel
Terminal or python run example response will be : geometry_msgs/Pose