Ros2 navigation for dummies

I can’t launch any exercises, I did as you tell me to do and it’s not working.
I don’t know what I did wrong, can someone show me the ideal file, as planned to be taught in the course

I’m the kind of person who’s dumb, I blamed my mistakes all on myself, thinking, I did something wrong. But I got to the point where I don’t know what’s wrong, I need a file to compare what I’m doing wrong.

Because I really want to learn robotics, I love robotics, but I’m not able to learn.

Because I probably typed the code wrong and I don’t know where I got it wrong

You who are reading, you don’t need to see where I went wrong, the only thing I ask is the .tar file of your ros2_ws

To see where I went wrong, because I’m dumb, I don’t know where I went wrong, so I want to see where I went wrong

Hi,

But what’s exactly your issue? It seems your files are there in the course.
Are you talking about a file that has to be uploaded or something?
Could you give us some screen shots of the issue?

Hi @danimoura53,

we are all capable. God made us in His own image and likeness. If he was able to create us in the womb, He is not dumb or incapable, neither are we, since we are His likeness.

I once heard a saying that goes like this:

If you say you are incapable of anything, you are right. Likewise, if you say you are capable, you are also right.

Can you see how strong is this saying? This clearly shows that we are what we believe we are.

If you blame yourself and think you are responsible for everything bad that may have gone on in your life, this is just putting you down even more. Things do not get better when we think this way.

I say this based on my own experience: About 12 years ago I thought I was born only to suffer. Everything that I had done in my life went wrong. I was hopeless and almost accepting that “truth” for my life.

The only problem is that this hopelessness was not the “truth”. It was a lie. Every day when we wake up we have a new chance. A new chance to live, to be grateful for the breadth of life, for having what to eat, for being healthy, etc.

You can surely be what you want. Be truthful to yourself. Believe in yourself. You can.

Do not accept the lies that the difficulties try to impose on you. Be truthful to yourself.

:palm_tree: I know this is a “robotics” forum, but I hope this message encourages and changes your life.


Now, back to the technical question, can you tell us what exactly went wrong?

We can provide you exactly what you want if you tell us what exactly you were trying to do, in which Unit of the course you were, etc. Please, help us help you by providing us some context. In the last case, you can also start the course from the beginning so that you will be reviewing the course, and will probably find the problem by yourself, but as I told you, we are here for your support.

It may happen also that you are struggling because maybe you don’t know ROS2 Basics yet. If that is the case, please have a look at the ROS2 Basics in 5 Days (Python) course first.

But if the only thing you want is to reset your ~/ros2_ws, can download the ros2_ws.zip (for ROS Foxy) file from the link below:
https://s3.eu-west-1.amazonaws.com/rosject-preview.theconstructsim.com/help/ros2_ws.zip

Cheers.

Let’s start with unit 4, exercise 4.4

Hello @danimoura53 ,

Let’s go by parts. First of all, you need to launch the navigation nodes. You can do this with the following commands:

source ros2_ws/install/setup.bash
ros2 launch nav2_course nav2_complete.launch.py

Next, in order to start navigation, you need to provide an initial Pose for the robot in RViz. You can do this from RViz, using the 2D Pose Estimate tool. See below GIF:

initial-pose

Check where the robot is in your simulation, and set this Pose in the map in RViz. After you do this, you will see all the costmaps appear in RVIZ. Now you are ready to navigate.

At this point, you can already interact with the navigation nodes from your own programs. Let’s now fix a couple problems you have in your code.

  • First of all, update your setup.py file, in the entry_points section, to add a comma separating the 2 executables that you are generating, like this:
entry_points={
        'console_scripts': [
            'clicked_point_sub = exercise44.clicked_point_sub:main',
            'goal_pose_pub = exercise44.goal_pose_pub:main'
        ],
    },
  • The code in clicked_point_sub.py is OK.

  • The code in goal_pose_pub.py has several things wrong. Let’s go by parts.

  1. First, you don’t have the constructor for your class (def __init__(self)), as you can see it is in the other script.

  2. Second, the indentation of the callback() function is wrong. It should be indented INSIDE the class Publisher (indentation in Python is very important)

  3. Finally, you are also missing the import of the PoseStamped message. Putting all this together, your code should be something like this:

import sys
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import PoseStamped

class Publisher(Node):

    def __init__(self):
        super().__init__('goal_pose_pub_node')
        self.publisher_ = self.create_publisher(PoseStamped, 'goal_pose', 1)
        timer_period = 0.5  #Seconds
        self.i = 0.0
        self.timer_ = self.create_timer(timer_period, self.callback)

    def callback(self):
        msg = PoseStamped()
        msg.header.frame_id = 'map'
        msg.pose.position.x = 1.9
        msg.pose.position.y = -0.5
        msg.pose.orientation.w = 0.0
        self.get_logger().info('Publishing Goal Position \n X= 2.2 \n Y=0.0 \n W = 1.0')
        self.publisher_.publish(msg)

def main(args=None):
    rclpy.init(args=args)
    publisher = Publisher()
    rclpy.spin_once(publisher)
    publisher.destroy_node()
    rclpy.shutdown()

if __name__ == '__main__':
    main()

You can also find this code in the Solutions in the notebook.

Ok, now you can compile your workspace:

cd ~/ros2_ws
colcon build
source install/setup.bash

After compiling, you can then run your programs. For instance, you can launch the goal publisher, which will send a goal to the robot:

ros2 run exercise44 goal_pose_pub

You should see your robot start navigating to the goal position provided in the code (x=1.9, y=-0.5).

You can also run the subscriber code:

ros2 run exercise44 clicked_point_sub

With this 2nd program, you can click somewhere in the map in RViz using the Publish Point option:

pub-point

and you will get the coordinates of the map in the output of your program:

Analyzing the situation, I don’t think that the problem is that you are dumb as you say. I think that the problem is that you are not ready for doing this course. It’s impossible to try to learn something more complex without the proper base. I strongly recommend that you first complete the following courses:

  • Python3 for robotics (you will learn how to program in Python)
  • ROS2 Basics in Python (you will get the basis of ROS2 and practice some Python)

Best,

Thank you for your help and your attention.
I will follow the advice to take the courses.
I made the changes and the program worked fine.