Project Completed: GoPiGo3 on Ubuntu 20.04 with ROS Noetic For Pi4

UPDATE: PROJECT COMPLETE


GoPiGo3 on Ubuntu 20.04 Focal Fossa with ROS Noetic

Companion to BRJapon, “Hands On ROS For Robotics Programming”



BACKGROUND:

Released in mid 2018, ROS Melodic was a long term support version of ROS (original ROS not ROS 2), and Ubuntu Mate 18.04 officially supported the Raspberry Pi (2B/3B/3B+).

In 2020 BR Japon published the book “Hands On ROS For Robotics Programming” using the GoPiGo3, ROS Melodic over Ubuntu Mate (Desktop) 18.04, and released an SD card image to go with the book.

As of June 2023, ROS Melodic is archived and no longer supported. Ubuntu Mate 18.04 is archived, and no longer supported. Also as of mid 2021, there are two versions of the GoPiGo3 with different number of wheel encoder ticks making old software stop short of requested distance and angles.

Suggested thoughts from @este :slight_smile:

  • The book states to download the original Ubuntu Mate 18.04 image from https://ubuntu-mate.org/ but this not possible and probably hasn’t been possible for since Ubuntu 18.04 reached EOL in May, 2023. We did find a copy in the ubuntu-mate archives but it is hard to find, and only works with early (2018) vintage Raspi 3 B+ boards and older.
  • The image from SourceForge is never mentioned in the book and in fact is the author’s end state after completion of the exercises in the book.

The issue of not booting on a Pi4 board - the board most easily obtained in late 2023, is a major hurdle.

ROS Noetic is the latest ROS distribution available and the last ROS distribution that will be released - all future releases will be ROS 2.

It is hoped that this effort and SD card image will enable users to use the Hands On ROS book, with a Pi4 powered GoPiGo3, albeit with differences from the book that will require patience and flexibility.

UPDATED - removed progress from original post

IMAGE AVAILABLE see here

3 Likes

@cyclicalobsessive what a great topic! I love the history and the work so far! Many thanks for keeping the handsonros dream alive! :sunglasses:

3 Likes

I can help with this if you want.

2 Likes

Thanks, I fear we are a long way from that point, and looking longer every forward progress I make.

A really big issue is that “python” was commonly used everywhere in 2020 and in the operating systems. The next version of operating systems began the “python3” era.

I expected the Hands On ROS code would need some changes due to the ROS version change. I forgot about the Python gods mucking with reality.

In fact, while I can make the changes in the code, and get it to work, I am not sure anyone can survive reading the book with a “This is what that means I have to do in my environment” mindset.

The first hurdle - I chose the Server version of Ubuntu so there is no desktop. The book talks about using “terminator” which is a graphical terminal window divider:

but since there is no desktop the user must launch “tmux” and rather than mouse clicking, must use “cntrl-b ” keyboard shortcuts to divide the shells, and to move the cursor between panes.

For this code, I had to edit the three python code files and change:

  • #!/usr/bin/env python
    to
  • #!/usr/bin/env python3

and then it works.

I should have started with Ubuntu 20.04 Desktop for Raspberry Pi.

I like server operating systems because they require the least processor load, leaving headroom for actually doing robot stuff. BUT, I am still comfortable/actually prefer editing in a console window rather than the far superior graphical environment of VSCode or even “terminator with a mouse” of the Hands On ROS book. I really can’t expect “new to Linux, new to ROS, new to Python” folk to take the “path of most resistance”

Whoa - UPDATE: sudo apt install ubuntu-desktop, (reboot with monitor attached), and it works as described:

UNTIL HE WANTS ME TO DRIVE AROUND …WITH THE HDMI CABLE ATTACHED??
Setting up remote desktop is a whole cottage industry to itself!

3 Likes

Agreed but I don’t think it exists (or if it does, I couldn’t find it…) :disappointed_relieved:

3 Likes

IT WORKS!

Well, that’s a tall order now that I remember going through the book the first time, BUT

  • Skipped Chapter 4 Rviz and Chapter 5 Gazebo just like I did the first time - these are simulated GoPiGo3 chapters that teach lots and lots about ROS, but I’m always in a hurry to use the real robot please
  • Jumping into Chapter 6, the book brings down the very early ros-gopigo node, which needed the python → python3 environment specification change:
