Quiz 1 Subscriber Error from auto grader

Hello there, I’ve tested my code multiple times and it works. However, when I submitted it to the auto grader it tells me my code doesn’t subscribe to /kobuki/laser/scan correctly. But if it didn’t subscribed it correctly how come it works as it is intended. You can find my code as below:

#! /usr/bin/env python

import rospy

from geometry_msgs.msg import Twist

from sensor_msgs.msg import LaserScan

def callback(msg):

    dist = 0.0

    for value in msg.ranges[340:380]:

        if value > dist and value != float('inf'):

            dist = value

            print('Maximum distance is: ', dist)

    if dist > 1.0: 

        act.linear.x = 0.10

        act.angular.z = 0.0

        print('Moving forward', dist)

    if dist < 1.0:

        act.linear.x = 0.0

        act.angular.z = 0.30

        print('Turning', dist)

    pub.publish(act)

rospy.init_node('topics_quiz_node')

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

sub =rospy.Subscriber('/kobuki/laser/scan', LaserScan, callback)

act = Twist()

rospy.spin()

Hi @tutuncuoglu94

You have to make sure that nothing is running in your terminals, and kill them if they are running, before you submit it to the auto grader.

You should also make sure that the names of the packages and files are the same as instructed in the notebook.

Ok, thank you for your reply. I had troubles with my launch file. I re-edited .launch file and it is solved.