Every GoPiGo3 Has A Worm In Its Brain!

Wow - discovered that every GoPiGo3 has a C. Elegans worm in its brain!

Well, in the GoPiGo3/Projects/Connectome folder, and we can put the code into our GoPiGo3 robot’s “brain” to run a (sequential) neural net simulating the “mind of the C. Elegans worm”.

I added speech and Dave immediately began annoying me with his “worm thoughts”.

As @cleoqc advised, there are some issues with the project code implementations, even on the Raspberry Pi4.

The original was written when only the Raspberry Pi B+, single core processor was available, and the CEO/Pres of DexterIndustries attempted an “experimentalOptimization”, which indeed has a faster cycle time, but Dave mainly sits announcing the amount of food in his virtual stomach more than pleasant to hear or watch.

When Dave’s “worm brain” first finds the food, it seems to pound Dave’s nose into the food (wall) risking a motor stall, so I have to keep “pulling the worm out of his brain”.

If he keeps this up Dave’s head is going to have worms coming out like Carl’s has been for the last eight years:


you’re just having so much fun, aren’t you? :slight_smile:

1 Like

FYI, Dalhousie University in Halifax, Canada, has been using the Jupyter Notebook version with their Masters students. Well, I dont know if they still do, but they did for a couple of years at least.

1 Like

Cool - got it loaded on my Mac - it opened right up in a browser tab - amazing.

WORM on Mac

=== Install Jupyter Notebook

  • mkdir jupyter-projects

  • cd jupyter-projects

  • python3 -m venv venv_jupyter

  • source venv_jupyter/bin/activate

  • pip install notebook

=== Bring down worm project

run it

  • jupyter notebook

  • Double Click Connectome project

I’m going to have to resurrect my mock_easygopigo3.py module from 2016-2017. I used it with my RugWarriorPro robot before I bought my first GoPiGo3. The “worm” only uses the distance sensor read() and a few motor calls. I can simulate the motor calls, and ask for a distance sensor reading, I think, and the “worm” will never know it isn’t running on a GoPiGo3.

The program has a “Comment sections out to run without GoPiGo3” but I prefer not to mess with the code until I can see it running.

Hmm, I don’t even remember doing that LOL!!
Go me! :slight_smile:

1 Like

Same behavior: When it touches some food (dist < 100 or 200cm), it stops for a few “bites or smells”, then slowly starts toward the food, and then races forward jamming its nose against the food. Might work for a worm, but very disturbing robot behavior!

Actually I haven’t the slightest idea what the outputs are saying, or what the worm is “thinking”.

And when the worm is given a 0 distance, it reads one more time, and if again 0, the worm explodes!

Little terrorists they are.

OBSTACLE (Nose Touch) dist:15.0
Left Eye on (40, 10, 10) Right Eye On (40, 10, 10)
Left:  0 Right: 0 Speed:  150
Left Eye on (5, 5, 5) Right Eye On (5, 5, 5)

My analysis of the Connectome C. Elegans simulation with the GoPiGo3 robot.

First we should define the expected behaviors (Google Search edited for applicability):

C. elegans is a millimeter-long soil nematode with a remarkably simple, mapped nervous system (302 neurons). Its behavioral repertoire is highly stereotyped, primarily consisting of sinusoidal locomotion, foraging, feeding, and basic sensory responses. [1, 2, 3, 4, 5]

Explore its specific behaviors in greater detail:

  1. Locomotion and Movement
  • Sinusoidal Crawling: C. elegans moves by propagating rhythmic, dorsoventral muscle contractions along its body, resulting in an “S-shaped” or sinusoidal wave pattern. [1, 2, 3]
  • Foraging: When searching for food, the worm exhibits ** klinotaxis**, sweeping its head from side to side to detect chemical gradients, before turning sharply to adjust direction. [1, 2, 3, 4, 5]
  • Reversal and Omega Turns: Upon encountering aversive stimuli, it initiates an “omega turn” (bending into a sharp U-shape) or a reversal (backing up) to change its heading. [1]
  1. Sensory and Avoidance Responses
  • Chemosensation & Olfaction: Its primary senses are chemical and olfactory. It relies on these to find nutrient-rich bacterial patches and to navigate away from noxious chemicals or pathogens. [1, 2]
  • Mechanosensation: The worm responds to touch. A gentle tap on the head causes it to reverse, while a tap on the tail prompts forward acceleration. It also exhibits proprioception, sensing its own body position. [1, 2, 3, 4, 5]
  1. Feeding Behaviors
  • Pharyngeal Pumping: The worm feeds on bacteria by using a muscular organ called the pharynx. It utilizes “pumping” (rapid suction and relaxation) to draw liquid and bacteria into its mouth, grinding the food before passing it to the intestine. [1, 2]
  • Quiescence: When food is plentiful, the worm will eventually become satiated, slowing or halting its pumping and locomotion in a sleeplike state

