Failing for not using /scan

Hi, I’m getting an error because I’m not subscribed to the /scan topic, but I am. I attached a screenshot of my code.

1 Like

Try adding “/scan” and not “scan” to the topic name.I had the same problem, and it worked for me.

Hello martinetbon, thank you for your reply, I tried but doesn’t work.

I can’t recall the exercise, but I think it could be related to the node name or something similar.

The problem is that you named your node motion instead of topics_quiz_node.

image

That’s the node that must subscribe to /scan. You can check that by

# launching your quiz in one terminal
ros2 launch topics_quiz topics_quiz.launch.py

And

# Checking the subscriptions to /scan in another terminal
ros2 topic info /scan -v

Hello bayodesegun, thanks for your reply, that was the first error, but I changed the node name and I still get the same error, I attach the command output.

Well, it was the error I saw in the logs as of your last attempt, so it wasn’t merely the “first” error. In which file are you changing the node name?

I modified topics_quiz_node.cpp

I see.

The node name specified in the launch file overrides whatever is specified in the source code, so when you use ros2 launch what you specified in the launch file will be the node name.

Please fix the node name in the launch file and try again.

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

Hello Bayodesegun,
Sorry for the delay but I was on vacation. I changed the name but I get the same error. The code works and I check the /scan subcriptions and it shows the correct name.
Cheers.

Please check again and show us the output of the commands mentioned here:

Hello bayodesegun,

Attached the command output.

and this is the node list
ROS2-error-nodes

As of your last submission, the node name was topics_quiz, not topics_quiz_node :cold_face:. I don’t know how you arrived at that and used up your trials trials on it :slightly_frowning_face:.

[topics_quiz_node-1] [INFO] [1724674435.971871950] [topics_quiz]: Distancia mínima en la parte central: inf
[topics_quiz_node-1] [INFO] [1724674435.982007851] [topics_quiz]: Distancia mínima en la parte central: inf
+ OUT='Type: sensor_msgs/msg/LaserScan

Publisher count: 1

Node name: lidar_1
Node namespace: /
Topic type: sensor_msgs/msg/LaserScan
Endpoint type: PUBLISHER
GID: 01.0f.6a.68.f4.00.0f.e2.01.00.00.00.00.00.3a.03.00.00.00.00.00.00.00.00
QoS profile:
  Reliability: RELIABLE
  History (Depth): UNKNOWN
  Durability: VOLATILE
  Lifespan: Infinite
  Deadline: Infinite
  Liveliness: AUTOMATIC
  Liveliness lease duration: Infinite

Subscription count: 1

Node name: topics_quiz
Node namespace: /
Topic type: sensor_msgs/msg/LaserScan
Endpoint type: SUBSCRIPTION

I have added two more trials for you. Now please:

  • use the node name topics_quiz_node in both the C++ source and the launch file, just to be sure.
  • submit your code for grading again.

Every time I tried it I checked that it worked correctly before, but I always got the same error.
The last attempt was with the code I ran when I entered in the previous comment, but I don’t know why it doesn’t update on your server and show you “topics_quiz”. Do I have to do something special to update the server? Or wait more time?
Now I have launch the same code without any changes and it works…

No, the changes should reflect instantly. There must have been a mix up somewhere.

Anyways, glad to hear it now works :+1: