Testers Wanted: "v4 image" ROS2 for GoPiGo3

PLEASE TEST (No ROS knowledge needed):

Any GoPiGo3 will work - no sensors required

This Nov 4, 2022 release adds:

  • URDF files for dave, finmark, and gpgMin (a basic GoPiGo3 without any sensors)
  • robot state and joint state publishers on GoPiGo3 (use the on-platform URDF)
  • WiFi IP announcement at boot to the attached speaker (or headphones)
  • Slam-toolbox mapping and save (map also visible in rviz2 on any desktop ROS2 installation)
  • Work around found to eliminate shutdown errors in all the ROS2 GoPiGo3 code
    (The code I wrote. One last shutdown error from joint_state_publisher I can’t figure out.)
  • start_robot_xxxx (xxxx= dave, finmark, or gpgMin), and universal stop_robot.sh script to shutdown all nodes
  • /usr/local/bin/stop (just type stop from anywhere for a “runaway robot”)
  • 10 frames per minute PiCamera /Image topic publisher for camera equipped GoPiGo3 robots
  • odometry reset batch file to demonstrate publish to the ros2_gopigo3_node service listener from command line
  • no default /home/pi/Dexter/gpg3_config.json so it gets generated automatically
  • monitor.sh script reports CPU load and temperature, Memory usage, and Battery Voltage
  • “odometer” node /odom subscriber prints to console+logs motion start and ending x, y, heading
    (./start_odometer.sh to run it)
  • No longer auto starts distance_sensor node which had huge CPU load impact (vs imu or ultrasonic ranger nodes)
  • Tuning ROS2 GoPiGo3 utility programs and usage document
  • Testing ROS2 GoPiGo3 document updated
  • auto update disabled - run update/upgrade at your discretion
  • ROS2 GoPiGo3 Desktop Visualization Guide
    (For users with ROS2 installed on a desktop/laptop)

Follow the new instructions at: GitHub - Install ROS2/Ubuntu For GoPiGo3 From Image

Landing Page for the ROS2 on GoPiGo3:

2 Likes

Wow.
Traveling currently - will test when I’m back
/K

2 Likes

And how about a dictionary and/or a translation into English?  (:wink:)
 

What’s a “URDF file”?  If I build out Charlie or Charlene as ROS bots, do I need one?  How do I make one?  If I want to include sensors that Charlie/Charlene have, how do I do it?

2 Likes

Those are all good questions, that I will be happy to discuss after you have downloaded my “You don’t need to know anything - ROS2 for GoPiGo3” image and can tell me what my docs lack from a “I don’t know anything about ROS” user viewpoint.

Your path to enlightenment begins here!

2 Likes

Documentation updated to include files and detailed steps needed to configure remote visualization of a ROS2 GoPiGo3

