ROS basic Unit 3 problem

I’m doing ROS Basics in 5 days course and in exercise 3.1 after launching the launch file I’m getting this:

and my robot is not moving at all.

I need help regarding this. Thanks

Can you share your code from move_robot.py?

The launch file is successfully starting your node, the issue is that your node is also finishing (without doing what you want).

I suspect that you are missing a call to ropsy.spin() this method keeps the node running so that your subscribers can receive new messages

#! /usr/bin/env python

import rospy

from geometry_msgs.msg import Twist

rospy.init_node(‘move_robot_node’)

pub = rospy.Publisher(’/cmd_vel’, Twist, queue_size=1)

rate = rospy.Rate(2)

move = Twist()

move.linear.x = 1

move.angular.z = 0.7

while not rospy.is_shutdown():

pub.publish(move)

rate.sleep()

RM is correct you need a rospy.spin() to keep your code running… The way you have it now it just publishes once and exits. Look at some of the examples that have rospy.spin() to see were it belongs. If are not able to figure out were it goes post again, but you will learn more if you can do this on your own.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.