-
Notifications
You must be signed in to change notification settings - Fork 1
Publishing commands with python
ldemk edited this page Apr 9, 2019
·
1 revision
-
Create new_package
-
Create a launch file
<launch>
<!-- My Package launch file -->
<node pkg="new_package" type="simpli_pub.py" name="topic_publisherroscd" output="screen">
</node>
</launch>
- Create a simply_pub.py file
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
msg = Twist()
rospy.init_node('topic_publisher')
pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
rate = rospy.Rate(2)
msg.linear.x = 2
msg.linear.y = 0
msg.angular.z = 2
while not rospy.is_shutdown():
pub.publish(msg)
rate.sleep()