pi@U20S64B:~/catkin_ws$ grep Changed src/gopigo3_node/src/*.py
src/gopigo3_node/src/colour_sensor.py:#  Changed env python -> env python3
src/gopigo3_node/src/distance_sensor.py:# Changed env python -> env python3
src/gopigo3_node/src/gopigo3_driver.py:# Changed env python -> env python3
src/gopigo3_node/src/imu.py:# Changed env python -> env python3
src/gopigo3_node/src/temperature_sensor.py:#  Changed env python -> env python3
src/gopigo3_node/src/ultra_sonic.py:#  Changed env python -> env python3

I opened three terminals on my Mac, ssh pi@10.0.0.xx in each, cd to ~/catkin_ws and let’s see what runs?

  • had to run the build twice - first so it builds the gopigo3_node.msg package, then second time it built without complaining about the msg package being missing.
  • For the big test: rosrun gopigo_node gopigo3_driver.py …drum roll please… it started with no errors:
pi@U20S64B:~/catkin_ws$ rosrun gopigo3_node gopigo3_driver.py 
GoPiGo3 info:
Manufacturer    :  Dexter Industries
Board           :  GoPiGo3
Serial Number   :  56ECD67E5152415447202020FF192614
Hardware version:  3.x.x
Firmware version:  1.0.0
new_angle2 0.0
new_angle2 0.0
new_angle2 0.0
new_angle2 0.0
new_angle2 0.0
new_angle2 0.0
new_angle2 0.0
  • Now for the coup de grace:
T1:  roscore
T2: rosrun gopigo3_node gopigo3_driver.py
T3: ./run_teleop.sh    (rosrun teleop_twist_keyboard teleop_twist_keyboard.py)
T4: rostopic echo /odom

Press the “i-key”…Dave is driving!!! and the “k-key” stopped him!

Test for measured meter: 1.39 meters - not bad for default WHEEL_DIAMETER and 16-tick encoder robot.

header: 
  seq: 3221
  stamp: 
    secs: 1698374735
    nsecs: 296841621
  frame_id: "odom"
child_frame_id: "base_link"
pose: 
  pose: 
    position: 
      x: -1.3946795179752338
      y: -0.09580851810901567
      z: 0.0
    orientation: 
      x: 0.0
      y: 0.0
      z: 0.9992659197279876
      w: 0.03830955063921943
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist: 
  twist: 
    linear: 
      x: 0.0
      y: 0.0
      z: 0.0
    angular: 
      x: 0.0
      y: 0.0
      z: 0.0
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---

ROS Noetic GoPiGo3 with Pi4 (2GB) running Ubuntu 20.04 Server - It works!

Lessons:

  • ROS is at the end of the maturity cycle so the only changes are
    • specify run with Python3
      change:
      #!/usr/bin/env python
      to
      #!/usr/bin/env python3
  • Search .py files for "print ..." as in print<spacechar>stuff_to_print
    change to print( ... )

That seems to be it for the code changes.

No ROS command changes detected in my tests.

Oh, and the distance_sensor node works too:

T1: roscore
T2: pi@U20S64B: ~/catkin_ws$ rosrun gopigo3_node distance_sensor.py
T3: pi@U20S64B: ~/catkin_ws$ rostopic echo /distance_sensor/distance

header:
seq: 3356
stamp:
secs: 1698372590
nsecs: 823113918
frame_id: "distance"
radiation_type: 1
field_of_view: 0.0
min_range: 0.004999999888241291     <-- 5mm
max_range: 8.0                                          <-- 8 meters
range: 0.4480000138282776                  <-- about half a meter, 443mm actual - off by 5mm

3 Likes

Since I had to get past a bunch of failed scripts that may have enabled my successful steps, I now have to try with a clean OS to get a working “Master Image Installation” script.

3 Likes

Progress:

  • Added tigervnc to base OS - partial success. Going to live with limitation - fix is beyond me.
    Cannot reconnect remote desktop if logout before exiting remote desktop application

  • GoPiGo3 software install script works

  • GoPiGo3 Python tests succeed

  • ROS Noetic software install script works

  • Install script works for Hands-On-ROS-For-Robotics-Programming code
    (Chap3 code and Chap6 example code updated for Noetic)
    and Noetic gopigo3_node

  • Chap 3 works

  • (Chap6 “updated for Noetic” code is for reference after student completes exercises)

  • Noetic gopigo3_node successfully runs with teleop_twist_keyboard node

TODO:

  • Investigate why GoPiGo3 python programs do not work after running ROS GoPiGo3 node
    but ROS GoPiGo3 node can be exited and started again no problem.
  • Document base OS creation steps (cannot be scripted)
  • Document Testing master image
  • Create a bootable image that can be installed and configured with the Raspberry Pi Imager
  • Document steps to image the SD card (setting user/pw, locale, wifi, ssh), and later vncserver password
2 Likes

@este Have you reached pg 178 in the book (the gopigo3_node distance_sensor example?

I would like to know if the behavior I am seeing after running the gopigo3_driver from that package is my system related.

Is it possible for you to run the following sequence of tests with your GoPiGo3 ROS Melodic?

- cold boot
- Open three terminals or shells  T1, T2, T3
- cd catkin_ws  (in each)
- source /opt/ros/melodic/setup.bash   (in each)
- source devel/setup.bash  (in each)
- T1:  python /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Motor_Turn.py
  Confirm GoPiGo3 turns, then ctrl-c
- T1: roscore
- T2: rosrun gopigo3_node gopigo3_driver.py
- T3: rosrun teleop_twist_keyboard teleop_twist_keyboard.py
   press x-key repeatedly until speed is around 0.1
   press i-key, confirm GoPiGo3 drives slowly forward
   press k-key or spacebar, confirm GoPiGo3 stops
   press ctrl-c to exit teleop_twist
- T2: press ctrl-c to exit gopigo3_driver
- T1: press ctrl-c to exit roscore

Now for the point of all this:
- T1: recall the python servo test command (up arrow) or copy/paste again:
  python /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Motor_Turn.py
  Confirm GoPiGo3 turns, then ctrl-c

On my system, the program is running quite happily, but the motors are not turning (not happily).

I’ve confirmed restarting the pigpiod does make the motors happy again.
I’ve confirmed running the gopigo3_driver node repeatedly makes the motors work happily (only in ROS)

2 Likes

No clue but not a requirement for successful following book needs. If desired, reboot and test before using ROS GoPiGo3 nodes.

TODO:

  • Add documentation for master OS creation steps (cannot be scripted)
  • Document Testing master image
  • Create a bootable image that can be installed and configured with the Raspberry Pi Imager
  • Document steps to image the SD card (setting user/pw, locale, wifi, ssh), and later vncserver password
2 Likes

Sorry for the delay @cyclicalobsessive

This is not part of handsonros as far as I could tell, but I found and cloned it into /catkin_ws/src then did catkin_make as required when adding nodes.

The before use of python /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Motor_Turn.py works

All of the ros items work. Not a fan of the weird keyboard mappings though.

The repeat of python /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Motor_Turn.py however, does not work, same as what you describe. My, that’s annoying…

BTW, I have had problems with the VNC connection: Copy in Windows and Paste into Mate terminal via tightVNC does not typically work. Using Xfce Terminal seems better but the problem was finally traced back to my VNC client. tightVNC has the copy/paste problem, tigerVNC does not have the copy/paste problem. Both have a problem with character distortion and screen artifacts. Switched again to RealVNC and that seems the best (no character distortion or screen artifacts - still copy/paste issue but only with Mate terminal but not with Xfce or Terminator). God what a confusing mess getting these non-robotic parts to work properly.

3 Likes

Thanks for duplicating this issue. It is not a problem in using the GoPiGo3 with the book, just something I discovered in my “not following the book” approach.

IIRC it was installed with apt in chap 3 not cloned to the workspace. The chapter introduced topics and using rqt. One of the issues I have with ROS is remembering how to run things after a bit not using them. I make tons of “run_xyz.sh” and “echo_xyzzy.sh” and… scripts in the workspace.

In my ROS2 Humble image, I created a custom teleop_gopigo3_keyboard that didn’t print out the holonomic keys and the up/down keys that don’t apply to our little GoPiGo3 bots.

Since you cloned it, you can change it to your favorite keys. I also managed to get a wireless Nintendo game pad (like $10 again IIRC) node working, but teleop works fine for doing the book.

2 Likes

COMPLETED: THA-THA-THATS ALL FOLKS

This “Antiquated ROS for Pi4 Revival” effort is complete, giving highly adaptable folks a way to use a Pi4 powered GoPiGo3 robot with the BR Japon book, “Hands On ROS For Robotics Programming”, 2020


CLICK HERE FOR INSTALLATION INSTRUCTIONS:




Announcement on discourse.ros.org

(For the even more adaptable folks, desiring a way to use the Hands-On-ROS book to learn ROS 2, I suggest starting here)

3 Likes

Congratulations. That’s quite an achievement.
/K

3 Likes

I really shouldn’t be so biased toward ROS 2, in 2022 slightly more people downloaded ROS Noetic than ROS 2 Humble, and EOL for Noetic isn’t until May 2025.

Thanks. It was 10 days of way too much focus, and I slept 9 hours the next night. That hasn’t happened in years.

3 Likes

Thank you so SO MUCH @cyclicalobsessive for doing this. The handsonros book is really quite good and it was such a shame that it hit a brick wall so soon after publication. You have given it new life and I believe many will benefit. Thank you also for posting this on https://discourse.ros.org/ where it will get the visibility it so deserves. Well done! :fireworks:

3 Likes