CollaborativeRobotHubNet

CollaborativeRobotHubNet preview image

1 collaborator

Screen_shot_2021-10-29_at_8.40.47_am Corey Brady (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0 • Viewed 476 times • Downloaded 52 times • Run 0 times
Download the 'CollaborativeRobotHubNet' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [ gpio ]

to do-hubnet-reset
  hubnet-reset  
  set reset-hubnet false
end 

to setup 
  ca
  if (reset-hubnet) [ do-hubnet-reset ] 
  gpio:set-mode "gpio7" "WRITE"
  let i 2
  while [ i <= 12 ]
  [
  gpio:set-mode (word "gpio" i) "WRITE"
  set i i + 2
  ]
  ask patches with [ pxcor < 0 ] [ set pcolor red - 3 ]
  ask patches with [ pxcor > 0 ] [ set pcolor green - 3 ]
  reset-ticks
end 

to execute-votes [vote-left vote-right]
  let vlist get-votelist vote-left vote-right
  ;show vlist
  
  let i 2
  while [ i <= 12 ]
  [
    let towrite "LOW"
    if  item (-1 + i / 2) vlist = 1 [ set towrite "HIGH" ]
    
    gpio:digital-write (word "gpio" i) towrite
    ;show (word "gpio:digital-write " (word "gpio" i) towrite)
    set i i + 2
  ]
end 

to-report get-votelist [ vleft vright ]
  let returnlist n-values 6 [0]
  if vleft > 0 [ set returnlist replace-item 0 returnlist 1 ]
  if vright > 0 [set returnlist replace-item 3 returnlist 1 ]
  let t floor ((abs vleft) / 2)
  let r (abs vleft) mod 2
  set returnlist replace-item 1 returnlist r
  set returnlist replace-item 2 returnlist t
  
  let tr floor ((abs vright) / 2)
  let rr (abs vright) mod 2
  set returnlist replace-item 4 returnlist rr
  set returnlist replace-item 5 returnlist tr
  
  report returnlist
end 

to display-votes [vleft vright]
  ask patch -5 7 [ set plabel "left" ]
  ask patch (max-pxcor - 2) 7 [ set plabel "right" ]
  ask patch -5 -3 [ set plabel vleft ]
  ask patch (max-pxcor - 2) -3 [ set plabel vright ]
end 

to kill
  gpio:digital-write "gpio7" "LOW" 
end 

to unkill
  gpio:digital-write "gpio7" "HIGH"   
end 

to hubnet-control
  if (reset-hubnet) [ do-hubnet-reset ]
  let lvotes 0
  let rvotes 0
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    ifelse (hubnet-enter-message? or hubnet-exit-message?) 
    [ show "enter or exit" ]
    [
      if hubnet-message-tag = "left-forward" [ set lvotes lvotes + 1 ]
      if hubnet-message-tag = "left-backward" [ set lvotes lvotes - 1 ]
      if hubnet-message-tag = "right-forward" [ set rvotes rvotes + 1 ]
      if hubnet-message-tag = "right-backward" [ set rvotes rvotes - 1 ]
    ]
  ]
  set lvotes round (lvotes / sensitivity)
  set rvotes round (rvotes / sensitivity)
  if lvotes > 3 [ set lvotes 3 ]
  if rvotes > 3 [ set rvotes 3 ]
  if lvotes < -3 [ set lvotes -3 ]
  if rvotes < -3 [ set rvotes -3 ]
  
  display-votes lvotes rvotes
  execute-votes lvotes rvotes
end 

There are 2 versions of this model.

Uploaded by When Description Download
Corey Brady over 10 years ago fix switch state Download this version
Corey Brady over 10 years ago Initial upload Download this version

Attached files

File Type Description Last updated
CollaborativeRobotHubNet.png preview Preview for 'CollaborativeRobotHubNet' over 10 years ago, by Corey Brady Download

This model does not have any ancestors.

This model does not have any descendants.