Issues with gradebot finding launch file

Hello,

My project works fine, as seen in the video: https://youtu.be/AyOd09E-ErM
but gradebot says:
" [18:24:52] [assess] Could not launch topics_quiz package successfully. Let’s squash this bug before we proceed further.
The launch command exited earlier than expected. Things your can check:

  • Does your quiz node exit in 15 seconds or less? Does it complete the expected movement?
  • Did you name the launch file correctly? It should be topics_quiz.launch.py
  • Run ros2 launch topics_quiz topics_quiz.launch.py and fix any errors that appears. (mark: 3.0)"

how to proceed?

Hello @johnatabrayan,

First things first: welcome to the community!

Now to the problem: did you check the points made by gradebot one by one?

When it ran the command ros2 launch topics_quiz topics_quiz.launch.py, the following error happened within 15 seconds.

+ ros2 launch topics_quiz topics_quiz.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-04-08-21-24-37-418546-e49579e82456-770
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [topics_quiz_node-1]: process started with pid [772]
[topics_quiz_node-1] Traceback (most recent call last):
[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node", line 33, in <module>
[topics_quiz_node-1]     sys.exit(load_entry_point('topics-quiz==0.0.0', 'console_scripts', 'topics_quiz_node')())
[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/python3.10/site-packages/topics_quiz/topics_quiz.py", line 102, in main
[topics_quiz_node-1]     rclpy.spin(topics_quiz)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 222, in spin
[topics_quiz_node-1]     executor.spin_once()
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 712, in spin_once
[topics_quiz_node-1]     raise handler.exception()
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
[topics_quiz_node-1]     self._handler.send(None)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 418, in handler
[topics_quiz_node-1]     await call_coroutine(entity, arg)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 332, in _execute_timer
[topics_quiz_node-1]     await await_or_execute(tmr.callback)
[topics_quiz_node-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
[topics_quiz_node-1]     return callback(*args)
[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/python3.10/site-packages/topics_quiz/topics_quiz.py", line 65, in motion
[topics_quiz_node-1]     roll, pitch, yaw = euler_from_quaternion(self.odometry.pose.pose.orientation)
[topics_quiz_node-1] AttributeError: 'int' object has no attribute 'pose'
[ERROR] [topics_quiz_node-1]: process has died [pid 772, exit code 1, cmd '/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node --ros-args'].


:point_up:This is what gradebot shows me.

Where did you get the error message you showed in your reply?

How can I fix this error if I can’t reproduce it in the IDE? As I showed in the video, in the IDE everything works fine.

Interesting, interpreting the error message in the reply I was able to solve the problem and get a 10. Where can I see this error messages? Why it does not show up in the IDE (as seen in the video)?

@johnatabrayan you should see that error in the terminal when you launch your program.
After checking your video, I can see the terminal doesn’t show any error message. Then it looks like everything is correct. However, when the Gradebot corrected your exercise, it captured an error:

[topics_quiz_node-1]   File "/home/user/ros2_ws/install/topics_quiz/lib/python3.10/site-packages/topics_quiz/topics_quiz.py", line 65, in motion
[topics_quiz_node-1]     roll, pitch, yaw = euler_from_quaternion(self.odometry.pose.pose.orientation)
[topics_quiz_node-1] AttributeError: 'int' object has no attribute 'pose'

That error says that the self.odometry has no pose attribute so when you try to access on that line with self.odometry.pose.pose.orientation it says the self.odometry is an int and doesn’t have the pose.pose.orientation.

That makes me suspect that there is a problem of initialization of your program. Since odometry must be filled by the callback of the subscriber to the /odom topic, the error indicates that at that time, the self.odometry was not yet filled by the callback.
This is a common error in multithreading systems. You expect to be filled a variable because everything runs in parallel, but sometimes it doesn’t because the system didn’t have the time yet to execute the callback (that is random and depends on many things in the computer of the robot).

So, because you are not initializing properly the self.odometry (because you expect the callback to do it) sometimes when your programs reaches the line 65, that would be initialized (and no error shown) and sometimes it will not (and the error is shown).

That makes me suspicious about if you really solved the error or was just luck… how did you solve it?

By the way… thank you very much for taking the time to record the video to show us about your error. That helps a lot!!!

I solved it in the least elegant way possible :point_down:

A much better solution would be doing what is proposed in the solution (having properties for “x”, “y” and “yaw” instead of only one property named “odometry”). I will do better next time :+1:

Yes I can see that your solution works but it is not correct.

Instead of doing the if not isinstance you should initialise the self.odometry variable with an Odometry message in the constructor of the class.

Do not leave this for later. Now it is your opportunity to learn and master that point!!!

Please do it right now and show me here how you did it. I’ll correct you in case necessary and hence you will increase your programming knowledge.

You are right. I just did it exactly as you told me to.

The property odometry is now initialized with an Odometry object:
Screenshot from 2024-04-11 16-10-41

I do not check for the type of the property before using it:

Everything still works fine.

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