(Assumes user has installed ROS2 successfully on their desktop/laptop

Rviz2: gpgMin RobotModel + Odometry to show path traveled:

 

Rviz2: Finmark RobotModel + LaserScan:

 

Rviz2: Finmark RobotModel + LaserScan + .010 meter Resolution Map from slam-toolbox online_async_mapper:

What you don’t see is how bad the map looks if the robot turns. Problem left for someone smarter than I am at this point.
(Has to be in the nasty math interpreting encoder left and right change to heading change in the ros2_gopigo3_node.py /odom topic publisher)

2 Likes

All true.

All I need now is a system to work on an a place to work on it. . . .

2 Likes

V4 ROS2 GoPiGo3 Image: Known Issues: Nov 8, 2022

  • /odom wrong for small heading changes? - eyeball close for 2, 5, 15, 30, 45, 90, 180, 360 deg turns
  • /odom/reset service performs reset but sometimes not returning success? - CND
  • my_mapper_params_online_async.yaml: 0.01 is better value for resolution
    Fix: Edit ~/ros2ws/my_mapper_parames_online_async.yaml
          change line:
                resolution: 0.05
          to:
                resolution: 0.01
  • odometer.py only detects forward/backward motion, but not spins.
    (Ouch- reminded /odom heading goes from -pi/2 to +pi/2 in an instant passing the lower quadrants)
    Apply fix:
    cd ~/ros2ws/src/ros2_gopigo3_node/ros2_gopigo3_node
    cp odometer.py odometer.py.v4
    wget https://raw.githubusercontent.com/slowrunner/ROS2-GoPiGo3/main/updates/odometer.py
  • YDLiDAR returning zero distances 25% of time:
    Apply fix:
   cd ~/ros2ws/src/ydlidar_ros2_driver/params
   cp ydlidar.yaml ydlidar.yaml.v4
   wget https://raw.githubusercontent.com/slowrunner/ROS2-GoPiGo3/main/updates/ydlidar.yaml
  • Image does not have swapfile setup
    Apply fix:
cd ~/utils
wget https://raw.githubusercontent.com/slowrunner/ROS2-GoPiGo3/main/utils/make1GBswapfile.sh
chmod +x make1GBswapfile.sh
./make1GBswapfile.sh
cd ~/systests
mkdir swap
cd swap
wget https://raw.githubusercontent.com/slowrunner/ROS2-GoPiGo3/main/systests/swap/use1GB.py
chmod +x use1GB.py

Test Swapfile

In another shell start monitoring memory use:

cd ~/ros2ws
./monitor.sh

In the first shell:

~/systests/swap/use1GB.py

and watch for Mem: line to show very little available, and then return to full memory available

********** ROS2 GoPiGo3 MONITOR ******************************
Saturday 11/12/22
 09:23:02 up  1:01,  2 users,  load average: 0.15, 0.16, 0.10
temp=51.6'C
frequency(48)=1700419968
throttled=0x0
               total        used        free      shared  buff/cache   available
Mem:           1.8Gi       198Mi       1.4Gi       7.0Mi       228Mi       1.5Gi
Swap:          1.0Gi          0B       1.0Gi
GoPiGo3 Battery Voltage: 12.5 volts
 

********** ROS2 GoPiGo3 MONITOR ******************************
Saturday 11/12/22
 09:23:13 up  1:01,  2 users,  load average: 0.32, 0.20, 0.12
temp=52.5'C
frequency(48)=1200287104
throttled=0x0
               total        used        free      shared  buff/cache   available
Mem:           1.8Gi       1.6Gi        77Mi       7.0Mi       173Mi        91Mi
Swap:          1.0Gi       653Mi       370Mi
GoPiGo3 Battery Voltage: 12.6 volts
 

********** ROS2 GoPiGo3 MONITOR ******************************
Saturday 11/12/22
 09:23:24 up  1:01,  2 users,  load average: 0.35, 0.21, 0.12
temp=52.5'C
frequency(48)=1700419968
throttled=0x0
               total        used        free      shared  buff/cache   available
Mem:           1.8Gi       183Mi       1.5Gi       7.0Mi       172Mi       1.5Gi
Swap:          1.0Gi       3.0Mi       1.0Gi
GoPiGo3 Battery Voltage: 12.5 volts

@KeithW please apply these fixes for the best result - looking forward to hearing how you make out with the Pi3B GoPiGo3.

2 Likes

Tuning the ROS2 GoPiGo3 doc updated:

Verify URDF LaserScan Link to Base Link x,y

(Requires Desktop Visualization with rviz2)

  1. Place bot square to a walled corner (suggest 50cm from front wall, 50cm from side wall)
  • Measure distance from a front wall to center of wheels
    Front Distance (wall to center of wheels) _____ mm
  • Measure distance from side wall to center of bot between the wheels
    Side Distance (wall to center of bot between wheels) _____ mm
  1. ./start_robot_xxxx.sh on robot
  2. Start rviz2, load RobotModel with robot_xxxx urdf
  3. Select rviz2:Move Camera
  • mouse-drag down to be looking straight down on bot
  • shift mouse to put grid-cross under the wheels in center of big yellow circle in center of window

  1. Select rviz2:Measure
  • left click on grid crossing at center of bot
  • left click on front wall scan dot on the grid line
  • Note distance to front wall displayed in lower left
    (This is base_link-to-laser_frame X-distance plus /scan distance: laser_frame to front wall)
    Visualization Distance from center of bot (base_link) to front wall: ______ mm

  • right click to reset/clear measurement
  • left click on grid crossing at center of bot/grid cross
  • left click on side wall scan dot on the grid line
  • Note distance to side wall displayed in lower left
    (This is base_link-to-laser_frame Y-distance plus /scan distance: laser_frame to side wall)
    Visualization Distance from center of bot (base_link) to front wall: ______ mm

  • If the displayed measurement is larger than the physical measurement,
    decrease the appropriate x or y value (x to front wall, y to side wall)
    in the robot’s URDF file (~/ros2ws/src/ros2_gopigo3_node/urdf/xxxx.urdf and in ros2desk/xxxx.urdf
  • If the displayed measurement is smaller than the physical measurement,
    Increase the appropriate x or y value (x to front wall, y to side wall)
    in the robot’s URDF file (~/ros2ws/src/ros2_gopigo3_node/urdf/xxxx.urdf and in ros2desk/xxxx.urdf
  • ./rebuild.sh on the robot
  • Load the new URDF file in rviz2, then click Reset button in lower left
  • Retest measurements

Between tuning the gpg3_config.json wheel-diameter and wheel-base, the updated ydlidar.yaml param that gives 100% reliable readings, and verifying the URDF values for dave: the mapping and localization seems to be working quite well. The bot moves then a few seconds later the localization will update the position and orientation in the map very well.

Startup:

 
After driving around and spinning a few times,

 
backed up till touched the wall to back of dave:

 

When the environment is very messy, and I’m talking:

 
It is not doing too bad, although sometimes it glitches like the opening scene from “The Outer Limits”:

 

Perhaps moving very slow helps also.

2 Likes

OUCH-- forgot to set up the swap file in image. Added fix to “Changes Since v4” doc on GitHub.

You may check the zswap with this:

cd ~/systests/swap
wget https://raw.githubusercontent.com/slowrunner/ROS2-GoPiGo3/main/systests/swap/showZSWAPstatus.sh
chmod +x showZSWAPstatus.sh

./showZSWAPstatus.sh

ubuntu@ROS2HH:~/systests/swap$ ./showZSWAPstatus.sh 
/sys/kernel/debug/zswap/same_filled_pages:90
/sys/kernel/debug/zswap/stored_pages:710
/sys/kernel/debug/zswap/pool_total_size:1183744
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

Note the stored_pages is not 0 meaning that the:

Swap:          1.0Gi       3.0Mi       1.0Gi

3MB was the remainder of the 1GB array of '1’s compressed into the /swapfile (that did not fit into the physical memory) … I think. I’m not actually sure exactly, but since the reject_compress_poor is 0, I am guessing the compression is working. I did the test with a use2GB on my 1.5GB free, and it succeeded while using only 687Mi bites of swap. I also ran the full dave and image pub and use1GB and use2GB which ran the CPU load up to 17! and caused a temporary LIDAR "[ydlidar_ros2_driver_node-1] [YDLIDAR ERROR]: Device Tremble
" message, but everything kept running after the use memory programs returned the memory. Load dropped back down, available memory appears fully returned. Looking pretty robust on the Pi4 2GB using 3.6GB of memory.

@KeithW This fix may be especially important for Finmark with the 1GB Pi3B config.

I also updated ~/ros2ws/versions.sh with:

echo "v4 Updates applied 12 Nov 2022"
2 Likes

OK- I’ve actually been back for a while, but just had time to work on this today.
Initial boot was slow. And then I did an apt update/full-upgrade, which I realize was stupid after I did it - just a holdover habit from running Ubuntu on laptops. That took forever.

But I can ssh in. And the communication and motor test (sans wheels) was successful. I had a keyboard and monitor attached just in case, but tomorrow I can try it untethered with the wheels on. But based on today’s performance I worry that it’ll be really slow.
/K

2 Likes

Did you apply the swap fix?

1 Like

Ooh - not yet. Good point.
/K

2 Likes

Finally had a chance to play with Finmark. I applied all of the updates above. When I try the swap fix I get an error:

Traceback (most recent call last):
  File "/home/ubuntu/systests/swap/./use1GB.py", line 13, in <module>
    arr = np.ones((1024,1024,1024, 1), dtype=np.uint8)
  File "/usr/lib/python3/dist-packages/numpy/core/numeric.py", line 204, in ones
    a = empty(shape, dtype, order)
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 1.00 GiB for an array with shape (1024, 1024, 1024, 1) and data type uint8

Not sure if that has do to with me being on an RPi 3B+ not a 4???

/K

PS - on the bright side with the wheels on the motor test worked as expected
:slight_smile:

1 Like

Even w/o the swap fix working I tried all of the test on https://github.com/slowrunner/ROS2-GoPiGo3/blob/main/Docs/Test_ROS2_GoPiGo3.md (well, the first 3, since I don’t have a servo).

Everything worked. Driving from the keyboard was fine, and overall didn’t seem too slow (or too much latency). I ssh’d in from Ubuntu using WSL on my Windows desktop.

So - so far so good with the RPi3B+ running ROS2.

Next step - check out the lidar. But first, since we’re now using Ubuntu 22.04 Jammy/ROS2 Humble, and since I got a new laptop this fall, I took the opportunity to repurpose the laptop I was previously using for ROS, and have put Jammy Jellyfish on my former personal laptop. Now I need to install ROS2 Humble on that laptop. Although I should probably look into trying WSL on my desktop computer, or even trying ROS2 on Win11. Lots of rabbit holes to dive down :slight_smile:

/K

2 Likes

Perhaps the maximum allocatable memory to a process might be the size of the physical memory, I don’t really know if an entire process must be able to fit in physical memory. If so, then you might be able to run three processes that each used half a gig say. Each one will fit in memory by itself, and two could be swapped out while any one was executing. But I thought I tested a 2gb and a 1gb with my 2 Gb pi4, so I expected that you would be able to run the use1gb.

You rebooted and saw free -h showing 1GB swap free?

2 Likes

I think the ROS works good anywhere, but the visualization tools and sim have problems from what I have read. I didn’t pay too much attention because the say they only officially test on the recommended Ubuntu release and don’t even recommend mixing ROS version over a later Ubuntu version than tested for that release.

2 Likes

Very interested to see if you get 100% readings with my config file parameters set. Did I document using the LiDAR test I created. I was going so quickly to get it released I don’t recall what I documented. There are some things on the image I didn’t think would be needed by users initially.

2 Likes

No - didn’t doc that. I fired up Dave this morning!! and added documentation for testing the lidar scans:

2 Likes