Hi all,
This is a question on 4.3 Topic Quiz of Unit 4 Understanding ROS Topics: Subscribers & Messages.
I am having difficulty trying to solve an error that the auto-checker points out:
"[assess] Not publishing to /cmd_vel. Let’s fix this before we continue.
Things your can check:
- Did you create a publisher correctly in your source code?
- Is the logic correct, such that the publisher gets to publish?
- Your robot should start moving within 5 seconds of launching your package.
- Run rostopic echo /cmd_vel and confirm that you have some data there."
However, I am publishing in my code, the publisher gets to publish, my robot starts moving in about 5 seconds (it correctly avoids the object), and when I run rostopic echo /cmd_vel I can confirm that data is being transferred.
I have also done catkin_make and source devel/setup.bash
This is my python source code:
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
rospy.init_node('topics_quiz_node')
pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
rate = rospy.Rate(10)
move = Twist()
def callback(laser):
if(laser.ranges[360] < 1):
move.linear.x = 0.2
move.angular.z = 0.5
elif(laser.ranges[0] < 1):
move.linear.x = 0.2
move.angular.z = 0.5
elif(laser.ranges[719] < 1):
move.linear.x = 0.2
move.angular.z = -0.5
else:
move.linear.x = 0.2
move.angular.z = 0
while not rospy.is_shutdown():
rospy.Subscriber('/kobuki/laser/scan', LaserScan, callback)
pub.publish(move)
rate.sleep()
and this is my launch file:
<launch>
<!-- My Package launch file -->
<node pkg="topics_quiz" type="my_script.py" name="topics_quiz_node" output="screen">
</node>
</launch>
Can somebody please give me advice on what I am doing wrong or if the auto-checker is bugged?
Thank you in advance!