The GoPiGo3 Simulation:

A great simulation of C. Elegans with the GoPiGo3 robot

  • would use a panning servo mounted distance sensor to simulate the scanning motion of the head
  • would perhaps differentiate food from obstacles/adversaries (when satiated/not moving):
    • small sweep angle distance constant = obstacle
    • small sweep angle distance decreasing = adversary
    • large sweep angle distance constant = food field
  • would simulate forward motion by forward motion by arcing slowly

The existing code runs on a basic GoPiGo3 with a Distance Sensor (not servo mounted).

The Connectome code appears to try to simulate the moving phase (not well), and the satiated phase (very boring, and not sure what behaviors can be triggered). I cannot understand the nose touch being a long distance, and cannot figure out the emerging behaviors from sensor input.

I’m tempted to increase or maybe even remove the time limits on the motion commands, and see if the robot will simulate the undulating worm motion. I need to time the computation loop, to see how the robot would be driving blind. It seems like the motion time limits are way too short.

(I also cannot copy out the Jupyter print output more than the run window height even though it is scrollable and the text is selectable, I cannot copy the selected output to the clipboard.)

Ok - My version - still booooring but slightly less boring…

The output:

(gopigo3) ubuntu@U26LDave:~/LyricalDave/systests/worm$ python3 GoPiGo3Connectome.py 
Voltage:  10.674
FOOD
0
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.713s
Satiated Rest: 0.5
FOOD
1
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.713s
Satiated Rest: 1.0
FOOD
0
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
Satiated Rest: 1.5
FOOD
1
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.717s
Satiated Rest: 2.0
Satiated Rest: 2.5
Inside SAFE_TURN_DIST (19cm) - Turning till clear
OBSTACLE (Nose Touch) dist:22
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.716s
OBSTACLE (Nose Touch) dist:23
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
OBSTACLE (Nose Touch) dist:23
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
OBSTACLE (Nose Touch) dist:23
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
OBSTACLE (Nose Touch) dist:23
Left:  1 Right: 1 Speed:  37.5
motorcontrol execution: 5.43s
runconnectome execution time 5.434s
OBSTACLE (Nose Touch) dist:21
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
Inside SAFE_TURN_DIST (14cm) - Turning till clear
OBSTACLE (Nose Touch) dist:21
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.716s
OBSTACLE (Nose Touch) dist:22
Left:  0 Right: 2 Speed:  37.5
motorcontrol execution: 4.31s
runconnectome execution time 4.312s
OBSTACLE (Nose Touch) dist:23
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.718s
OBSTACLE (Nose Touch) dist:23
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.716s
OBSTACLE (Nose Touch) dist:23
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
OBSTACLE (Nose Touch) dist:23
Left:  36 Right: 33 Speed:  37.5
motorcontrol execution: 6.13s
runconnectome execution time 6.128s
Satiated Rest: 3.0
Satiated Rest: 3.5
Satiated Rest: 4.0
Satiated Rest: 4.5
Satiated Rest: 5.0
Satiated Rest: 5.5
Satiated Rest: 6.0
Satiated Rest: 6.5
Satiated Rest: 7.0
Satiated Rest: 7.5
Satiated Rest: 8.0
Satiated Rest: 8.5
Satiated Rest: 9.0
Satiated Rest: 9.5
Satiated Rest: 10.0
Satiated Rest: 10.5
FOOD
0
Left:  23 Right: 23 Speed:  37.5
motorcontrol execution: 6.3s
runconnectome execution time 6.303s
Satiated Rest: 0.5
FOOD
1
Left:  0 Right: 1 Speed:  37.5
motorcontrol execution: 4.33s
runconnectome execution time 4.332s
Satiated Rest: 1.0
FOOD
0
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.714s
Satiated Rest: 1.5
FOOD
1
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.721s
Satiated Rest: 2.0
Satiated Rest: 2.5
Satiated Rest: 3.0
Satiated Rest: 3.5
Satiated Rest: 4.0
Satiated Rest: 4.5
Satiated Rest: 5.0
Satiated Rest: 5.5
Satiated Rest: 6.0
Satiated Rest: 6.5
Satiated Rest: 7.0
Satiated Rest: 7.5
Satiated Rest: 8.0
Satiated Rest: 8.5
Satiated Rest: 9.0
Satiated Rest: 9.5
Satiated Rest: 10.0
Satiated Rest: 10.5
FOOD
0
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.716s
Satiated Rest: 0.5
FOOD
1
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.72s
runconnectome execution time 3.718s
Satiated Rest: 1.0
FOOD
0
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
Satiated Rest: 1.5
FOOD
1
Left:  1 Right: 2 Speed:  37.5
motorcontrol execution: 8.59s
runconnectome execution time 8.592s
Satiated Rest: 2.0
Satiated Rest: 2.5
Satiated Rest: 3.0
Satiated Rest: 3.5
Satiated Rest: 4.0
Satiated Rest: 4.5
Satiated Rest: 5.0
Satiated Rest: 5.5
Satiated Rest: 6.0
Satiated Rest: 6.5
Satiated Rest: 7.0
Satiated Rest: 7.5
Satiated Rest: 8.0
Satiated Rest: 8.5
Satiated Rest: 9.0
Satiated Rest: 9.5
Satiated Rest: 10.0
Satiated Rest: 10.5
FOOD
0
Left:  0 Right: 3 Speed:  37.5
motorcontrol execution: 4.32s
runconnectome execution time 4.322s
Satiated Rest: 0.5
FOOD
1
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.715s
Satiated Rest: 1.0
FOOD
0
Left:  1 Right: 0 Speed:  37.5
motorcontrol execution: 4.34s
runconnectome execution time 4.338s
Satiated Rest: 1.5
FOOD
1
Left:  44 Right: 42 Speed:  43.0
motorcontrol execution: 6.22s
runconnectome execution time 6.221s
Satiated Rest: 2.0
Satiated Rest: 2.5
OBSTACLE (Nose Touch) dist:26
Left:  0 Right: 1 Speed:  37.5
Inside SAFE_TURN_DIST (26cm) - Turning till clear
motorcontrol execution: 16.1s
runconnectome execution time 16.080s
Satiated Rest: 3.0
Satiated Rest: 3.5
Satiated Rest: 4.0
Satiated Rest: 4.5
Satiated Rest: 5.0
Satiated Rest: 5.5
Satiated Rest: 6.0
Satiated Rest: 6.5
Satiated Rest: 7.0
Satiated Rest: 7.5
Satiated Rest: 8.0
Satiated Rest: 8.5
Satiated Rest: 9.0
Satiated Rest: 9.5
Satiated Rest: 10.0
Satiated Rest: 10.5
FOOD
1
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.713s
Satiated Rest: 0.5
FOOD
0
Left:  1 Right: 1 Speed:  37.5
motorcontrol execution: 5.43s
runconnectome execution time 5.434s
Satiated Rest: 1.0
FOOD
1
Left:  1 Right: 0 Speed:  37.5
motorcontrol execution: 4.33s
runconnectome execution time 4.332s
Satiated Rest: 1.5
FOOD
0
Left:  0 Right: 0 Speed:  37.5
motorcontrol execution: 3.71s
runconnectome execution time 3.712s
Satiated Rest: 2.0
Satiated Rest: 2.5
Satiated Rest: 3.0
Inside SAFE_TURN_DIST (20cm) - Turning till clear
Inside SAFE_TURN_DIST (20cm) - Turning till clear
^C
Ctrl+C detected. Program Stopped!

Reviewing the original GoPiGo code, explains the “boring” aspect. The original code was all about moving, while the GoPiGo3 code has a stop() everywhere there is a “go thought” making the loop time 4 seconds long.

I’m going to leave further explorations into “thinking like a worm” to the next person to “dig the nematodes out of the dirt”.