Create a ROS2 Node with Python and OOP - ROS2 Tutorial 5

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 82

  • @RoboticsBackEnd
    @RoboticsBackEnd  2 года назад

    Thank you for watching!
    🔥 To go further with ROS2, check out this complete and step-by-step ROS2 course
    👉 rbcknd.com/ros2-for-beginners

    • @greendsnow
      @greendsnow Год назад

      the -able suffixes at the end of the nouns are not pronounced /eibl/ as in table /teibl/
      but like /əbl/ or /ibl/ as in executable /egzekutəbl/

  • @MohamadAlajouz
    @MohamadAlajouz 6 месяцев назад

    My man I watched all the playlist 3 month ago to work on my graduation project, I only skipped this video and had to always type colcon build during these 3 months 😆, I even tried searching for a solution online but none actually helped. Your content is really simple and straight forward

  • @abhinavmathew2789
    @abhinavmathew2789 5 месяцев назад +5

    the rclpy is not working for me. I downloaded the extentsion and there is an error in the code

  • @impostercoding
    @impostercoding 9 месяцев назад

    I have been reading articles, docs and watching other tutorials for three days. This series got me up and going in a few minutes. I just wanted to add if the a KeyboardInterrupt error bothers you you can use "ctrl+z" || new output => [1]+ Stopped ros2 run my_robot_controller test_node

    • @quillaja
      @quillaja 29 дней назад +1

      i think that will just suspend the process to the background, not actually shut it down. you can bring it back with "fg" (foreground) and view all background processes with "jobs". If the KeyboardInterrupt bothers you, catch the error and print a nicer message.

  • @jerryhsieh2791
    @jerryhsieh2791 Год назад +5

    At 10:13, how did you execute a python file using "./" ?
    I tried the cmd "./my_first_node.py" but it didn't work.
    It only works if I do "python3 my_first_node.py".
    Please explain, thank you!

    • @2anta
      @2anta Год назад +3

      If i'm not mistaken it's the command on the left screen : "chmod +x my_first_node.py" that make the file executable. Happy coding

    • @jerryhsieh2791
      @jerryhsieh2791 Год назад +1

      @@2anta Yes, I did "chmod +x my_first_node.py", but when I then do "./ my_first_node.py", it just outputs "bash: ./: Is a directory" and the code doesn't execute.

    • @jerryhsieh2791
      @jerryhsieh2791 Год назад +3

      Ok I figured it out. It should be "./my_first_node.py" (without the space between / and m).

    • @jeriljudes7822
      @jeriljudes7822 Год назад

      Im also stuck here , I have checked the items in the directory and ran '.my_first_node_.py' but shows an erroe bad interprector no such file or directory

    • @ramzibouderrah7425
      @ramzibouderrah7425 10 месяцев назад

      @@jeriljudes7822 have you found a way to fix it??

  • @codewithdominic9318
    @codewithdominic9318 Год назад +4

    Love this! For a ROS beginner like myself it’s been very helpful

  • @saikeertanareddy4607
    @saikeertanareddy4607 5 месяцев назад

    I am learning ROS2 for a project and this video really helped me! Thank you!

  • @SA-ec9uo
    @SA-ec9uo 6 месяцев назад

    Merhaba ; Ben ilk ROS neotikle başladım ve eksiksiz öğrettiklerinizi tamamladım. Şimdide ROS2 başladım ve beşinci derse kadar eksiksiz devam ediyorum .Eğitimin için sana cok teşekkür ederim . python yeni öğrenen biriyim ama buna rağmen tüm derslerini eksiksiz yerine getirebiliyorum . Ama herşeyi bakarak yapıyorum ilerde tek başımada yapabilirmiyim bilmiyorum.

  • @tgirici
    @tgirici 11 дней назад

    Hi thank you very much for the video. I can run the program on VsCode and command line. I build it. I see "Finished

  • @zhuozhang9956
    @zhuozhang9956 Год назад +2

    Hi, thanks for the excellent tutorial! I am a newer of the terminal. And when I run 'ros2 run my_robot_controller test_node' it says 'Package 'my_robot_controller' not found'. I don't know if it is related that I used zsh and run 'source ~/.zshrc' rather than 'source ~/.bashrc'. Or it is about 'colcon build' (no error appeared from this command)? thanks!

    • @RoboticsBackEnd
      @RoboticsBackEnd  Год назад +1

      Hard to tell, and as for zsh: I haven't tried yet (only using bash), but will have a look. From what I quickly found it seems that zsh could have some issues with ROS2: answers.ros.org/question/394021/no-completion-for-ros2-run-in-zsh/
      But the error could also be because you have forgotten a step when building the node, a typo somewhere, etc. So I'd say, first redo all the steps one by one, then try with bash if possible, and if it works then troubleshoot with zsh.

    • @urbanspoken
      @urbanspoken Год назад

      All you need is just run instead of .bash 🙂

    • @tuanphammanh7122
      @tuanphammanh7122 10 месяцев назад

      @@urbanspoken i have the same problem. BUt I do not run .bash because my source ./bash not work

  • @SihleTrolly220
    @SihleTrolly220 Месяц назад +2

    Good Day, firstly great video series. I, however got stuck on 9:54, I run the my_first_node.py but the terminal does not print anything. would you be able to assist
    Thank you

    • @folaranmijesutofunmi2498
      @folaranmijesutofunmi2498 28 дней назад

      Have you been able to resolve this yet? Maybe you made an error in your main function

  • @pyakpepyak
    @pyakpepyak Год назад +3

    good course, one note though: the dark blue path part of the prompt in bash is not readable, so it makes it harder to follow.

    • @RoboticsBackEnd
      @RoboticsBackEnd  Год назад +2

      thanks! Yes I noticed that a bit too late. It's been fixed for future tutorial though :)

  • @MrEngineer_
    @MrEngineer_ 9 месяцев назад

    Hi, what happens If I use colcon build inside the src directory ? I was mistakenly doing this and I was so anxious that the updated code was not being tracked. Later on carefully watching the blue text, I realized you were doing it inside ros2_ws and not inside src. It fixed the problem of updates. But, what are the consequences ?

    • @RoboticsBackEnd
      @RoboticsBackEnd  9 месяцев назад +1

      If you use colcon build in the wrong directory, then it will add an install/, build/ and log/ folder there. Just remove those folders and you will be fine.
      If you keep different install/ folders in different places this is when you can get some weird errors and package collisions.

    • @MrEngineer_
      @MrEngineer_ 9 месяцев назад

      Okay, Thank you for the clarification !! @@RoboticsBackEnd

  • @hemrajpandeya81
    @hemrajpandeya81 Год назад

    you are a real hero, thank you for the content

  • @ashoksaini2141
    @ashoksaini2141 Год назад +2

    Hey When i am running the my_frist_node ,
    i found an error : No module Named " rclpy._rclpy_pybind11"

    • @Bardomp
      @Bardomp 3 месяца назад +1

      Try to deactivate Conda, that was my issue, ros2 doesnt work with Conda and maybe with other enviroments.
      After that use "pip list" and see if you have rclpy in it.

  • @drawingninja4773
    @drawingninja4773 Год назад +1

    i have a problem at 3:54 bcs rclpy is still not found in my code even though i installed the extention and checked the python version as well as if rclpy is correctly installed :/

    • @omkar_prusty
      @omkar_prusty 6 месяцев назад

      did it get resolved?
      cause i'm facing same issue

  • @DeathTempler
    @DeathTempler 7 месяцев назад

    2:11
    *♪Союз нерушимый республик свободных♪*
    So this tutorial is how Atomic Heart started 🤣

  • @blokpm
    @blokpm 9 месяцев назад

    22:15 suppose you want to automatically exit the Python program after receiving 10 counts, how can you do that? Basically break out the rclpy.spin? What’s the best solution for that? rclpy.shutdown() doesn’t work for me as the “context is not initiated”

    • @RoboticsBackEnd
      @RoboticsBackEnd  9 месяцев назад

      Then I would suggest to stop the timer with smth like "timer.cancel()", but not shutting down the node from the inside.

    • @thebasementengineer
      @thebasementengineer 8 месяцев назад

      Use a while or for loop around the timer

  • @user-nq5hy7vn9k
    @user-nq5hy7vn9k Месяц назад +1

    10:18 I have done the same exact thing but I am not getting any output at all no matter what I do

  • @deplorablesecuritydevices
    @deplorablesecuritydevices 9 дней назад

    Thanks!

  • @xavieronieves-garcia3879
    @xavieronieves-garcia3879 Год назад

    Hey! Great tutorial for newboo like me, though I’m running into a slight problem at 17:42 where after running colcon build - -symlink install, It starts and finishes but when I execute the ros2 run my_robot_controller test_node, it doesn’t update automatically the new code (changing it from printing “ROS2” to “ROS”) and I have to press save every time. Is that how it’s supposed to work? Since I understood that the colcon build - -symlink install is so the you wouldn’t have to manually save it each time.

    • @RoboticsBackEnd
      @RoboticsBackEnd  Год назад +1

      Maybe I see where the confusion is here:
      - with symlink-install you don't have to build again
      - but you have to save the file. If you don't save the file then of course the new version is not used.

    • @xavieromar7981
      @xavieromar7981 Год назад

      @@RoboticsBackEnd thank you so much! For the clarification! Your videos has helped me a lot!

  • @SohailSiadat
    @SohailSiadat Год назад +12

    Blue 🟦 colour text in terminal should be banned.

    • @RoboticsBackEnd
      @RoboticsBackEnd  Год назад

      I know, just found out after I published the tutorial :/
      Fixed in other tutorials

    • @izurzuhri
      @izurzuhri Год назад +1

      why should be banned?

  • @fattysun1121
    @fattysun1121 Год назад

    this is immensely helpful, thank you

  • @rahultom4310
    @rahultom4310 8 месяцев назад

    First of all thank you for the wonderful explanation.
    I have an error when I am trying to run node as ros2 functionality(ros2 run) as per video time line 15.25. Th error saying that "Package 'my_robot_controller' not found". Can you please help me?
    NB: 1). Usually the auto completion is available in my terminal, but not during this terminal session.
    2). I am able to run the same node as python script from the same terminal.

    • @RoboticsBackEnd
      @RoboticsBackEnd  8 месяцев назад

      Probably you didn't source your ROS2 workspace in this terminal. You need to source the workspace so that you can find the packages with ros2 run

  • @pal432-m5v
    @pal432-m5v 10 месяцев назад

    Thanks....
    This is heavenly tutorial

  • @greendsnow
    @greendsnow Год назад

    I understood more from this crash course than the udemy course...

    • @RoboticsBackEnd
      @RoboticsBackEnd  Год назад +2

      Both courses are teaching in a different way, and if you understood more here, maybe it's because you finally "got it" here after having watched the other course. Happens all the time to me, I read from different sources and finally I get it, but it's because the brain actually combines the knowledge from all learning material :) so the tutorial that made you understand is probably not the only one that was important.

    • @greendsnow
      @greendsnow Год назад

      @@RoboticsBackEnd I needed a concise recap.

  • @iamshakeelsindho
    @iamshakeelsindho 3 месяца назад

    Just like others, I am also having the same error at 1520:
    usage: ros2 run [-h] [--prefix PREFIX] package_name executable_name ...
    ros2 run: error: the following arguments are required: executable_name, argv
    I have looked my code in setup.py and my_first_node, they both are fine. Plus, I deleted the folders build&install and run colcon build again in the workspace. Later run the bashrc in the terminal and colcon build in the workspace, the folders are back however when I run the ros2 run my_robot_controller, it shows the same error. Anyone has solution?

    • @RoboticsBackEnd
      @RoboticsBackEnd  3 месяца назад

      In the video I don't run this command, I press TAB for autocompletion (please first watch a tutorial on autocompletion)
      The full command is ros2 run my_robot_controller + executable name

  • @ahmedelmogii2914
    @ahmedelmogii2914 Год назад

    21:13
    i always get this messege (( AttributeError: 'MyNode' object has no attribute 'Timer_callback' ))
    what is the problem and how to solve it?

    • @kenankortan
      @kenankortan 10 месяцев назад +1

      Probably, your timer_callback function is inside of the constructor(__init__). Just put it outside to the constructor. In short, get your cursor on head of def time_callback function and push the "backspace" in the keyboard. Also, same for self.get_logger()...
      I hope that will work.

  • @MavellousFrancis
    @MavellousFrancis 26 дней назад

    please my code says node is not accessed by pylance, what do i do?/?

  • @MeMasterMind
    @MeMasterMind Месяц назад

    THANK YOU!

  • @Potatonater-it7gw
    @Potatonater-it7gw Год назад +1

    thanks for making this

  • @rithjosef-f3r
    @rithjosef-f3r 11 месяцев назад

    thank you brother keep it move on .

  • @mahamaneirochapiou4388
    @mahamaneirochapiou4388 Год назад

    you are a genuis, thx

  • @kin_1997
    @kin_1997 Год назад

    amazing tutorial

  • @reziepaul
    @reziepaul 10 месяцев назад

    heyy thats a good tutorial for a newbie like me , thnaks for making these videos
    though I’m running into a slight problem at 15:12 ,ros2 run my_robot_cotroller , this aint working for me , it says the following arguements require executable_name , though i have give the executable _name which is test_node , executable name and the package_name put togather it is ros2 run my_robot_controller test_name as youve shown in the video ,still it says error and package my_robot_controller not found
    can you pls help me with this

    • @5zigen371
      @5zigen371 6 месяцев назад

      probably because your my_first_node.py isn't is the good folder. It Should be under the 2nd folder my_robot_controller next to the __init__.py

  • @yuribespaloff7274
    @yuribespaloff7274 6 месяцев назад

    Hi! Nothing happens when I run node in the terminal. Not even an error

    • @sarimkhan2306
      @sarimkhan2306 6 месяцев назад

      Have you initialized the node in main() function?

  • @teetanrobotics5363
    @teetanrobotics5363 2 года назад +6

    Could you please make more complicated projects ? These are way too simple. For example: UR5 robot manipulator that uses lidar to see and moves around using local planner using dijsktras algorithm/RRT ?

  • @spaghettiman512
    @spaghettiman512 Год назад +2

    Hi! I'm running into a problem at 15:26 where after having source ~/.bashrc, I could not run the command ros2 run because it reported an error because it oculd not find any executable. Does anyone know why?
    I have been trying to find searching it but I havent been successful at all.

    • @RoboticsBackEnd
      @RoboticsBackEnd  Год назад

      Double check the setup.py of your python package, and make sure you've specificed an executable here. Probably an error here, or in your code. When everything is good, go to your ~/ros2_ws folder, remove install/ and build/, and run "colcon build" again

  • @Ducerobot
    @Ducerobot Год назад

    Can I install ros2 in lunar lobster?

  • @valeriiaokhmak3329
    @valeriiaokhmak3329 10 месяцев назад

    Amazing1 thank you very much

  • @sarimkhan2306
    @sarimkhan2306 6 месяцев назад

    --symlink-install for automating the code is not working. Manual build is working fine.

  • @thebasementengineer
    @thebasementengineer 8 месяцев назад +1

    If source ~/.bashrc doesn't work, use source install/setup.bash instead

  • @EdRlld98
    @EdRlld98 Год назад

    Moi je dis cocorico

  • @rakesharks6643
    @rakesharks6643 4 месяца назад

    @RoboticsBackEnd
    Traceback (most recent call last):
    File "/home/rocky/ros2_ws/src/my_robot/my_robot/./my_node.py", line 3, in
    from rclpy import Node
    ImportError: cannot import name 'Node' from 'rclpy' (/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py)
    I am getting this error :(
    someone pls help me

    • @pavanmeesala5943
      @pavanmeesala5943 3 месяца назад

      Did you find any solution
      I am too facing this problem

    • @Bardomp
      @Bardomp 3 месяца назад

      Try to deactivate Conda, that was my issue, ros2 doesnt work with Conda and maybe with other enviroments.
      After that use "pip list" and see if you have rclpy in it.