Problem in quiz of chapter 4 and chapter 9

My code is working perfectly fine but the grader is not giving me grades properly , can you please resolve this issue for me , thanks

Can you share a screenshot of the results when you submit the quiz?

My code is working perfectly fine but the grader is not giving me grades properly , can you please resolve this issue for me , thanks

In chapter 9 quiz it is giving error drone is not flying but my drone is flying perfectly

Hi @muhammadjunaid,
Most often, its an error in your code. Quizes can be tricky since they are very specific about the requirements and any deviation from them wll be marked as “fail”. Even a small spelling change for a file name will be treated as deviation.

From the errors its showing that the TAKEOFF and LAND call works but the drone is landing after Takeoff, hence its marking it as wrong. Do check this out.

I am assuming that you have gone through the code and double checked, hence i am forwarding your query to @staff.

Do share the quiz goals and the code you used, since that will give us more info to work with.

Here is my code for chapter 9 quiz , more details I hhave already shared:

#! /usr/bin/env python

import rospy
import actionlib
import time

from actions_quiz.msg import CustomActionMsgFeedback , CustomActionMsgResult ,   CustomActionMsgAction
from std_msgs.msg import Empty

class drone_move(object):
   _feedback = CustomActionMsgFeedback()
   _result = CustomActionMsgResult()

   def __init__(self):
      self._as = actionlib.SimpleActionServer("action_custom_msg_as" , CustomActionMsgAction, self.goal_callback , False )
   def goal_callback(self , goal):
      success = True
      r= rate.time(1)

      self._pub_takeoff = rospy.Publisher('/drone/takeoff', Empty, queue_size=1)
      self._takeoff_msg = Empty()
      self._pub_land = rospy.Publisher('/drone/land', Empty, queue_size=1)
      self._land_msg = Empty()

      if self._as.is_preempt_requested():
         rospy.loginfo('The goal has been cancelled/preempted')
         # the following line, sets the client in preempted state (goal cancelled)
         success = False
         # we end the calculation of the Fibonacci sequence
      drone_actions = goal.goal
      if drone_actions == "TAKEOFF" : 
         self._pub_takeoff.publish (self._takeoff_msg)
         rospy.loginfo('Taking off...')
      elif drone_actions == "LAND":
         self._pub_land.publish (self._land_msg)
    = goal.goal

      if success:

if __name__ == '__main__':

Here is my code for topics quiz of chapter 4 topics quiz :

#! /usr/bin/env python

import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan

def callback(msg): 
   if msg.ranges[360] < 1.5:
     move.linear.x = 0.5 
     move.angular.z = 0.5 
   elif msg.ranges[0] < 1.5:
     move.linear.x = 0.5 
     move.angular.z = 0.5
   elif msg.ranges[719] < 1.5:
     move.linear.x = 0.5
     move.angular.z = -0.5
   else: #msg.ranges[360] > 1.5:
     move.linear.x = 0.5
     move.angular.z = 0 

sub = rospy.Subscriber("/kobuki/laser/scan", LaserScan, callback)
pub = rospy.Publisher("/cmd_vel", Twist , queue_size=1 )
rate = rospy.Rate(1)
move = Twist()


Here is the evalution :


but when I run catkin_make --only-pkg-with-deps topics_quiz , it compiles sucessfully :

   else: #msg.ranges[360] > 1.5:
     move.linear.x = 0.5
     move.angular.z = 0 

remove the hastag from else: #msg.ranges[360] > 1.5::

   else: msg.ranges[360] > 1.5:
     move.linear.x = 0.5
     move.angular.z = 0 

perhaps the above error caused the compilor error. Try compiling after making this change.

This is because one of the other packages you have created has a error that was not resolved. Try catkin_make --only-pkg-with-deps for all the packages you have created indivitually to find the one with errors.

I am not so sure about this one, i will forward this to @ralves, i think he will be able to resolve that one.

I already have checked and catkinmake is working perfectly , there is not compilation issue and that’s why I have uploaded an image for you to see .

Another problem is that I am unable to recheck as mistakenly clicked the get solutions option so I am unable to reevaluate my solution of topics quiz 4 . Can you please help me resolve it ? Thanks

I have forwarded your query, they will be able to help you out.


Please do not combine problems next time, and from this point forward. Kindly separate the problems into different posts.

For the drone quiz:

  • Please check that when you take off the drone, it remains in that position forever and has to be manually landed.
  • For the compilation issue, try removing build and devel directories and try again:
cd ~/catkin_ws
rm -rf build/ devel/
  • Unfortunately you cannot retry after clicking the check solutions button. We have no way of checking if it was accidentally or intentionally clicked, and we have visual cues in place to prevent an accidental click.

Hi !

Thank you so much for your kind reply .

  1. (chapter 9 action server quiz) : For take off and land I am 100% percent sure my code has no issues as it is working perfectly and its following the instructions as said. Thats why I have uploaded the screenshots above as well. If you want I can try to make a video of it taking off and landing (that the maximum I can do) . I belive there is some issue in the score marking system.

  2. (chapter 4 topics quiz) I understand and I will be careful next time and will not merge issues again. Actually if you could see my code and my work you will come to know i did everything myself and the only problem is that I accidently checked the solutions for that chapter. I believe the effort should also be appreciated. The issue is the I only have 1 /10 mark in that exam and sur to that i may not be able to get the certificate (For which I really have worked hard). If you want I can share the code here as well and you can check by yourself.

Hi @muhammadjunaid ,

I’ve been checking the logs for Unit 9, and I see the error saying “NameError: name ‘rate’ is not defined”:

publishing and latching message. Press ctrl-C to terminate
[ERROR] [1651306061.295949, 428.147000]: Exception in your execute callback: name 'rate' is not defined
Traceback (most recent call last):
  File "/home/simulations/public_sim_ws/src/all/actionlib/actionlib/src/actionlib/", line 289, in executeLoop
  File "/home/user/catkin_ws/src/actions_quiz/scripts/", line 21, in goal_callback
    r= rate.time(1)
NameError: name 'rate' is not defined

And checking the code on your goal_callback I can see that it was really not defined.
The IDE (Code Editor) also has a red line saying that the variable was not defined.

If you want a message to be published once a minute, you would do something like:

r = rospy.Rate(1) # 1hz

Please review the code and submit again. Also, pay attention to the warnings given by the code editor. Most of the times (at least for Python) the warnings of the editor are to be considered because they point exactly to the error.

1 Like

Hi again, @muhammadjunaid ,

For Unit 4 (Understanding ROS Topics - Subscribers & Messages) I’ve been also checking the logs.

It says:

The build space at ‘/home/user/catkin_ws/build’ was previously built by ‘catkin build’. Please remove the build space or pick a different build space.

This shows that you somehow built the catkin workspace using catkin build, but our automatic system compiles with catkin_make

If you remove your devel and build folders, compile your package again, and submit the quiz again, you will probably have a better score in the quiz.

Please let us know how you are advancing and how else we can help.

You can remove the build and devel folders, and compile again with:

cd ~/catkin_ws
rm build devel -r


source devel/setup.bash

# Now, run whathever **ros** command you may want
1 Like

You may submit the chapter 4 topics quiz again.

For both quizzes, please correct the errors pointed out by @ralves before submitting again.