├── .gitignore
├── .project
├── .readthedocs.yaml
├── Firmware
├── GoPiGo3_Firmware_1.0.0.bin
├── archives
│ ├── GoPiGo3_Firmware_0.2.5.bin
│ ├── GoPiGo3_Firmware_0.2.6.bin
│ ├── GoPiGo3_Firmware_0.3.0.bin
│ ├── GoPiGo3_Firmware_0.3.1.bin
│ ├── GoPiGo3_Firmware_0.3.2.bin
│ ├── GoPiGo3_Firmware_0.3.3.bin
│ └── GoPiGo3_Firmware_0.3.4.bin
├── check_if_firmware_update_is_needed.py
├── gopigo3_flash_firmware.sh
├── rpi1.cfg
├── rpi2.cfg
└── rpi4-sysfsgpio.cfg
├── GoPiGo3_Raspberry_Pi_Robot.jpg
├── GoPiGo3_Raspberry_Pi_Robot_With_Eyes.jpg
├── Hardware
├── GoPiGo3 Body.stl
├── GoPiGo3 Chassis Acrylic.svg
├── GoPiGo3 Robot.stl
├── GoPiGo3 Spacer Acrylic.svg
├── GoPiGo3 Wheel.stl
├── GoPiGo3 v3.1.3.pdf
└── GoPiGo3 v3.2.0.pdf
├── Install
├── README.md
├── antenna_wifi.service
├── antenna_wifi.sh
├── gpg3_power.service
├── gpg3_power.sh
├── install.sh
├── install_scratch.sh
├── list_of_serial_numbers.pkl
├── tools
│ ├── 16TickRedboardCodes.txt
│ └── remove_serial_numbers.py
└── update_gopigo3.sh
├── LICENSE.md
├── Projects
├── BalanceBot
│ └── BalanceBot.py
├── BasicRobotControl
│ ├── README.md
│ ├── keyboarded_robot.py
│ └── run_this.py
├── CompassRobot
│ ├── README.md
│ └── compass_robot.py
├── Connectome
│ ├── Connectome.ipynb
│ ├── GoPiGo3Connectome.py
│ ├── LICENSE
│ ├── README.md
│ ├── connectome.py
│ └── experimentalOptimization.py
├── Empathybot
│ ├── Emotions.jpg
│ ├── Empathybot.jpg
│ ├── README.md
│ └── empathybot.py
├── IntelligentObjectAvoider
│ ├── README.md
│ ├── devsketches
│ │ ├── math-sketches1.jpg
│ │ └── math-sketches2.jpg
│ └── robot.py
├── MouseControl
│ ├── README.ipynb
│ ├── README.md
│ ├── mouse_control_robot.ipynb
│ └── mouse_control_robot.py
├── ObjectAvoidanceRobot
│ ├── README.md
│ └── object_avoidance_robot.py
├── PIDLineFollower
│ ├── README.md
│ ├── menu.PNG
│ └── pid_tuner.py
├── Pixy2LaneTracker
│ ├── Pixy2DatasetGenerator.ipynb
│ ├── Pixy2LaneFollowerEfficientOnDataset.ipynb
│ ├── Pixy2LaneFollowerOnDataset.ipynb
│ ├── README.md
│ ├── config.json
│ ├── dataset
│ │ └── pixy2_vector_dataset.obj
│ ├── pixy2_lane_follower.py
│ ├── requirements.txt
│ └── videos
│ │ ├── efficient_pixy2_lane_follower.avi
│ │ └── ema_efficient_pixy2_lane_follower.avi
├── Pixy2ObjectTracker
│ ├── README.md
│ └── pixy2_object_tracker.py
├── RemoteCameraRobot
│ ├── README.md
│ ├── camerarobot.service
│ ├── complex_version
│ │ ├── robot_server.py
│ │ ├── uv4l-raspicam.conf
│ │ └── web_server.js
│ ├── install_startup.sh
│ ├── remote_robot.py
│ ├── requirements.txt
│ ├── static
│ │ ├── favicon.ico
│ │ ├── jquery-3.2.1.min.js
│ │ ├── nipplejs.js
│ │ ├── plane_loading.gif
│ │ ├── style.css
│ │ ├── throttle.js
│ │ └── waiting.svg
│ └── templates
│ │ └── index.html
└── ServoControl
│ ├── README.md
│ ├── keyboarded_robot.py
│ └── run_this.py
├── README.md
├── Software
├── C
│ ├── CMakeLists.txt
│ ├── Examples
│ │ ├── drive.cpp
│ │ ├── grove_led.cpp
│ │ ├── i2c.cpp
│ │ ├── info.cpp
│ │ ├── leds.cpp
│ │ ├── motors.cpp
│ │ ├── sensors.cpp
│ │ ├── servos.cpp
│ │ └── vbatt.cpp
│ ├── GoPiGo3.cpp
│ ├── GoPiGo3.h
│ ├── gopigo3_cppConfig.cmake.in
│ └── package.xml
├── Csharp
│ └── README.md
├── Go
│ └── readme.md
├── Java
│ ├── .gitignore
│ ├── README.md
│ ├── main
│ │ └── java
│ │ │ ├── com
│ │ │ └── dexterindustries
│ │ │ │ ├── DemoEasyGoPiGo3.java
│ │ │ │ ├── DemoSensors.java
│ │ │ │ └── gopigo3driver
│ │ │ │ ├── AnalogSensor.java
│ │ │ │ ├── ButtonSensor.java
│ │ │ │ ├── Buzzer.java
│ │ │ │ ├── DigitalSensor.java
│ │ │ │ ├── EasyGoPiGo3.java
│ │ │ │ ├── GoPiGo3.java
│ │ │ │ ├── Led.java
│ │ │ │ ├── LoudnessSensor.java
│ │ │ │ ├── Sensor.java
│ │ │ │ ├── Servo.java
│ │ │ │ └── constants
│ │ │ │ └── SPI_MESSAGE_TYPE.java
│ │ │ ├── install.sh
│ │ │ ├── run_demo.sh
│ │ │ └── run_file.sh
│ └── src
│ │ └── main
│ │ └── java
│ │ ├── .project
│ │ ├── .settings
│ │ └── org.eclipse.m2e.core.prefs
│ │ ├── com
│ │ └── dexterindustries
│ │ │ ├── .gitignore
│ │ │ └── .project
│ │ └── pom.xml
├── NodeJS
│ ├── .babelrc
│ ├── .editorconfig
│ ├── .eslintignore
│ ├── .eslintrc
│ ├── .gitignore
│ ├── .travis.yml
│ ├── CHANGELOG.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE.md
│ ├── README.md
│ ├── calibrate
│ │ └── lineSensor.js
│ ├── examples
│ │ ├── EasyMotors.js
│ │ ├── Grove.js
│ │ ├── GroveBuzzer.js
│ │ ├── Grove_I2C.js
│ │ └── custom
│ │ │ ├── buzzer.js
│ │ │ ├── dht.js
│ │ │ ├── easyLed.js
│ │ │ ├── readInfo.js
│ │ │ ├── salut.js
│ │ │ └── ultrasonic.js
│ ├── install.sh
│ ├── package.json
│ ├── src
│ │ ├── components
│ │ │ ├── analogSensor.js
│ │ │ ├── buttonSensor.js
│ │ │ ├── buzzer.js
│ │ │ ├── dhtSensor.js
│ │ │ ├── digitalSensor.js
│ │ │ ├── distanceSensor.js
│ │ │ ├── led.js
│ │ │ ├── lightSensor.js
│ │ │ ├── lineFollower.js
│ │ │ ├── lineFollower
│ │ │ │ ├── blackLine.txt
│ │ │ │ ├── lineFollow.js
│ │ │ │ ├── lineThresholdSet.js
│ │ │ │ ├── rangeLine.txt
│ │ │ │ └── whiteLine.txt
│ │ │ ├── loudnessSensor.js
│ │ │ ├── motionSensor.js
│ │ │ ├── remote.js
│ │ │ ├── sensor.js
│ │ │ ├── servo.js
│ │ │ ├── soundSensor.js
│ │ │ └── ultraSonicSensor.js
│ │ ├── easyGopigo3.js
│ │ ├── errors
│ │ │ ├── firmwareVersionError.js
│ │ │ ├── i2cError.js
│ │ │ ├── sensorError.js
│ │ │ └── valueError.js
│ │ ├── gopigo3.js
│ │ ├── index.js
│ │ └── utils
│ │ │ ├── enumeration.js
│ │ │ ├── i2cMutex.js
│ │ │ └── misc.js
│ ├── test
│ │ └── index.js
│ └── uninstall.sh
├── Python
│ ├── Examples
│ │ ├── Calibration_Panel
│ │ │ ├── calibration_panel_gui.py
│ │ │ ├── drive-config-icon.png
│ │ │ └── gopigo3_calibration.desktop
│ │ ├── Control_Panel
│ │ │ ├── GoPiGo3.png
│ │ │ ├── __init__.py
│ │ │ ├── control_panel_gui_3.py
│ │ │ ├── dex.png
│ │ │ └── gopigo3_control_panel.desktop
│ │ ├── Grove.py
│ │ ├── Grove_Buzzer.py
│ │ ├── Grove_I2C.py
│ │ ├── Grove_IR.py
│ │ ├── Grove_LED.py
│ │ ├── Grove_Light_Sensor.py
│ │ ├── Grove_US.py
│ │ ├── Grove_US2.py
│ │ ├── LED.py
│ │ ├── Line_Sensor
│ │ │ ├── README.md
│ │ │ ├── basic_example.py
│ │ │ └── line_follower-basic_example.py
│ │ ├── Motor.py
│ │ ├── Motor_Encoder.py
│ │ ├── Motor_Follow.py
│ │ ├── Motor_Position.py
│ │ ├── Motor_Speed.py
│ │ ├── Motor_Turn.py
│ │ ├── Read_Info.py
│ │ ├── Remote_Control.py
│ │ ├── Servo.py
│ │ ├── __init__.py
│ │ ├── easy_Blinkers.py
│ │ ├── easy_Button.py
│ │ ├── easy_Buzzer.py
│ │ ├── easy_DexEyes.py
│ │ ├── easy_Distance_Sensor.py
│ │ ├── easy_LED.py
│ │ ├── easy_Light_Sensor.py
│ │ ├── easy_Motors.py
│ │ └── gps_reading.py
│ ├── easygopigo3.py
│ ├── easysensors.py
│ ├── gopigo3.py
│ ├── hardware_test.py
│ ├── mock_package
│ │ ├── __init__.py
│ │ └── distance_sensor.py
│ ├── package_description.rst
│ ├── setup.cfg
│ ├── setup.py
│ └── tests
│ │ ├── test_distance_sensor.py
│ │ ├── test_distance_sensor_2.py
│ │ ├── test_heavy_mutex.py
│ │ ├── test_heavy_mutex_2.py
│ │ ├── test_mutex.py
│ │ └── test_sensor_mutex.py
├── Scratch
│ ├── Examples
│ │ ├── GoPiGo3_Basic_test.sb
│ │ ├── GoPiGo3_Light_Sensor.sb
│ │ ├── GoPiGo3_Loudness.sb
│ │ ├── GoPiGo3_Ultrasonic_Servo.sb
│ │ ├── GoPiGo3_button_example.sb
│ │ ├── GoPiGo3_control_panel.sb
│ │ ├── GoPiGo3_line_follower.sb
│ │ ├── GoPiGo3_square.sb
│ │ ├── button_example.sb
│ │ └── icons
│ │ │ ├── GPG_small.png
│ │ │ ├── arrow89.png
│ │ │ ├── dex.png
│ │ │ ├── fast19.png
│ │ │ ├── light59.png
│ │ │ ├── off.png
│ │ │ └── stop.png
│ ├── GoPiGo3Scratch.py
│ ├── Local_Scratch_Start.desktop
│ ├── gopigo3addons.png
│ ├── gopigo3commands.png
│ ├── gopigo3deprecated.png
│ ├── gopigo3led.png
│ ├── gopigo3sensors.png
│ ├── new.sb
│ ├── readme.md
│ ├── start_local_scratch.sh
│ └── test_GoPiGo3Scratch.py
└── gopigo3_power.py
├── Troubleshooting
├── README.md
├── all_tests.sh
└── hardware_and_firmware_test.sh
├── docs
├── Makefile
├── make.bat
└── source
│ ├── about.rst
│ ├── api-advanced.rst
│ ├── api-basic
│ ├── deprecated.rst
│ ├── easygopigo3.rst
│ ├── index.rst
│ ├── sensors.rst
│ └── structure.rst
│ ├── conf.py
│ ├── devguide.rst
│ ├── faq.rst
│ ├── images
│ ├── GoPiGo3-Bottom_annotated-768x565.jpg
│ ├── GoPiGo3-Top-768x565.jpg
│ ├── button.gif
│ ├── dexter-logo.jpg
│ ├── dexter-logo.png
│ ├── dist_sensor.gif
│ ├── driving1.gif
│ ├── driving2.gif
│ ├── driving3.gif
│ ├── driving4.gif
│ ├── driving5.gif
│ ├── gopigo3.jpg
│ ├── gpg3_and_logo.jpg
│ ├── gpg3_ports.jpg
│ ├── gpg3_ports_clean.jpg
│ ├── gpg3_robot.svg
│ ├── led.gif
│ ├── light_sensor.gif
│ └── modular_robotics_logo.png
│ ├── index.rst
│ ├── quickstart.rst
│ ├── tutorials-advanced
│ └── tut-advanced.rst
│ └── tutorials-basic
│ ├── button.rst
│ ├── buzzer.rst
│ ├── distance_sensor.rst
│ ├── driving.rst
│ ├── index.rst
│ ├── led.rst
│ └── light_sensor.rst
└── environment.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io/api/python
2 |
3 | ### Python ###
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 | *$py.class
8 |
9 | # C extensions
10 | *.so
11 |
12 | # Distribution / packaging
13 | .Python
14 | env/
15 | build/
16 | develop-eggs/
17 | dist/
18 | downloads/
19 | eggs/
20 | .eggs/
21 | lib/
22 | lib64/
23 | parts/
24 | sdist/
25 | var/
26 | wheels/
27 | *.egg-info/
28 | .installed.cfg
29 | *.egg
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *,cover
50 | .hypothesis/
51 |
52 | # Translations
53 | *.mo
54 | *.pot
55 |
56 | # Django stuff:
57 | *.log
58 | local_settings.py
59 |
60 | # Flask stuff:
61 | instance/
62 | .webassets-cache
63 |
64 | # Scrapy stuff:
65 | .scrapy
66 |
67 | # Sphinx documentation
68 | docs/_build/
69 |
70 | # PyBuilder
71 | target/
72 |
73 | # Jupyter Notebook
74 | .ipynb_checkpoints
75 |
76 | # pyenv
77 | .python-version
78 |
79 | # celery beat schedule file
80 | celerybeat-schedule
81 |
82 | # dotenv
83 | .env
84 |
85 | # virtualenv
86 | .venv
87 | venv/
88 | ENV/
89 |
90 | # Spyder project settings
91 | .spyderproject
92 |
93 | # Rope project settings
94 | .ropeproject
95 |
96 | # End of https://www.gitignore.io/api/python
97 | sftp-config*
98 | .json
99 |
100 | .ftpconfig
101 | .vscode/*
102 |
103 | # PyCharm configuration files
104 | .idea/
105 |
106 | gpg3env/*
107 |
108 | .DS_Store
109 |
110 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | GoPiGo3
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 |
3 | conda:
4 | environment: environment.yml
5 |
--------------------------------------------------------------------------------
/Firmware/GoPiGo3_Firmware_1.0.0.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/GoPiGo3_Firmware_1.0.0.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.2.5.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.2.5.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.2.6.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.2.6.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.3.0.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.3.0.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.3.1.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.3.1.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.3.2.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.3.2.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.3.3.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.3.3.bin
--------------------------------------------------------------------------------
/Firmware/archives/GoPiGo3_Firmware_0.3.4.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Firmware/archives/GoPiGo3_Firmware_0.3.4.bin
--------------------------------------------------------------------------------
/Firmware/check_if_firmware_update_is_needed.py:
--------------------------------------------------------------------------------
1 | import gopigo3
2 | import os
3 |
4 | list_files = os.listdir('/home/pi/Dexter/GoPiGo3/Firmware')
5 | for onefile in list_files:
6 | # print (F"{onefile}: { onefile.find('GoPiGo3_Firmware_')}")
7 | if onefile.find("GoPiGo3_Firmware_") == 0:
8 | available_firmware = onefile[len("GoPiGo3_Firmware_"):-4]
9 | break
10 |
11 | try:
12 | g = gopigo3.GoPiGo3()
13 | current_firmware = g.get_version_firmware()
14 | if current_firmware == available_firmware:
15 | print(f"\nThe GoPiGo is already running the latest firmare: {current_firmware}. \nAn upgrade is not needed at this time.\n")
16 | exit(1)
17 | except Exception as e:
18 | print(e)
19 | print("Firmware upgrade is needed")
20 | exit(0)
--------------------------------------------------------------------------------
/Firmware/gopigo3_flash_firmware.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 |
4 | # check if upgrade is needed
5 | /usr/bin/python3 /home/pi/Dexter/GoPiGo3/Firmware/check_if_firmware_update_is_needed.py
6 | if [ $? -eq 1 ]
7 | then
8 | echo "Firmware is up to date and working properly."
9 | echo "Exiting firmware upgrade script file without changing anything."
10 | exit
11 | else
12 | echo "Attempting to upgrade firmware."
13 | fi
14 |
15 | # check the RPi version
16 | RPI_VERSION=$(python3 -c "import auto_detect_rpi; print (auto_detect_rpi.getRPIGenerationCode())")
17 |
18 | INTERFACE_FILE="none"
19 | if [ "$RPI_VERSION" == "RPI1" ] || [ "$RPI_VERSION" == "RPI0" ]; then
20 | # use rpi1 interface config file
21 | INTERFACE_FILE="rpi1.cfg"
22 | elif [ "$RPI_VERSION" == "RPI2" ] || [ "$RPI_VERSION" == "RPI3" ] || [ "$RPI_VERSION" == "RPI3B+" ] || [ "$RPI_VERSION" == "RPI3A+" ]; then
23 | # use rpi2 interface config file
24 | INTERFACE_FILE="rpi2.cfg"
25 | elif [ "$RPI_VERSION" == "RPI4" ]; then
26 | # use rpi4 interface config file
27 | echo "Flashing the firmware using a Pi4"
28 | INTERFACE_FILE="rpi4-sysfsgpio.cfg"
29 | fi
30 |
31 | if [ "$INTERFACE_FILE" == "none" ]; then
32 | # unsupported RPI
33 | echo "Unsupported RPi version '$RPI_VERSION'. Please report to support@dexterindustries.com"
34 | else
35 | echo "Using interface file '$INTERFACE_FILE' for RPi version '$RPI_VERSION'."
36 |
37 | SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
38 | echo $SCRIPT_DIR
39 | # Get the absolute path of the latest Firmware update
40 | FIRMWARE_FILE=$(sudo find $SCRIPT_DIR -maxdepth 1 -name "*.bin")
41 |
42 | echo $FIRMWARE_FILE
43 |
44 | if [ "$FIRMWARE_FILE" == "" ]; then
45 | echo "Failed to find firmware file."
46 | else
47 | echo "Updating the GoPiGo3 Firmware with '$FIRMWARE_FILE'"
48 |
49 | if [ "$INTERFACE_FILE" == "rpi4-sysfsgpio.cfg" ]; then
50 | sudo openocd -f $SCRIPT_DIR/$INTERFACE_FILE -c "transport select swd; set CHIPNAME at91samc20j18; source [find target/at91samdXX.cfg]; adapter srst delay 100; adapter srst pulse_width 100" -c "init; targets; reset halt; program $FIRMWARE_FILE verify; reset" -c "shutdown"
51 | else
52 | # flash the firmware - P2 and Pi3
53 | sudo openocd -f $SCRIPT_DIR/$INTERFACE_FILE -c "transport select swd; set CHIPNAME at91samc20j18; source [find target/at91samdXX.cfg]; adapter_khz 50; adapter_nsrst_delay 100; adapter_nsrst_assert_width 100" -c "init; targets; reset halt; program $FIRMWARE_FILE verify; reset" -c "shutdown"
54 | fi
55 |
56 | echo $(python -c "import gopigo3;g=gopigo3.GoPiGo3();print('Success.')")
57 | fi
58 | fi
59 |
--------------------------------------------------------------------------------
/Firmware/rpi1.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # Config for using Raspberry Pi's expansion header
3 | #
4 | # This is best used with a fast enough buffer but also
5 | # is suitable for direct connection if the target voltage
6 | # matches RPi's 3.3V and the cable is short enough.
7 | #
8 | # Do not forget the GND connection, pin 6 of the expansion header.
9 | #
10 |
11 | interface bcm2835gpio
12 |
13 | bcm2835gpio_peripheral_base 0x20000000
14 |
15 | # Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
16 | # These depend on system clock, calibrated for stock 700MHz
17 | # bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
18 | bcm2835gpio_speed_coeffs 113714 28
19 |
20 | # SWD pins swclk and swdio
21 | bcm2835gpio_swd_nums 25 24
22 |
23 | # reset pin
24 | bcm2835gpio_srst_num 18
25 | reset_config srst_only srst_push_pull
26 |
--------------------------------------------------------------------------------
/Firmware/rpi2.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # Config for using Raspberry Pi's expansion header
3 | #
4 | # This is best used with a fast enough buffer but also
5 | # is suitable for direct connection if the target voltage
6 | # matches RPi's 3.3V and the cable is short enough.
7 | #
8 | # Do not forget the GND connection, pin 6 of the expansion header.
9 | #
10 |
11 | interface bcm2835gpio
12 |
13 | bcm2835gpio_peripheral_base 0x3F000000
14 |
15 | # Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
16 | # These depend on system clock, calibrated for stock 700MHz
17 | # bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
18 | bcm2835gpio_speed_coeffs 146203 36
19 |
20 | # SWD pins swclk and swdio
21 | bcm2835gpio_swd_nums 25 24
22 |
23 | # reset pin
24 | bcm2835gpio_srst_num 18
25 | reset_config srst_only srst_push_pull
26 |
--------------------------------------------------------------------------------
/Firmware/rpi4-sysfsgpio.cfg:
--------------------------------------------------------------------------------
1 | adapter driver sysfsgpio
2 |
3 | sysfsgpio swd_nums 25 24
4 |
5 | # reset pin
6 | sysfsgpio srst_num 18
7 | reset_config srst_only srst_push_pull
8 |
--------------------------------------------------------------------------------
/GoPiGo3_Raspberry_Pi_Robot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/GoPiGo3_Raspberry_Pi_Robot.jpg
--------------------------------------------------------------------------------
/GoPiGo3_Raspberry_Pi_Robot_With_Eyes.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/GoPiGo3_Raspberry_Pi_Robot_With_Eyes.jpg
--------------------------------------------------------------------------------
/Hardware/GoPiGo3 Body.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Hardware/GoPiGo3 Body.stl
--------------------------------------------------------------------------------
/Hardware/GoPiGo3 Robot.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Hardware/GoPiGo3 Robot.stl
--------------------------------------------------------------------------------
/Hardware/GoPiGo3 Wheel.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Hardware/GoPiGo3 Wheel.stl
--------------------------------------------------------------------------------
/Hardware/GoPiGo3 v3.1.3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Hardware/GoPiGo3 v3.1.3.pdf
--------------------------------------------------------------------------------
/Hardware/GoPiGo3 v3.2.0.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Hardware/GoPiGo3 v3.2.0.pdf
--------------------------------------------------------------------------------
/Install/antenna_wifi.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Antenna Wifi Indicator
3 |
4 | [Service]
5 | Type=idle
6 | User=pi
7 | WorkingDirectory=/home/pi
8 | ExecStart=/bin/bash /home/pi/Dexter/GoPiGo3/Install/antenna_wifi.sh
9 | Restart=always
10 | RestartSec=10
11 |
12 | [Install]
13 | WantedBy=multi-user.target
14 |
--------------------------------------------------------------------------------
/Install/antenna_wifi.sh:
--------------------------------------------------------------------------------
1 | # 1 Detect if we are on a GoPiGo3
2 | # 2 Detect if we have Wifi connection
3 | # 3 Throw a yellow-orangey LED or turn it off
4 |
5 |
6 | # If detected_robot exists and it contains GoPiGo3, or
7 | # if it doesn't exist at all on standalone Raspbian
8 | if [ -f "/home/pi/Dexter/detected_robot.txt" ] && grep -q GoPiGo3 /home/pi/Dexter/detected_robot.txt || [ ! -f "/home/pi/Dexter/detected_robot.txt" ]
9 | then
10 | if iwgetid --scheme
11 | then
12 | python -c "import gopigo3;GPG=gopigo3.GoPiGo3();GPG.set_led(GPG.LED_WIFI,3,1,3)"
13 | else
14 | python -c "import gopigo3;GPG=gopigo3.GoPiGo3();GPG.set_led(GPG.LED_WIFI,1,0,0)"
15 | fi
16 | fi
17 |
--------------------------------------------------------------------------------
/Install/gpg3_power.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=GoPiGo3 Power Service
3 |
4 | [Service]
5 | Type=idle
6 | ExecStart=/usr/bin/env bash /home/pi/Dexter/GoPiGo3/Install/gpg3_power.sh
7 |
8 | [Install]
9 | WantedBy=multi-user.target
--------------------------------------------------------------------------------
/Install/gpg3_power.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 | # This script is used to detect if GPG3 connected and run the gopigo3_power.py
3 | # This script is called by gpg3_power.service
4 |
5 | # These lines are specific to the GoPiGo3
6 | SCRIPTDIR="$(readlink -f $(dirname $0))"
7 | echo $SCRIPTDIR
8 | REPO_PATH=$(readlink -f $(dirname $0) | grep -E -o "^(.*?\\GoPiGo3)")
9 |
10 |
11 | # Check if gopigo3_power.py is running.
12 | SERVICE='gopigo3_power.py'
13 | # To be able to do an update without crapping out, we need to have power management on. So let's directly turn it on.
14 | if ps ax | grep -v grep | grep $SERVICE > /dev/null
15 | then
16 | echo "$SERVICE service running."
17 | else
18 | echo "$SERVICE is not running"
19 | # Run the gopigo3_power.py if GPG3 detected
20 | sudo python3 $REPO_PATH/Software/gopigo3_power.py
21 | echo "$SERVICE started."
22 | fi
--------------------------------------------------------------------------------
/Install/list_of_serial_numbers.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Install/list_of_serial_numbers.pkl
--------------------------------------------------------------------------------
/Install/tools/16TickRedboardCodes.txt:
--------------------------------------------------------------------------------
1 | 15DAE40F5152433037202020FF19090B
2 | BFA818035152415447202020FF190B15
3 | F56E3CD55152415447202020FF191508
4 | B3A870185152415447202020FF192005
5 | 7800DBF05152415447202020FF191F1B
6 | 4D00F5905152415447202020FF19151E
7 | 14F946E55152415447202020FF190B33
8 | 5D8E5E7F5152415447202020FF192110
9 | DE6292AB5152415447202020FF190F0F
10 | 0A9630605152433037202020FF191A0F
11 | 5BDBC7625152433037202020FF192810
12 | 57FD598A5152415447202020FF192610
13 | CC1D88195152415447202020FF193112
14 | 166C5B985152415447202020FF191A28
15 | 19D73DC75152415447202020FF192927
16 | C86400EF5152415447202020FF192811
17 | E2FB97535152433037202020FF192731
18 | AD75BE4C5152433037202020FF192A35
19 | E09E8AA55152433037202020FF191A31
20 | 1A845F385152415447202020FF192334
21 | 57B2E1E15152415447202020FF192411
22 | B15803065151475154202020FF0E1435
23 | 992C6F685152433037202020FF192A32
24 | 5D67AA6A5152415447202020FF192908
25 | CE8462465152415447202020FF191F0F
26 | C532FAB95152433037202020FF191B32
27 | AE6DA2B65152433037202020FF193516
28 | A879E7005152433037202020FF191B33
29 | 8C96C5F85152415447202020FF191006
30 | 205DBF2F5152433037202020FF191915
31 | 1A04859B5152415447202020FF192327
32 | 02E1A4E95152433037202020FF192932
33 | 567904645152433037202020FF191115
34 | 5D124D255152433037202020FF190B0D
35 | 29E751345152415447202020FF191608
36 | BB73D1BA5152433037202020FF191F31
37 | FA3C9DA25152415447202020FF193227
38 | B63AF1475152433037202020FF192031
39 | A921BC215152433037202020FF19260E
40 | 86AB05F95152415447202020FF19250E
41 | FEA86D315152433037202020FF191515
42 | EABA41575152415447202020FF191F0E
43 | 7BE0ABF75152415447202020FF19251B
44 | A9A9E6AC5152433037202020FF192131
45 | 903AFAB85152415447202020FF19240E
46 | 02BE09135152433037202020FF192B15
47 | 2220EC9A5152415447202020FF190D05
48 | 2F1F46055152415447202020FF191505
49 | 75F0CDAA5152415447202020FF19081E
50 | C39CB2885152433037202020FF191D37
51 | E0025C1C5152415447202020FF191010
52 | FAA996F05152433037202020FF190712
53 | 025F2E9E5152433037202020FF19180F
54 | 502C79A35152415447202020FF191F04
55 |
--------------------------------------------------------------------------------
/Install/tools/remove_serial_numbers.py:
--------------------------------------------------------------------------------
1 | import pickle
2 | import json
3 |
4 | serial_file = "list_of_serial_numbers.pkl"
5 | with open(serial_file, 'rb') as f:
6 | serial_list = pickle.load(f)
7 |
8 | refurb = []
9 | with open('16TickRedboardCodes.txt') as f:
10 | for line in f:
11 | refurb.append(f.readline().strip('\n'))
12 |
13 |
14 | print(len(refurb))
15 | print(len(serial_list))
16 | print(len(serial_list)-len(refurb))
17 |
18 | for item in refurb:
19 | if item in serial_list:
20 | serial_list.remove(item)
21 | print(len(serial_list))
22 |
23 | print(serial_list[:5])
24 | for _ in range(4):
25 | serial_list.pop(0)
26 | print(serial_list[:5])
27 |
28 | with open('list_of_serial_numbers.pkl', 'wb') as handle:
29 | pickle.dump(serial_list, handle, protocol=pickle.HIGHEST_PROTOCOL)
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | License Information
2 | ===================
3 |
4 | Software License
5 | ----------------
6 |
7 | **All code (including all scripts, firmware, drivers, examples, and any other
8 | software) is released under the [MIT License].**
9 |
10 | [MIT License]: http://choosealicense.com/licenses/mit/
11 |
12 | MIT License
13 |
14 | Copyright (c) 2019 Dexter Industries
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining a copy
17 | of this software and associated documentation files (the "Software"), to deal
18 | in the Software without restriction, including without limitation the rights
19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20 | copies of the Software, and to permit persons to whom the Software is
21 | furnished to do so, subject to the following conditions:
22 |
23 | The above copyright notice and this permission notice shall be included in all
24 | copies or substantial portions of the Software.
25 |
26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 | SOFTWARE.
33 |
34 |
35 | Hardware License
36 | ----------------
37 |
38 | **The hardware designs are released under the [Creative Commons Attribution
39 | NonCommercial ShareAlike 4.0 License][CC4].**
40 |
41 | [CC4]: https://creativecommons.org/licenses/by-nc-sa/4.0/
42 |
--------------------------------------------------------------------------------
/Projects/BasicRobotControl/README.md:
--------------------------------------------------------------------------------
1 | # Basic Robot Control Panel
2 |
3 | With this program you can test a variety of functions of the GoPiGo3 ranging from built-in LEDs to moving the robot around. The available keys are described when the program is launched.
4 |
5 | The script can be launched this way:
6 | ```
7 | python run_this.py
8 | ```
9 |
10 | # The Control Panel
11 |
12 | The control panel the user sees when the program is launched can be rendered with formatted-text this way:
13 | ```
14 | Press the following keys to run the features of the GoPiGo3.
15 | To move the motors, make sure you have a fresh set of batteries powering the GoPiGo3.
16 |
17 | [key w ] : Move the GoPiGo3 forward
18 | [key s ] : Move the GoPiGo3 backward
19 | [key a ] : Turn the GoPiGo3 to the left
20 | [key d ] : Turn the GoPiGo3 to the right
21 | [key ] : Stop the GoPiGo3 from moving
22 | [key ] : Drive forward for 10 centimeters
23 | [key ] : Drive forward for 10 inches
24 | [key ] : Drive forward for 360 degrees (aka 1 wheel rotation)
25 | [key 1 ] : Turn ON/OFF left blinker of the GoPiGo3
26 | [key 2 ] : Turn ON/OFF right blinker of the GoPiGo3
27 | [key 3 ] : Turn ON/OFF both blinkers of the GoPiGo3
28 | [key 8 ] : Turn ON/OFF left eye of the GoPiGo3
29 | [key 9 ] : Turn ON/OFF right eye of the GoPiGo3
30 | [key 0 ] : Turn ON/OFF both eyes of the GoPiGo3
31 | [key ] : Change the eyes' color on the go
32 | [key ] : Exit
33 | ```
--------------------------------------------------------------------------------
/Projects/Empathybot/Emotions.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/Empathybot/Emotions.jpg
--------------------------------------------------------------------------------
/Projects/Empathybot/Empathybot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/Empathybot/Empathybot.jpg
--------------------------------------------------------------------------------
/Projects/IntelligentObjectAvoider/devsketches/math-sketches1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/IntelligentObjectAvoider/devsketches/math-sketches1.jpg
--------------------------------------------------------------------------------
/Projects/IntelligentObjectAvoider/devsketches/math-sketches2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/IntelligentObjectAvoider/devsketches/math-sketches2.jpg
--------------------------------------------------------------------------------
/Projects/MouseControl/README.md:
--------------------------------------------------------------------------------
1 | # Mouse Control Project
2 |
3 | In this project, you'll be able to control your `GoPiGo3` robot with a ``wireless mouse``.
4 | Make sure you connect a `wireless mouse` to your `Raspberry Pi` and then launch the script (preferably with SSH).
5 |
6 | 
7 |
8 | When the ``mouse_control_robot`` script is launched (with either Python 2 or 3), the user
9 | is prompted to input a value which represents the mode of operation:
10 |
11 | * When the input value is `choice = 1`, the robot gets to be controlled by the mouse's buttons. Here's a list on what each combination of buttons does:
12 | * The `left` button of the mouse - moves the `GoPiGo3` to the left.
13 | * The `right` button of the mouse - moves the `GoPiGo3` to the right.
14 | * The `middle` button of the mouse - moves the `GoPiGo3` backward.
15 | * Both the `left` & the `right` buttons of the mouse - moves the `GoPiGo3` forward.
16 | * Not pressing any button keeps the robot stationary.
17 |
18 | * When the input value is `choice = 2`, the robot gets to be controlled by the mouse's movements.
19 | * Moving the mouse `forward`, makes the `GoPiGo3` to move forward.
20 | * Moving the mouse `backward`, makes the `GoPiGo3` to move backward.
21 | * Moving the mouse to the `left`, makes the `GoPiGo3` to move to the left.
22 | * Moving the mouse to the `right`, makes the `GoPiGo3` to move to the right.
23 | * Not moving the mouse in any direction keeps the robot stationary.
24 |
25 | When closing the app, press the `CTRL-C` combination of keys and move the mouse around just a little bit, so that the process stops. That's because the script uses blocking methods and while the mouse is stationary (and no buttons are pressed), the script is in a state of *"waiting"*.
26 |
27 | 
28 |
29 | ## On DexterOS
30 | In DexterOS it's not needed to install or configure anything. Any required dependency is already installed on it. Just make sure you've got the right physical configuration (sensors, servos, etc) and then run the script this way `python program-name.py`.
31 |
--------------------------------------------------------------------------------
/Projects/ObjectAvoidanceRobot/README.md:
--------------------------------------------------------------------------------
1 | # Obstacle Avoidance Robot
2 |
3 | In this project, we use a [DistanceSensor](https://www.dexterindustries.com/shop/distance-sensor/) for detecting obstacles with a [GoPiGo3](https://www.dexterindustries.com/shop/gopigo3-robot-base-kit/).
4 |
5 | The robot's speed is proportional to the distance from the target.
6 | When the target is too close to the robot, the GoPiGo3 robot stops. The robot will start moving again once the obstacle is removed from the robot's trajectory.
7 |
8 | This project can run with Python 2 and 3.
9 |
10 | ## On DexterOS
11 | In DexterOS it's not needed to install or configure anything. Any required dependency is already installed on it. Just make sure you've got the right physical configuration (sensors, servos, etc) and then run the script this way `python program-name.py`.
12 |
13 | ## Attention
14 |
15 | When the GoPiGo3 is low on battery, the script may inadvertently stop. Check the batteries before heading over to the forums.
16 |
17 | 
18 |
19 | ## About the script
20 |
21 | The DI-Sensor has to be connected to an I2C port with a Grove cable. Apart from that, there are a couple of constants that can be set within the script:
22 |
23 | * `DEBUG` : By default it's set to `False`, but if you wish to see more then set it to `True`.
24 | * `MAX_DISTANCE` : The maximum distance the sensor can detect in millimeters.
25 | * `MIN_DISTANCE` : The minimum distance the sensor can detect in millimeters.
26 | * `NO_OBSTACLE` : Don't modify this constant. When the sensor can't detect any surface, it returns a value equal to this constant.
27 | * `ERROR` : Don't modify this constant. When the sensor can't be detected, it returns a value equal to this constant.
28 | * `MAX_SPEED` : Through tests it has been proven that this constant's value is the optimum speed for the GoPiGo3.
29 | * `MIN_SPEED` : The minimum speed for the GoPiGo3. Can be set way lower.
30 |
31 | ## Preview of the GoPiGo3
32 |
33 |
34 | 
35 |
--------------------------------------------------------------------------------
/Projects/PIDLineFollower/README.md:
--------------------------------------------------------------------------------
1 | ## PID-based Controller for the Line Follower
2 |
3 | This is a project you can use to tune your GoPiGo + Line Follower (bot the red and black boards) to follow a black/white line.
4 |
5 | It all starts with the sensor of your choice: be it the old line follower (the red one) or the new one,
6 | which has a much higher poll rate, the sensors are more accurate and reliable, has a reduced power consumption and has a smaller footprint.
7 |
8 | 
9 |
10 | ### The Black Line Follower
11 |
12 | 
13 |
14 | ### The Red Line Follower
15 |
16 | 
17 |
18 | To find out more on interfacing with either sensor, check out the DI_Sensors [documentation](https://di-sensors.readthedocs.org).
19 |
20 | ### Optimal Values for Each Line Follower
21 |
22 | #### The Black Line Follower
23 |
24 | For the line follower (black board), the following parameters work best for the GoPiGo3:
25 |
26 | 1. Base Speed = 300
27 | 1. Loop Frequency = 100
28 | 1. Kp = 1100
29 | 1. Ki = 0
30 | 1. Kd = 1300
31 |
32 | #### The Red Line Follower
33 |
34 | For the line follower (red board), the following parameters work best for the GoPiGo3:
35 |
36 | 1. Base Speed = 300
37 | 1. Loop Frequency = 30
38 | 1. Kp = 4200
39 | 1. Ki = 0
40 | 1. Kd = 2500
41 |
42 | #### Running the Program
43 |
44 | To run the program, first be sure to have installed both the GoPiGo3 and DI_Sensors libraries and then
45 | run `python pid_controller.py` to run the program.
46 |
47 | Make use of the 2 available commands (`w` and `b`) in the menu to calibrate each line follower on a white and black surface.
48 |
49 | Next, update the Kp/Ki/Kd gains accordingly by using the appropriate commands listed in the menu and then finally let the GoPiGo3 run freely.
50 |
51 | _Note: Pay attention to the maximum update rate of both line followers: the line follower (black board) updates at a maximum rate of ~130Hz with the poll rate going up to ~500Hz whilst the line follower (red board) can do ~50Hz at most (both the update & poll rate)._
--------------------------------------------------------------------------------
/Projects/PIDLineFollower/menu.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/PIDLineFollower/menu.PNG
--------------------------------------------------------------------------------
/Projects/Pixy2LaneTracker/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "alfa": 0.1,
3 | "yotta": 0.2,
4 | "pid1": {
5 | "Kp": 1.75,
6 | "Ki": 0.002,
7 | "Kd": 9.0
8 | },
9 | "pid2": {
10 | "Kp": 3.5,
11 | "Ki": 0.001,
12 | "Kd": 2.0
13 | },
14 | "pid-switch-point": 45,
15 | "max-motor-speed": 350
16 | }
--------------------------------------------------------------------------------
/Projects/Pixy2LaneTracker/dataset/pixy2_vector_dataset.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/Pixy2LaneTracker/dataset/pixy2_vector_dataset.obj
--------------------------------------------------------------------------------
/Projects/Pixy2LaneTracker/requirements.txt:
--------------------------------------------------------------------------------
1 | recordclass
--------------------------------------------------------------------------------
/Projects/Pixy2LaneTracker/videos/efficient_pixy2_lane_follower.avi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/Pixy2LaneTracker/videos/efficient_pixy2_lane_follower.avi
--------------------------------------------------------------------------------
/Projects/Pixy2LaneTracker/videos/ema_efficient_pixy2_lane_follower.avi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/Pixy2LaneTracker/videos/ema_efficient_pixy2_lane_follower.avi
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/README.md:
--------------------------------------------------------------------------------
1 | # Remote Controlled GoPiGo3
2 |
3 | In this project we remotely control a GoPiGo3 robot via a mobile device or a laptop.
4 |
5 | 
6 |
7 | ## Requirements
8 |
9 | We need the following components for this project:
10 |
11 | * A [GoPiGo3](https://www.dexterindustries.com/gopigo3/) robot - it also includes the battery pack.
12 | * A [Raspberry Pi](https://www.dexterindustries.com/raspberry-pi/).
13 | * A [Pi Camera](https://www.dexterindustries.com/shop/raspberry-pi-camera/).
14 | * A laptop or a mobile device (aka smartphone).
15 |
16 | ## Setting Up
17 |
18 | In order to proceed the setup, make sure you have the `GoPiGo3` repository installed (not just cloned, but also installed) or that you have the latest version of `Raspbian For Robots`.
19 |
20 | After going through the above paragraph, install the `Pi Camera` dependencies and `Flask` by running following command:
21 | ```
22 | sudo pip3 install -r requirements.txt
23 | ```
24 |
25 | You should now have everything set up.
26 |
27 | ## Running it
28 |
29 | Start the server by typing the following command:
30 | ```
31 | python3 remote_robot.py
32 | ```
33 | It's going to take a couple of seconds for the server to fire up.
34 | The web app is set to port `5000` whereas the video stream is found at port `5001`.
35 |
36 | If you have got `Raspbian For Robots` installed, then going to `http://dex.local:5000` address will be enough.
37 | If you don't have `Raspbian For Robots`, then you'll need to see what's your interface's IP address.
38 |
39 | Also, please make sure you have your mobile device / laptop on the same network as your `GoPiGo3`. Otherwise, you won't be able to access it.
40 |
41 | ## Setting Up to Run on Boot
42 | You can run the server on boot so you don't have to run it manually. Use the command
43 | `install_startup.sh`
44 | and this should start the flask server on boot. You should be able to connect to the robot using "http://dex.local:5000" or if using the Cinch setup, you can use "http://10.10.10.10:5000"
45 |
46 | You can setup Cinch, which will automatically setup a wifi access point, with the command
47 | `sudo bash /home/pi/di_update/Raspbian_For_Robots/upd_script/wifi/cinch_setup.sh`
48 | On reboot, connect to the WiFi service "Dex".
49 |
50 | ## YouTube Video
51 |
52 | #### When loading `http://dex.local:5000` for the first time, click a couple of times on the screen without moving the mouse around, in order to enable the "joystick" functionality.
53 |
54 | Here's a YouTube video of this project:
55 |
56 | [](https://youtu.be/jyg_nt28ktk)
57 |
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/camerarobot.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=CameraBotStart
3 | After=graphical.target multi-user.target
4 | Wants=troubleshoot.service
5 |
6 | [Service]
7 | Type=idle
8 | ExecStart=/usr/bin/python3 /home/pi/Dexter/GoPiGo3/Projects/RemoteCameraRobot/remote_robot.py
9 | Restart=always
10 | RestartSec=15
11 |
12 | [Install]
13 | WantedBy=multi-user.target
14 |
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/complex_version/robot_server.py:
--------------------------------------------------------------------------------
1 | import socket
2 | import sys
3 | import easygopigo3
4 | import signal
5 |
6 | HOST = "localhost"
7 | PORT = 5002
8 | BUFF_SIZE = 128
9 | try:
10 | gopigo3 = easygopigo3.EasyGoPiGo3()
11 | gopigo3.set_speed(100)
12 | print("GoPiGo3 detected")
13 | except IOError as msg:
14 | print("GoPiGo3 failure message: " + str(msg))
15 | sys.exit(1)
16 |
17 | try:
18 | print("creating socket server")
19 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
20 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
21 | sock.bind((HOST, PORT))
22 | except socket.error as msg:
23 | print("server error code: " + str(msg[0]))
24 | print("server failure message: " + str(msg[1]))
25 | sys.exit(1)
26 | print("bind socket complete on address " + HOST + ":" + str(PORT))
27 | sock.listen(1)
28 | print("listening for client")
29 |
30 | def gopigo3_instructions(connection, addr):
31 | recv_string = connection.recv(BUFF_SIZE).strip().lower()
32 | while recv_string != "close" and len(recv_string) > 0:
33 | print("received [" + recv_string + "] command")
34 | if recv_string == "forward":
35 | gopigo3.forward()
36 | elif recv_string == "left":
37 | gopigo3.left()
38 | elif recv_string == "right":
39 | gopigo3.right()
40 | elif recv_string == "stop":
41 | gopigo3.stop()
42 | elif recv_string == "dexleds on":
43 | gopigo3.open_eyes()
44 | elif recv_string == "dexleds off":
45 | gopigo3.close_eyes()
46 | else:
47 | print("[" + repr(recv_string) + "] command unknown")
48 |
49 | recv_string = connection.recv(BUFF_SIZE).strip().lower()
50 |
51 | if recv_string == "close":
52 | print("received [" + recv_string + "] command")
53 | if len(recv_string) == 0:
54 | print("received FIN from client")
55 |
56 | try:
57 | connection = None
58 |
59 | while True:
60 | connection, addr = sock.accept()
61 | print("connected with " + addr[0] + ":" + str(addr[1]))
62 |
63 | try:
64 | gopigo3_instructions(connection, addr)
65 | except socket.error as msg:
66 | print("Socket error code: " + str(msg[0]))
67 | print("Socket failure message: " + str(msg[1]))
68 |
69 | connection.close()
70 | print("disconnected from client")
71 |
72 | except (KeyboardInterrupt, SystemExit):
73 | if connection:
74 | connection.close()
75 |
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/install_startup.sh:
--------------------------------------------------------------------------------
1 | # Installation file to make the Camera Robot start on boot.
2 | # This will add the camerarobot start on boot to SystemD on Stretch
3 |
4 | sudo cp camerarobot.service /etc/systemd/system/
5 | sudo chmod 644 /etc/systemd/system/camerarobot.service
6 | sudo systemctl daemon-reload
7 | sudo systemctl enable camerarobot.service
8 |
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/requirements.txt:
--------------------------------------------------------------------------------
1 | flask==2.3.2
2 | werkzeug==3.0.6
3 | picamera==1.13
4 |
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/RemoteCameraRobot/static/favicon.ico
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/static/plane_loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Projects/RemoteCameraRobot/static/plane_loading.gif
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/static/style.css:
--------------------------------------------------------------------------------
1 | #zone_joystick {
2 | display: block;
3 | position: absolute;
4 | width: 100%;
5 | height: 100%;
6 | left: 0;
7 | top: 0;
8 | }
9 |
10 | #video_source{
11 | display:block;
12 | width:100%; height:100%;
13 | object-fit: cover;
14 | background-color: white;
15 | background-image: url("/static/plane_loading.gif"), url('/static/waiting.svg');
16 | background-size: auto 100%;
17 | background-repeat: no-repeat;
18 | background-position: center center;
19 | }
20 |
21 | .robot {
22 | position: absolute;
23 | height: auto;
24 | width: 20%;
25 | min-width: 220px;
26 | left: 0.5%;
27 | top: 0.5%;
28 | padding: 1%;
29 | font-family: "Lucida Sans Typewriter";
30 | color: rgb(68, 68, 68);
31 | background: rgba(223, 226, 219, 0.7);
32 | }
33 |
34 |
35 | /*
36 | CSS settings for the commented section in index.html
37 | video {
38 | position: fixed;
39 | top: 50%;
40 | left: 50%;
41 | min-width: 100%;
42 | min-height: 100%;
43 | width: auto;
44 | height: auto;
45 | z-index: -100;
46 | transform: translateX(-50%) translateY(-50%);
47 | background: url('//demosthenes.info/assets/images/polina.jpg') no-repeat;
48 | background-size: cover;
49 | transition: 1s opacity;
50 | }
51 |
52 |
53 | @media screen and (max-width: 500px) {
54 | div{width:70%;}
55 | }
56 | @media screen and (max-device-width: 800px) {
57 | html { background: url(https://thenewcode.com/assets/images/polina.jpg) #000 no-repeat center center fixed; }
58 | #bgvid { display: none; }
59 | }*/
--------------------------------------------------------------------------------
/Projects/RemoteCameraRobot/static/throttle.js:
--------------------------------------------------------------------------------
1 | // Returns a function, that, when invoked, will only be triggered at most once
2 | // during a given window of time. Normally, the throttled function will run
3 | // as much as it can, without ever going more than once per `wait` duration;
4 | // but if you'd like to disable the execution on the leading edge, pass
5 | // `{leading: false}`. To disable execution on the trailing edge, ditto.
6 |
7 | function throttle(func, wait, options) {
8 | var context, args, result;
9 | var timeout = null;
10 | var previous = 0;
11 | if (!options) options = {};
12 | var later = function() {
13 | previous = options.leading === false ? 0 : Date.now();
14 | timeout = null;
15 | result = func.apply(context, args);
16 | if (!timeout) context = args = null;
17 | };
18 | return function() {
19 | var now = Date.now();
20 | if (!previous && options.leading === false) previous = now;
21 | var remaining = wait - (now - previous);
22 | context = this;
23 | args = arguments;
24 | if (remaining <= 0 || remaining > wait) {
25 | if (timeout) {
26 | clearTimeout(timeout);
27 | timeout = null;
28 | }
29 | previous = now;
30 | result = func.apply(context, args);
31 | if (!timeout) context = args = null;
32 | } else if (!timeout && options.trailing !== false) {
33 | timeout = setTimeout(later, remaining);
34 | }
35 | return result;
36 | };
37 | };
--------------------------------------------------------------------------------
/Projects/ServoControl/README.md:
--------------------------------------------------------------------------------
1 | # Servo Control Panel
2 |
3 | With this program you can test the servo functionality on the GoPiGo3. The available keys are described when the program is launched.
4 |
5 | The script can be launched this way:
6 | ```
7 | python run_this.py
8 | ```
9 |
10 | # The Control Panel
11 |
12 | The control panel the user sees when the program is launched can be rendered with formatted-text this way:
13 | ```
14 | Press the following keys to run the features of the GoPiGo3.
15 | To rotate the servos, make sure you have a fresh set of batteries powering the GoPiGo3.
16 | Use servos that can turn to 180 degrees as some have difficulties doing it.
17 |
18 | [key ] : Turn SERVO1 completely to 0 degrees
19 | [key ] : Turn SERVO1 completely to 180 degrees
20 | [key ] : Turn SERVO2 completely to 0 degrees
21 | [key ] : Turn SERVO2 completely to 180 degrees
22 | [key a ] : Turn SERVO1 towards 0 degrees incrementely
23 | [key d ] : Turn SERVO1 towords 180 degrees incrementely
24 | [key ] : Turn SERVO2 towards 0 degrees incrementely
25 | [key ] : Turn SERVO2 towards 180 degrees incrementely
26 | [key ] : Turn off power supply to both servos
27 | [key ] : Exit
28 | ```
--------------------------------------------------------------------------------
/Software/C/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | project(gopigo3_cpp)
3 |
4 | ### Build
5 |
6 | include_directories(.)
7 |
8 | ## GoPiGo3 library
9 | add_library(gopigo3 SHARED GoPiGo3.cpp)
10 |
11 | ## Examples
12 |
13 | # grove_led
14 | add_executable(grove_led Examples/grove_led.cpp)
15 | target_link_libraries(grove_led gopigo3)
16 |
17 | # i2c
18 | add_executable(i2c Examples/i2c.cpp)
19 | target_link_libraries(i2c gopigo3)
20 |
21 | # info
22 | add_executable(info Examples/info.cpp)
23 | target_link_libraries(info gopigo3)
24 |
25 | # leds
26 | add_executable(leds Examples/leds.cpp)
27 | target_link_libraries(leds gopigo3)
28 |
29 | # motors
30 | add_executable(motors Examples/motors.cpp)
31 | target_link_libraries(motors gopigo3)
32 |
33 | # sensors
34 | add_executable(sensors Examples/sensors.cpp)
35 | target_link_libraries(sensors gopigo3)
36 |
37 | # drive
38 | add_executable(drive Examples/drive.cpp)
39 | target_link_libraries(drive gopigo3)
40 |
41 | # servo example
42 | add_executable(servos Examples/servos.cpp)
43 | target_link_libraries(servos gopigo3)
44 |
45 | # vbatt example
46 | add_executable(vbatt Examples/vbatt.cpp)
47 | target_link_libraries(vbatt gopigo3)
48 |
49 | ### Installation
50 |
51 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
52 | DESTINATION include
53 | FILES_MATCHING PATTERN "*.h"
54 | PATTERN "Examples" EXCLUDE
55 | )
56 |
57 | install(TARGETS gopigo3 EXPORT gopigo3Targets
58 | LIBRARY DESTINATION lib
59 | ARCHIVE DESTINATION lib
60 | RUNTIME DESTINATION bin
61 | INCLUDES DESTINATION include
62 | )
63 |
64 | ### Export CMake configuration
65 |
66 | set_property(TARGET gopigo3 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
67 | $
68 | $
69 | )
70 |
71 | set(CONF_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include/)
72 |
73 | export(EXPORT gopigo3Targets
74 | FILE "${PROJECT_BINARY_DIR}/gopigo3_cppTargets.cmake")
75 |
76 | configure_file(gopigo3_cppConfig.cmake.in
77 | "${CMAKE_CURRENT_BINARY_DIR}/gopigo3_cppConfig.cmake" @ONLY)
78 |
79 | install(FILES
80 | "${CMAKE_CURRENT_BINARY_DIR}/gopigo3_cppConfig.cmake"
81 | DESTINATION share/gopigo3_cpp/cmake)
82 |
83 | install(EXPORT gopigo3Targets
84 | FILE gopigo3_cppTargets.cmake
85 | DESTINATION share/gopigo3_cpp/cmake
86 | )
87 |
--------------------------------------------------------------------------------
/Software/C/Examples/grove_led.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This is an example for using an ultrasonic sensor and IR receiver with the GoPiGo3.
10 | *
11 | * Hardware: Connect a grove LED to GPG3 AD1 port.
12 | *
13 | * Results: When you run this program, you should see the grove LED brightness pulsing up and down.
14 | *
15 | * Example compile command:
16 | * g++ -o grove_led grove_led.cpp ../GoPiGo3.cpp -I..
17 | * Example run command:
18 | * sudo ./grove_led
19 | *
20 | */
21 |
22 | #include // for GoPiGo3
23 | #include // for printf
24 | #include // for usleep
25 | #include // for catching exit signals
26 |
27 | GoPiGo3 GPG;
28 |
29 | void exit_signal_handler(int signo);
30 |
31 | int main(){
32 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
33 |
34 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
35 |
36 | GPG.set_grove_type(GROVE_1, GROVE_TYPE_CUSTOM);
37 | GPG.set_grove_mode(GROVE_1_1, OUTPUT_PWM);
38 |
39 | int8_t i = 0;
40 | int8_t a = 1;
41 | while(true){
42 | GPG.set_grove_pwm_duty(GROVE_1_1, i);
43 | i += a;
44 | if(i == 100 || i == 0){
45 | a *= -1;
46 | }
47 | usleep(5000);
48 | }
49 | }
50 |
51 | // Signal handler that will be called when Ctrl+C is pressed to stop the program
52 | void exit_signal_handler(int signo){
53 | if(signo == SIGINT){
54 | GPG.reset_all(); // Reset everything so there are no run-away motors
55 | exit(-2);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Software/C/Examples/i2c.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This is an example for using I2C with the GoPiGo3.
10 | *
11 | * Hardware: Connect a PCA9570 I2C output expander to GPG3 AD1 port.
12 | *
13 | * Results: When you run this program, P0 output should toggle.
14 | *
15 | * Example compile command:
16 | * g++ -o i2c i2c.cpp ../GoPiGo3.cpp -I..
17 | * Example run command:
18 | * sudo ./i2c
19 | *
20 | */
21 |
22 | #include // for GoPiGo3
23 | #include // for printf
24 | #include // for usleep
25 | #include // for catching exit signals
26 |
27 | GoPiGo3 GPG;
28 |
29 | void exit_signal_handler(int signo);
30 |
31 | int main(){
32 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
33 |
34 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
35 |
36 | GPG.set_grove_type(GROVE_1, GROVE_TYPE_I2C);
37 | i2c_struct_t I2C1;
38 | I2C1.address = 0x24;
39 | I2C1.length_read = 3;
40 | I2C1.length_write = 1;
41 | uint8_t s = 0;
42 | while(true){
43 | I2C1.buffer_write[0] = s;
44 | int error = GPG.grove_i2c_transfer(GROVE_1, &I2C1);
45 | printf("Error: %d bytes: %d %d %d\n", error, I2C1.buffer_read[0], I2C1.buffer_read[1], I2C1.buffer_read[2]);
46 | if(s == 0){
47 | s = 1;
48 | }else{
49 | s = 0;
50 | }
51 | usleep(50000);
52 | }
53 | }
54 |
55 | // Signal handler that will be called when Ctrl+C is pressed to stop the program
56 | void exit_signal_handler(int signo){
57 | if(signo == SIGINT){
58 | GPG.reset_all(); // Reset everything so there are no run-away motors
59 | exit(-2);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Software/C/Examples/info.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This code is an example for reading GoPiGo3 information
10 | *
11 | * Results: Print information about the attached GoPiGo3.
12 | *
13 | * Example compile command:
14 | * g++ -o info info.cpp ../GoPiGo3.cpp -I..
15 | * Example run command:
16 | * sudo ./info
17 | *
18 | */
19 |
20 | #include // for GoPiGo3
21 | #include // for printf
22 |
23 | GoPiGo3 GPG; // Create a GoPiGo3 instance
24 |
25 | int main(){
26 | char str[33]; // Room for the 32-character serial number string plus the NULL terminator.
27 |
28 | // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
29 | // pass 'false' to detect() to make the error non-critical (return the error instead of exiting the program).
30 | if(GPG.detect(false) == ERROR_NONE){
31 | printf("\nGoPiGo3 info:\n");
32 |
33 | GPG.get_manufacturer(str);
34 | printf(" Manufacturer : %s\n", str);
35 |
36 | GPG.get_board(str);
37 | printf(" Board : %s\n", str);
38 |
39 | GPG.get_id(str);
40 | printf(" Serial Number : %s\n", str);
41 |
42 | GPG.get_version_hardware(str);
43 | printf(" Hardware version: %s\n", str);
44 |
45 | GPG.get_version_firmware(str);
46 | printf(" Firmware version: %s\n", str);
47 |
48 | printf(" Battery voltage : %.3f\n", GPG.get_voltage_battery());
49 | printf(" 5v voltage : %.3f\n", GPG.get_voltage_5v());
50 | }else{
51 | printf("\nError communicating with GoPiGo3\n");
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Software/C/Examples/leds.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This code is an example for using GoPiGo3 motors.
10 | *
11 | * Results: When you run this program, you should see the encoder value for each motor. Manually rotate the left motor, and the right motor will follow.
12 | *
13 | * Example compile command:
14 | * g++ -o leds leds.cpp ../GoPiGo3.cpp -I..
15 | * Example run command:
16 | * sudo ./leds
17 | *
18 | */
19 |
20 | #include // for GoPiGo3
21 | #include // for printf
22 | #include // for usleep
23 | #include // for catching exit signals
24 |
25 | GoPiGo3 GPG;
26 |
27 | #define BRIGHTNESS_LIMIT 25
28 |
29 | void exit_signal_handler(int signo);
30 |
31 | int main(){
32 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
33 |
34 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
35 |
36 | uint8_t i1 = 0;
37 | uint8_t i2 = BRIGHTNESS_LIMIT / 3;
38 | uint8_t i3 = (BRIGHTNESS_LIMIT * 2) / 3;
39 | int8_t a1 = 1;
40 | int8_t a2 = 1;
41 | int8_t a3 = 1;
42 | while(true){
43 | GPG.set_led(LED_EYE_LEFT, i1, i2, i3);
44 | GPG.set_led(LED_EYE_RIGHT, i2, i3, i1);
45 | GPG.set_led(LED_BLINKER_LEFT, i1);
46 | GPG.set_led(LED_BLINKER_RIGHT, i2);
47 |
48 | i1 += a1;
49 | if(i1 == BRIGHTNESS_LIMIT || i1 == 0){
50 | a1 *= -1;
51 | }
52 | i2 += a2;
53 | if(i2 == BRIGHTNESS_LIMIT || i2 == 0){
54 | a2 *= -1;
55 | }
56 | i3 += a3;
57 | if(i3 == BRIGHTNESS_LIMIT || i3 == 0){
58 | a3 *= -1;
59 | }
60 |
61 | // slow down
62 | usleep(25000);
63 | }
64 | }
65 |
66 | // Signal handler that will be called when Ctrl+C is pressed to stop the program
67 | void exit_signal_handler(int signo){
68 | if(signo == SIGINT){
69 | GPG.reset_all(); // Reset everything so there are no run-away motors
70 | exit(-2);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Software/C/Examples/motors.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This code is an example for using GoPiGo3 motors.
10 | *
11 | * Results: When you run this program, you should see the encoder value for each motor. Manually rotate the left motor, and the right motor will follow.
12 | *
13 | * Example compile command:
14 | * g++ -o motors motors.cpp ../GoPiGo3.cpp -I..
15 | * Example run command:
16 | * sudo ./motors
17 | *
18 | */
19 |
20 | #include // for GoPiGo3
21 | #include // for printf
22 | #include // for usleep
23 | #include // for catching exit signals
24 |
25 | GoPiGo3 GPG;
26 |
27 | void exit_signal_handler(int signo);
28 |
29 | int main(){
30 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
31 |
32 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
33 |
34 | // Reset the encoders
35 | GPG.offset_motor_encoder(MOTOR_LEFT, GPG.get_motor_encoder(MOTOR_LEFT));
36 | GPG.offset_motor_encoder(MOTOR_RIGHT, GPG.get_motor_encoder(MOTOR_RIGHT));
37 |
38 | while(true){
39 | // Read the encoders
40 | int32_t EncoderLeft = GPG.get_motor_encoder(MOTOR_LEFT);
41 | int32_t EncoderRight = GPG.get_motor_encoder(MOTOR_RIGHT);
42 |
43 | // Use the encoder value from the left motor to control the position of the right motor
44 | GPG.set_motor_position(MOTOR_RIGHT, EncoderLeft);
45 |
46 | // Display the encoder values
47 | printf("Encoder Left: %6d Right: %6d\n", EncoderLeft, EncoderRight);
48 |
49 | // Delay for 20ms
50 | usleep(20000);
51 | }
52 | }
53 |
54 | // Signal handler that will be called when Ctrl+C is pressed to stop the program
55 | void exit_signal_handler(int signo){
56 | if(signo == SIGINT){
57 | GPG.reset_all(); // Reset everything so there are no run-away motors
58 | exit(-2);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Software/C/Examples/sensors.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This is an example for using an ultrasonic sensor and IR receiver with the GoPiGo3.
10 | *
11 | * Hardware: Connect a grove ultrasonic sensor to GPG3 AD1 port, and IR receiver to GPG3 AD2 port.
12 | *
13 | * Results: When you run this program, you should see the values for each sensor.
14 | *
15 | * Example compile command:
16 | * g++ -o sensors sensors.cpp ../GoPiGo3.cpp -I..
17 | * Example run command:
18 | * sudo ./sensors
19 | *
20 | */
21 |
22 | #include // for GoPiGo3
23 | #include // for printf
24 | #include // for usleep
25 | #include // for catching exit signals
26 |
27 | GoPiGo3 GPG;
28 |
29 | void exit_signal_handler(int signo);
30 |
31 | int main(){
32 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
33 |
34 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
35 |
36 | GPG.set_grove_type(GROVE_1, GROVE_TYPE_US);
37 | GPG.set_grove_type(GROVE_2, GROVE_TYPE_IR_DI_REMOTE);
38 | sensor_ultrasonic_t US;
39 | sensor_infrared_gobox_t IR;
40 |
41 | while(true){
42 | int USerror = GPG.get_grove_value(GROVE_1, &US);
43 | int IRerror = GPG.get_grove_value(GROVE_2, &IR);
44 | printf("US: Error %d %4dmm IR: Error %d button %d\n", USerror, US.mm, IRerror, IR.button);
45 | usleep(20000);
46 | }
47 | }
48 |
49 | // Signal handler that will be called when Ctrl+C is pressed to stop the program
50 | void exit_signal_handler(int signo){
51 | if(signo == SIGINT){
52 | GPG.reset_all(); // Reset everything so there are no run-away motors
53 | exit(-2);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Software/C/Examples/servos.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * https://www.dexterindustries.com/GoPiGo3/
3 | * https://github.com/DexterInd/GoPiGo3
4 | *
5 | * Copyright (c) 2017 Dexter Industries
6 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | *
9 | * This code is an example for using GoPiGo3 servos.
10 | *
11 | * Results: When you run this program, you should see the servos center.
12 | *
13 | * To compile see: https://github.com/slowrunner/Carl/blob/master/Examples/cpp/Alan_Note.txt
14 | */
15 |
16 | #include // for GoPiGo3
17 | #include // for printf
18 | #include // for usleep
19 | #include // for catching exit signals
20 |
21 | GoPiGo3 GPG;
22 |
23 | void exit_signal_handler(int signo);
24 |
25 | int main(){
26 | signal(SIGINT, exit_signal_handler); // register the exit function for Ctrl+C
27 |
28 | GPG.detect(); // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
29 |
30 | printf("\nReseting servos to center\n");
31 |
32 | // Reset the servos to center
33 | GPG.set_servo(SERVO_1,1500);
34 | // let one servo move at a time to keep load smaller
35 | usleep(200000);
36 | GPG.set_servo(SERVO_2,1500);
37 | usleep(200000);
38 | // Turn servo power off
39 | GPG.set_servo(SERVO_1,0);
40 | GPG.set_servo(SERVO_2,0);
41 |
42 | // while(true){
43 | // usleep(2000);
44 | // }
45 | GPG.reset_all();
46 | }
47 |
48 | // Signal handler that will be called when Ctrl+C is pressed to stop the program
49 | void exit_signal_handler(int signo){
50 | if(signo == SIGINT){
51 | GPG.reset_all(); // Reset everything so there are no run-away motors
52 | exit(-2);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Software/C/Examples/vbatt.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This code is an example for reading GoPiGo3 battery voltage
3 | *
4 | * Results: Prints float battery voltage
5 | *
6 | */
7 |
8 | #include // for GoPiGo3
9 | #include // for printf
10 |
11 | GoPiGo3 GPG; // Create a GoPiGo3 instance
12 |
13 | int main(){
14 |
15 | // Make sure that the GoPiGo3 is communicating and that the firmware is compatible with the drivers.
16 | // pass 'false' to detect() to make the error non-critical (return the error instead of exiting the program).
17 | if(GPG.detect(false) == ERROR_NONE){
18 | printf(" Battery voltage : %.3f\n", GPG.get_voltage_battery());
19 | printf(" 5v voltage : %.3f\n", GPG.get_voltage_5v());
20 | }else{
21 | printf("\nError communicating with GoPiGo3\n");
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Software/C/gopigo3_cppConfig.cmake.in:
--------------------------------------------------------------------------------
1 | # - Config file for the GOPIGO3 package
2 | # It defines the following variables
3 | # GOPIGO3_INCLUDE_DIRS - include directories for gopigo3_cpp
4 | # GOPIGO3_LIBRARIES - libraries to link against
5 |
6 | # Compute paths
7 | get_filename_component(GOPIGO3_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
8 | set(GOPIGO3_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
9 |
10 | # Our library dependencies (contains definitions for IMPORTED targets)
11 | if(NOT TARGET gopigo3 AND NOT GOPIGO3_BINARY_DIR)
12 | include("${GOPIGO3_CMAKE_DIR}/gopigo3_cppTargets.cmake")
13 | endif()
14 |
15 | # These are IMPORTED targets created by gopigo3_cppTargets.cmake
16 | set(GOPIGO3_LIBRARIES gopigo3)
--------------------------------------------------------------------------------
/Software/C/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | gopigo3_cpp
4 | 0.0.2
5 | C++ driver for GoPiGo3
6 |
7 | Modular Robotics
8 |
9 | MIT
10 |
11 | https://GoPiGo.io
12 | https://github.com/DexterInd/GoPiGo3
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | cmake
21 |
22 |
23 |
24 |
25 | cmake
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Software/Go/readme.md:
--------------------------------------------------------------------------------
1 | # Program the GoPiGo3 in the Go Programming Language
2 |
3 | GoBot is a next generation robotics and IOT framework in the Go Programming Language.
4 |
5 | This language was developed by members of our community and the [master code repo can be found here](https://github.com/hybridgroup/gobot/tree/master/examples).
6 |
7 | # Get Started
8 | [See the getting started guide here.](https://github.com/hybridgroup/gobot/blob/master/README.md)
9 |
10 | # Examples
11 |
12 | Example programs can be [found in github here.](https://github.com/hybridgroup/gobot/tree/master/examples) They include:
13 | * [Controlling the GoPiGo3 Eyes.](https://github.com/hybridgroup/gobot/blob/master/examples/gopigo3.go)
14 | * [Using a Grove Button.](https://github.com/hybridgroup/gobot/blob/master/examples/gopigo3_grove_button.go)
15 | * [Adding an LCD Panel.](https://github.com/hybridgroup/gobot/blob/master/examples/gopigo3_grove_lcd.go)
16 | * [Using a light sensor with your Raspberry Pi robot.](https://github.com/hybridgroup/gobot/blob/master/examples/gopigo3_grove_light_sensor.go)
17 | * [Controlling an LED Brightness](https://github.com/hybridgroup/gobot/blob/master/examples/gopigo3_led_brightness.go).
18 | * [Congrolling a Servo](https://github.com/hybridgroup/gobot/blob/master/examples/gopigo3_servo.go).
19 |
--------------------------------------------------------------------------------
/Software/Java/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .gradle
3 | build
4 | *.iml
5 | *.class
6 | .classpath
7 | .project
8 | .settings
--------------------------------------------------------------------------------
/Software/Java/README.md:
--------------------------------------------------------------------------------
1 | # JAVA INSTALLATION
2 | There are a few things you need to do before you can run Java code on the GoPiGo3.
3 | If you've installed the latest version of Raspbian for Robots, you may skip this step. Verify that folder /opt/ contains the following folders: pi4j and json-simple. If they do not, follow this procedure.
4 | Open up a command line on the GoPiGo3 and run the following commands:
5 |
6 | ```
7 | cd ~/Dexter/GoPiGo3/Software/Java_new/main/java
8 | sudo chmod +x *.sh
9 | ./install.sh
10 | ```
11 |
12 | This will install all the needed jar files and do all of the necessary prep work. You should only have to do this step once.
13 |
14 | # RUNNING PROGRAMS
15 | Dexter Industries provides two scripts to allow for easy compilation of java programs on the GoPiGo3.
16 | If you wish to run the demo, all you need to do is execute the run_demo.sh script. The robot will drive forwards a bit, turn around, and then drive in a arc before coming to a stop.
17 |
18 | If you wish to run your own programs, simply make sure to add the following import statement:
19 | ```import com.dexterindustries.gopigo3driver.*;```
20 |
21 | Then, use your favorite file transfer service to transfer it to the GoPiGo. Place it in your directory of choice, and copy the run_file.sh script to the same directory.
22 | Then, you just need to execute the run_file.sh script and pass the name of your file as an argument. Do not include the .java.
23 | For example, if your program is named Foo.java, the call should look like
24 | ```./run_file.sh Foo```
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/DemoEasyGoPiGo3.java:
--------------------------------------------------------------------------------
1 | //package com.dexterindustries;
2 |
3 |
4 | import java.time.Duration;
5 | import java.time.Instant;
6 |
7 | import com.dexterindustries.gopigo3driver.*;
8 | import static com.dexterindustries.gopigo3driver.constants.SPI_MESSAGE_TYPE.*;
9 |
10 | public class DemoEasyGoPiGo3 {
11 |
12 | public static void main(String[] args) throws Exception {
13 |
14 | System.out.println("GoPiGo3 Demo");
15 |
16 | EasyGoPiGo3 platform = new EasyGoPiGo3();
17 |
18 | platform.reset_encoders(true);
19 | System.out.println("Battery voltage: " + platform.volt());
20 | System.out.println("Driving forwards 60cm");
21 | platform.drive_cm(60, true);
22 |
23 | System.out.println("Turning around");
24 | platform.turn_degrees(180);
25 |
26 |
27 | platform.set_eye_color(150, 30, 60);
28 | System.out.println("Turning blinkers on");
29 | platform.blinker_on(1);
30 | platform.blinker_on("right");
31 | platform.open_eyes();
32 |
33 | System.out.println("Orbiting");
34 | platform.orbit(90, 30, true);
35 |
36 | System.out.println("Turning blinkers off");
37 | platform.blinker_off(0);
38 | platform.blinker_off("left");
39 | platform.close_eyes();
40 |
41 | System.out.println("Left motor pos: "+platform.get_motor_encoder(MOTOR_LEFT));
42 | System.out.println("Right motor pos: "+platform.get_motor_encoder(MOTOR_RIGHT));
43 |
44 | System.out.println("End demo");
45 |
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/DemoSensors.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries;
2 |
3 | import java.time.Duration;
4 | import java.time.Instant;
5 |
6 | import com.dexterindustries.gopigo3driver.*;
7 | import static com.dexterindustries.gopigo3driver.constants.SPI_MESSAGE_TYPE.*;
8 |
9 | public class Demo {
10 |
11 | public static void main(String[] args) throws Exception {
12 |
13 | System.out.println("GoPiGo3 Demo");
14 |
15 | EasyGoPiGo3 platform = new EasyGoPiGo3();
16 | LoudnessSensor castafiore = platform.init_loudness_sensor("AD1");
17 | System.out.println(castafiore.read());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/gopigo3driver/ButtonSensor.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries.gopigo3driver;
2 |
3 | import java.io.IOException;
4 |
5 | public class ButtonSensor extends DigitalSensor {
6 | /**
7 | * Constructor for initializing a ButtonSensor object
8 | * @param port can be either "AD1" or "AD2", depending on the port the LED is plugged into.
9 | * @param gpg an instance of a gopigo3 object
10 | * @param use_mutex when using multiple sensors in parallel, mutexes should be enabled.
11 | * @throws IOException
12 | * @throws InterruptedException
13 | */
14 | public ButtonSensor(String port, GoPiGo3 gpg, boolean use_mutex) throws IOException, InterruptedException {
15 | super(port, "DIGITAL_INPUT", gpg, use_mutex);
16 | set_descriptor("BUTTON");
17 | }
18 |
19 | /**
20 | * Checks if the button is pressed.
21 | * Note that in the case where SPI reading fails for whatever reason, this function will silently return false.
22 | * @return true if the button is currently being hold down, false if it isn't.
23 | * @throws IOException
24 | */
25 | public boolean is_button_pressed() throws IOException {
26 | return (read() == 1);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/gopigo3driver/Buzzer.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries.gopigo3driver;
2 |
3 | import java.io.IOException;
4 |
5 | public class Buzzer extends AnalogSensor {
6 | int power = 50;
7 | /**
8 | * Dictionary of frequencies for each musical note.
9 | *
10 | */
11 | public enum SCALE {
12 | A3 (220),
13 | A3S (233),
14 | B3 (247),
15 | C4 (261),
16 | C4S (277),
17 | D4 (293),
18 | D4S (311),
19 | E4 (329),
20 | F4 (370),
21 | F4S (370),
22 | G4 (392),
23 | G4S (415),
24 | A4 (440),
25 | A4S (466),
26 | B4 (494),
27 | C5 (523),
28 | C5S (554),
29 | D5 (587),
30 | D5S (622),
31 | E5 (659),
32 | F5 (698),
33 | F5S (740),
34 | G5 (784),
35 | G5S (831);
36 |
37 | private final int value;
38 |
39 | SCALE(int value) {
40 | this.value = value;
41 | }
42 |
43 | public int value() { return value; };
44 | }
45 |
46 | /**
47 | * Constructor for initializing a buzzer object.
48 | * Normally, this should be called by the init_buzzer() function of EasyGoPiGo3.
49 | * @param port can be either "AD1" or "AD2", depending on the port the LED is plugged into.
50 | * @param gpg an instance of a gopigo3 object
51 | * @param use_mutex when using multiple sensors in parallel, mutexes should be enabled.
52 | * @throws IOException
53 | * @throws InterruptedException
54 | */
55 | public Buzzer(String port, GoPiGo3 gpg, boolean use_mutex) throws IOException, InterruptedException {
56 | super(port, "OUTPUT", gpg, use_mutex);
57 | set_pin(1);
58 | set_descriptor("Buzzer");
59 | freq = 329;
60 | //sound_off();
61 | }
62 |
63 | /**
64 | * Sets a musical note to come from the buzzer.
65 | * You can use any number you wish for the musical note, but you can use the defined scale to make it easier.
66 | * In that case, the function call would look like this:
67 | * buzz.sound(Buzzer.SCALE.A4.value());
68 | * @param freq the frequency you wish the buzzer to sound at
69 | * @throws IOException
70 | */
71 | public void sound(int freq) throws IOException {
72 | if(freq <= 0) {
73 | power = 0;
74 | freq = 0;
75 | }
76 | else {
77 | power = 50;
78 | }
79 |
80 | if (power == 50) {
81 | write_freq(freq);
82 | }
83 | write(power);
84 | }
85 |
86 | /**
87 | * Shuts off the buzzer.
88 | * @throws IOException
89 | */
90 | public void sound_off() throws IOException {
91 | sound(0);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/gopigo3driver/DigitalSensor.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries.gopigo3driver;
2 |
3 | import com.pi4j.io.spi.SpiChannel;
4 | import com.pi4j.io.spi.SpiDevice;
5 | import com.pi4j.io.spi.SpiFactory;
6 |
7 | import java.io.IOException;
8 | import java.util.Arrays;
9 |
10 | import static com.dexterindustries.gopigo3driver.constants.SPI_MESSAGE_TYPE.*;
11 |
12 | public class DigitalSensor extends Sensor {
13 | protected int value; //can be 0 or 1, or sometimes -1 when reading fails.
14 | /**
15 | * Constructor for creating an analog connection to one of the ports on the GoPiGo3.
16 | *
17 | * @param port can take the following string values:
18 | * "AD1" for digital and analog pinmodes
19 | * "AD2" for digital and analog pinmodes
20 | *
21 | * @param pinmode can take the following string values:
22 | * "DIGITAL_INPUT" for digital inputs (the port can only detect 0 and 1)
23 | * "DIGITAL_OUTPUT" for digital outputs (the port can only send 0 and 1)
24 | *
25 | * @param gpg3 an instance of a gopigo3 object.
26 | * @throws IOException
27 | */
28 | public DigitalSensor(String port, String pinmode, GoPiGo3 gpg3, boolean use_mutex) throws IOException, InterruptedException {
29 | super(port, pinmode, gpg3, use_mutex);
30 | }
31 |
32 | /**
33 | * Reads a value from the sensor.
34 | * @return 0 and 1 are valid values. Returns a -1 if reading fails.
35 | * @throws IOException
36 | */
37 | public int read() throws IOException {
38 | try {
39 | value = gpg.get_grove_state(this.get_pin());
40 | }
41 | catch(Exception e){
42 | System.out.println("Digital read fail: "+e.toString());
43 | value = -1;
44 | }
45 | return value;
46 | }
47 | }
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/gopigo3driver/Led.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries.gopigo3driver;
2 |
3 | import java.io.IOException;
4 |
5 | public class Led extends AnalogSensor {
6 | /**
7 | * Constructor for initializing a Led object
8 | * @param port can be either "AD1" or "AD2", depending on the port the LED is plugged into.
9 | * @param gpg an instance of a gopigo3 object
10 | * @param use_mutex when using multiple sensors in parallel, mutexes should be enabled.
11 | * @throws IOException
12 | * @throws InterruptedException
13 | */
14 | public Led(String port, GoPiGo3 gpg, boolean use_mutex) throws IOException, InterruptedException {
15 | super(port, "OUTPUT", gpg, use_mutex);
16 | set_descriptor("LED");
17 | }
18 |
19 | /**
20 | * Sets the light to a specified power, in percent.
21 | * @param power Number from 0 to 100 that represents the power you wish the LED to shine at. Decimals are permitted, but any increment smaller than 0.1 will be ignored.
22 | * @throws IOException
23 | */
24 | public void light_on(double power) throws IOException {
25 | write(power);
26 | }
27 |
28 | /**
29 | * Sets the light to maximum brightness.
30 | * @throws IOException
31 | */
32 | public void light_max() throws IOException {
33 | max_value = 100;
34 | write(100.0);
35 | }
36 |
37 | /**
38 | * Turns the light off.
39 | * @throws IOException
40 | */
41 | public void light_off() throws IOException {
42 | write(0.0);
43 | }
44 |
45 | /**
46 | * Returns true if the LED is currently on, and false if it isn't.
47 | * @return a boolean representing the current state of the LED.
48 | * @throws IOException
49 | */
50 | public boolean is_on() throws IOException {
51 | return (value > 0);
52 | }
53 |
54 | /**
55 | * Returns true if the LED is currently off, and false if it isn't.
56 | * @return a boolean representing the current state of the LED.
57 | * @throws IOException
58 | */
59 | public boolean is_off() throws IOException {
60 | return (value == 0);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/gopigo3driver/LoudnessSensor.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries.gopigo3driver;
2 |
3 | import java.io.IOException;
4 |
5 | public class LoudnessSensor extends AnalogSensor {
6 | /**
7 | * Constructor for initializing a ButtonSensor object
8 | * @param port can be either "AD1" or "AD2", depending on the port the LED is plugged into.
9 | * @param gpg an instance of a gopigo3 object
10 | * @param use_mutex when using multiple sensors in parallel, mutexes should be enabled.
11 | * @throws IOException
12 | * @throws InterruptedException
13 | */
14 | public LoudnessSensor(String port, GoPiGo3 gpg, boolean use_mutex) throws IOException, InterruptedException {
15 | super(port, "INPUT", gpg, use_mutex);
16 | set_descriptor("LOUDNESS SENSOR");
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Software/Java/main/java/com/dexterindustries/gopigo3driver/Servo.java:
--------------------------------------------------------------------------------
1 | package com.dexterindustries.gopigo3driver;
2 |
3 | import java.io.IOException;
4 |
5 | public class Servo extends Sensor {
6 | private static int PULSE_WIDTH_RANGE = 1850;
7 |
8 | /**
9 | * Constructor for initializing a servo object
10 | * @param port can be either "SERVO1" or "SERVO2"
11 | * @param gpg an instance of a gopigo3 object
12 | * @param use_mutex when using multiple sensors in parallel, mutexes should be enabled.
13 | * @throws IOException
14 | * @throws InterruptedException
15 | */
16 | public Servo(String port, GoPiGo3 gpg, boolean use_mutex) throws IOException, InterruptedException {
17 | super(port, "OUTPUT", gpg, use_mutex);
18 | set_descriptor("SERVO");
19 | }
20 |
21 | /**
22 | * Rotates the servo to a specific angle.
23 | *
24 | * The pulse width here is in microseconds and varies int he following way:
25 | * 0 degrees = 575 uS.
26 | * 180 degrees = 24250 uS.
27 | * Thankfully, this function accepts inputs in degrees.
28 | * @param servo_position the target position in degrees.
29 | * @throws IOException
30 | */
31 | public void rotate_servo(double servo_position) throws IOException {
32 | if(servo_position > 180) {
33 | servo_position = 180;
34 | }
35 | if(servo_position < 0) {
36 | servo_position = 0;
37 | }
38 |
39 | int pulsewidth = (int)((1500 - (PULSE_WIDTH_RANGE/2)) + ((PULSE_WIDTH_RANGE/180) * servo_position));
40 | gpg.set_servo(get_port_id(), pulsewidth);
41 | }
42 |
43 | /**
44 | * Resets the servo straight ahead.
45 | * @throws IOException
46 | */
47 | public void reset_servo() throws IOException {
48 | rotate_servo(90);
49 | }
50 |
51 | /**
52 | * Disables the servo. The purpose of this command is so that if you try to turn the servo manually, it won't resist you.
53 | * @throws IOException
54 | */
55 | public void disable_servo() throws IOException {
56 | gpg.set_servo(get_port_id(), 0);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Software/Java/main/java/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | curl -ssl https://pi4j.com/install | sudo bash
3 | sudo mkdir /opt/java-json
4 | wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/json-simple/json-simple-1.1.1.jar
5 | sudo mv json-simple-1.1.1.jar /opt/java-json
6 | javac -classpath .:classes:/opt/pi4j/lib/'*' -d . com/dexterindustries/gopigo3driver/constants/*.java
7 | javac -classpath .:classes:/opt/pi4j/lib/'*':/opt/java-json/'*' -d . com/dexterindustries/gopigo3driver/*.java
--------------------------------------------------------------------------------
/Software/Java/main/java/run_demo.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sudo javac -classpath .:classes:/opt/pi4j/lib/'*':/opt/java-json/'*' -d . com/dexterindustries/DemoEasyGoPiGo3.java
3 | sudo java -classpath .:classes:/opt/pi4j/lib/'*':/opt/java-json/'*' com/dexterindustries/DemoEasyGoPiGo3
4 |
5 |
--------------------------------------------------------------------------------
/Software/Java/main/java/run_file.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | javac -classpath .:classes:/opt/pi4j/lib/'*':/opt/java-json/'*':/home/pi/Dexter/GoPiGo3/Software/Java_new/main/java -d . $1.java
3 | java -classpath .:classes:/opt/pi4j/lib/'*':/opt/java-json/'*':/home/pi/Dexter/GoPiGo3/Software/Java_new/main/java $1
4 |
5 |
--------------------------------------------------------------------------------
/Software/Java/src/main/java/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | java
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Software/Java/src/main/java/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/Software/Java/src/main/java/com/dexterindustries/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/Software/Java/src/main/java/com/dexterindustries/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | dexterindustries
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Software/Java/src/main/java/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | java
4 | java
5 | 0.0.1-SNAPSHOT
6 | pom
7 | java
8 |
--------------------------------------------------------------------------------
/Software/NodeJS/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["stage-2", "es2015"],
3 | "plugins": [
4 | "add-module-exports",
5 | "transform-class-properties"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/Software/NodeJS/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain
2 | # consistent coding styles between different editors and IDEs.
3 |
4 | root = true
5 |
6 | [*]
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 | indent_style = space
12 | indent_size = 4
13 |
14 | [*.md]
15 | trim_trailing_whitespace = false
16 |
--------------------------------------------------------------------------------
/Software/NodeJS/.eslintignore:
--------------------------------------------------------------------------------
1 | test
2 |
--------------------------------------------------------------------------------
/Software/NodeJS/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": "airbnb",
4 | "env": {
5 | "mocha": true
6 | },
7 | "rules": {
8 | "indent": [
9 | "error",
10 | 4
11 | ],
12 | "quote-props": ["error", "consistent"],
13 | "no-param-reassign": 0,
14 | "comma-dangle": 0,
15 | "no-plusplus": 0,
16 | "no-underscore-dangle": 0,
17 | "no-continue": 0,
18 | "no-multi-spaces": 0,
19 | "no-bitwise": 0,
20 | "no-self-compare": 0,
21 | "class-methods-use-this": 0,
22 | "no-mixed-operators": 0,
23 | "max-len": 0
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Software/NodeJS/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # nyc test coverage
18 | .nyc_output
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directories
30 | node_modules
31 | jspm_packages
32 | DI_Sensors
33 |
34 | # Optional npm cache directory
35 | .npm
36 | package-lock.json
37 |
38 | # Optional REPL history
39 | .node_repl_history
40 |
41 | # Editors
42 | .idea
43 |
44 | # Lib
45 | lib
46 |
--------------------------------------------------------------------------------
/Software/NodeJS/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "6"
4 | script:
5 | - npm run lint
6 | - npm run test
7 | - npm run build
8 | - npm run test:examples
9 | branches:
10 | only:
11 | - master
12 |
--------------------------------------------------------------------------------
/Software/NodeJS/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | ## 0.0.1 (2017-9-10)
5 |
6 | * Initial release
--------------------------------------------------------------------------------
/Software/NodeJS/LICENSE.md:
--------------------------------------------------------------------------------
1 | License Information
2 | ===================
3 |
4 | Software License
5 | ----------------
6 |
7 | **All code (including all scripts, firmware, drivers, examples, and any other
8 | software) is released under the [MIT License].**
9 |
10 | [MIT License]: http://choosealicense.com/licenses/mit/
11 |
12 | MIT License
13 |
14 | Copyright (c) 2017 Dexter Industries
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining a copy
17 | of this software and associated documentation files (the "Software"), to deal
18 | in the Software without restriction, including without limitation the rights
19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20 | copies of the Software, and to permit persons to whom the Software is
21 | furnished to do so, subject to the following conditions:
22 |
23 | The above copyright notice and this permission notice shall be included in all
24 | copies or substantial portions of the Software.
25 |
26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 | SOFTWARE.
33 |
34 |
35 | Hardware License
36 | ----------------
37 |
38 | **The hardware schematics are released under the [Creative Commons Attribution
39 | NonCommercial ShareAlike 4.0 License][CC4].**
40 |
41 | [CC4]: https://creativecommons.org/licenses/by-nc-sa/4.0/
--------------------------------------------------------------------------------
/Software/NodeJS/calibrate/lineSensor.js:
--------------------------------------------------------------------------------
1 | const EasyGopigo3 = require('../lib/easyGopigo3');
2 |
3 | const gpg = new EasyGopigo3();
4 | const calibrator = gpg.calibrateLineFollower();
5 |
6 | console.log('Calibration...');
7 | calibrator.calibrate();
8 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/EasyMotors.js:
--------------------------------------------------------------------------------
1 | const sleep = require('sleep');
2 | const EasyGopigo3 = require('../lib/easyGopigo3');
3 |
4 | const gpg = new EasyGopigo3();
5 |
6 | console.log('Press any key to exit');
7 |
8 | process.stdin.setRawMode(true);
9 | process.stdin.resume();
10 | process.stdin.on('data', () => {
11 | gpg.stop();
12 | gpg.resetAll();
13 | process.exit(0);
14 | });
15 |
16 | console.log('Move the motors forward freely for 1 second.');
17 | gpg.forward();
18 | sleep.sleep(1);
19 |
20 | console.log('Stop the motors for 1 second.');
21 | gpg.stop();
22 | sleep.sleep(1);
23 |
24 | console.log('Drive the motors 50 cm and then stop.');
25 | gpg.driveCm(50, () => {
26 | console.log('Wait 1 second.');
27 | sleep.sleep(1);
28 |
29 | console.log('Turn right 1 second.');
30 | gpg.right();
31 | sleep.sleep(1);
32 |
33 | console.log('Turn left 1 second.');
34 | gpg.left();
35 | sleep.sleep(1);
36 |
37 | console.log('Stop!');
38 | gpg.stop();
39 |
40 | console.log('Done!');
41 | });
42 |
43 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/Grove.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * https://www.dexterindustries.com/GoPiGo/
4 | * https://github.com/DexterInd/GoPiGo3
5 | *
6 | * Copyright (c) 2017 Dexter Industries
7 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | *
10 | * This code is an example for demonstrating grove devices with the GoPiGo3.
11 | *
12 | * Hardware: Connect a grove buzzer to port AD1, and a grove potentiometer to port AD2.
13 | *
14 | * Results: When you run this program, the position of the potentiometer will determine the tone of the buzzer.
15 | *
16 | */
17 |
18 | const Gopigo3 = require('../lib/gopigo3');
19 | const sleep = require('sleep');
20 |
21 | const gpg = new Gopigo3();
22 |
23 | gpg.setGroveType(Gopigo3.GROVE_1, Gopigo3.GROVE_TYPE_CUSTOM);
24 | gpg.setGroveType(Gopigo3.GROVE_2, Gopigo3.GROVE_TYPE_CUSTOM);
25 |
26 | gpg.setGroveMode(Gopigo3.GROVE_1_1, Gopigo3.GROVE_OUTPUT_PWM);
27 | gpg.setGroveMode(Gopigo3.GROVE_2, Gopigo3.GROVE_INPUT_ANALOG);
28 |
29 | let duty = 10;
30 | // let freq = 0;
31 |
32 | const interval = setInterval(() => {
33 | duty++;
34 | if (duty > 90) {
35 | duty = 10;
36 | }
37 | gpg.setGrovePwmDuty(Gopigo3.GROVE_1_1, duty);
38 | gpg.setGrovePwmFrequency(Gopigo3.GROVE_1, gpg.getGroveAnalog(Gopigo3.GROVE_2_1));
39 | }, 100);
40 |
41 | console.log('Press any key to exit');
42 |
43 | process.stdin.setRawMode(true);
44 | process.stdin.resume();
45 | process.stdin.on('data', () => {
46 | clearInterval(interval);
47 | gpg.resetAll();
48 | process.exit(0);
49 | });
50 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/GroveBuzzer.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * https://www.dexterindustries.com/GoPiGo/
4 | * https://github.com/DexterInd/GoPiGo3
5 | *
6 | * Copyright (c) 2017 Dexter Industries
7 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | *
10 | * This code is an example for using the grove buzzer with the GoPiGo3.
11 | *
12 | * Hardware: Connect a grove buzzer to AD1 port.
13 | *
14 | * Results: When you run this program, the buzzer should repeat the scale of middle C through tenor C.
15 | *
16 | */
17 |
18 | const Gopigo3 = require('../lib/gopigo3');
19 | const sleep = require('sleep');
20 |
21 | const gpg = new Gopigo3();
22 | const scale = [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25];
23 |
24 | gpg.setGroveType(Gopigo3.GROVE_1, Gopigo3.GROVE_TYPE.CUSTOM);
25 | gpg.setGroveMode(Gopigo3.GROVE_1_1, Gopigo3.GROVE_OUTPUT_PWM);
26 | gpg.setGrovePwmDuty(Gopigo3.GROVE_1_1, 50);
27 |
28 | let note = 0;
29 | const interval = setInterval(() => {
30 | gpg.setGrovePwmFrequency(Gopigo3.GROVE_1, scale[note]);
31 | note++;
32 | if (note >= scale.length) {
33 | note = 0;
34 | }
35 | }, 500);
36 |
37 | console.log('Press any key to exit');
38 |
39 | process.stdin.setRawMode(true);
40 | process.stdin.resume();
41 | process.stdin.on('data', () => {
42 | clearInterval(interval);
43 | gpg.resetAll();
44 | process.exit(0);
45 | });
46 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/Grove_I2C.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * https://www.dexterindustries.com/GoPiGo/
4 | * https://github.com/DexterInd/GoPiGo3
5 | *
6 | * Copyright (c) 2017 Dexter Industries
7 | * Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | * For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | *
10 | * This code is an example for using the GoPiGo3 software I2C busses.
11 | *
12 | * Hardware: Connect an I2C device to port AD1.
13 | *
14 | */
15 |
16 | const Gopigo3 = require('../lib/gopigo3');
17 | const sleep = require('sleep');
18 |
19 | const gpg = new Gopigo3();
20 | const I2CSlaveAddress = 0x24;
21 |
22 | console.log('Press any key to exit');
23 |
24 | process.stdin.setRawMode(true);
25 | process.stdin.resume();
26 | process.stdin.on('data', () => {
27 | gpg.resetAll();
28 | process.exit(0);
29 | });
30 |
31 | gpg.setGroveType(Gopigo3.GROVE_1, Gopigo3.GROVE_TYPE.I2C);
32 | let i = 0;
33 |
34 | while (true) {
35 | gpg.groveI2cTransfer(Gopigo3.GROVE_1, I2CSlaveAddress, [i]); // write one byte
36 | console.log(i, gpg.groveI2cTransfer(Gopigo3.GROVE_1, I2CSlaveAddress, [], 16)); // read sixteen bytes
37 |
38 | sleep.msleep(100);
39 |
40 | i++;
41 | if (i > 15) {
42 | i = 0;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/custom/buzzer.js:
--------------------------------------------------------------------------------
1 | const EasyGopigo3 = require('../../lib/easyGopigo3');
2 | const sleep = require('sleep');
3 |
4 | const gpg = new EasyGopigo3();
5 | const sensor = gpg.initBuzzer('AD2');
6 |
7 | console.log('🔊');
8 | sensor.soundOn();
9 | sleep.sleep(2);
10 | sensor.soundOff();
11 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/custom/dht.js:
--------------------------------------------------------------------------------
1 | const EasyGopigo3 = require('../../lib/easyGopigo3');
2 |
3 | const gpg = new EasyGopigo3();
4 | const sensor = gpg.initDhtSensor('SERIAL', 11);
5 |
6 | console.log('DHT values', sensor.readDht());
7 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/custom/easyLed.js:
--------------------------------------------------------------------------------
1 | const sleep = require('sleep');
2 | const EasyGopigo3 = require('../../lib/easyGopigo3');
3 |
4 | const gpg = new EasyGopigo3();
5 | const myLed = gpg.initLed('AD1');
6 |
7 | for (let i = 0, len = 100; i < len; i++) {
8 | myLed.lightMax();
9 | sleep.msleep(500);
10 |
11 | myLed.lightOn(30);
12 | sleep.msleep(500);
13 |
14 | myLed.lightOff();
15 | sleep.msleep(500);
16 | }
17 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/custom/readInfo.js:
--------------------------------------------------------------------------------
1 | const Gopigo3 = require('../../lib/gopigo3');
2 |
3 | const gpg = new Gopigo3();
4 |
5 | try {
6 | console.log('Manufacturer :', gpg.getManufacturer());
7 | console.log('Board :', gpg.getBoard());
8 | console.log('Serial Number :', gpg.getId());
9 | console.log('Hardware Version :', gpg.getVersionHardware());
10 | console.log('Firmware Version :', gpg.getVersionFirmware());
11 | console.log('Battery Voltage :', gpg.getVoltageBattery());
12 | console.log('5v Voltage :', gpg.getVoltage5v());
13 | } catch (err) {
14 | console.log(err);
15 | }
16 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/custom/salut.js:
--------------------------------------------------------------------------------
1 | const sleep = require('sleep');
2 | const EasyGopigo3 = require('../../lib/easyGopigo3');
3 |
4 | const gpg = new EasyGopigo3();
5 | const myServo = gpg.initServo('SERVO2');
6 |
7 | gpg.openLeftEye();
8 | gpg.openRightEye();
9 |
10 | myServo.rotateServo(10);
11 |
12 | /*
13 | for (let i = 90, len = 180; i < len; i++) {
14 | myServo.rotateServo(i);
15 | sleep.msleep(50);
16 | }
17 | */
18 |
19 | sleep.sleep(5);
20 |
21 | gpg.closeLeftEye();
22 | gpg.closeRightEye();
23 | myServo.resetServo();
24 |
--------------------------------------------------------------------------------
/Software/NodeJS/examples/custom/ultrasonic.js:
--------------------------------------------------------------------------------
1 | const sleep = require('sleep');
2 | const EasyGopigo3 = require('../../lib/easyGopigo3');
3 |
4 | const gpg = new EasyGopigo3();
5 | const sensor = gpg.initUltrasonicSensor('AD1');
6 |
7 | console.log(sensor.read(), sensor.readMm(), sensor.readInches());
8 | console.log('Is too close', sensor.isTooClose());
9 |
--------------------------------------------------------------------------------
/Software/NodeJS/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # - Install NPM / NodeJS / NVM for the current user
4 |
5 | function realpath()
6 | {
7 | f=$@
8 | if [ -d "$f" ]; then
9 | base=""
10 | dir="$f"
11 | else
12 | base="/$(basename "$f")"
13 | dir=$(dirname "$f")
14 | fi
15 | dir=$(cd "$dir" && /bin/pwd)
16 | echo "$dir$base"
17 | }
18 |
19 | if [ "$(id -u)" == "0" ]; then
20 | echo "This script cannot be run as sudo" 1>&2
21 | exit 1
22 | fi
23 |
24 | read -p "This operation will install NPM, Node.js and NVM for the current user profile, do you want to proceed? [Y,N] " answer
25 | if [[ $answer = [Yy] ]] ; then
26 |
27 | # Installing NVM
28 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
29 |
30 | export NVM_DIR="$HOME/.nvm"
31 | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
32 | [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
33 |
34 | # Installing Node.js
35 | nvm install 8.5.0
36 |
37 | # Validating installation
38 | echo "❤ Node.js version"
39 | node --version
40 | echo "❤ NPM version"
41 | npm --version
42 |
43 | echo
44 | echo
45 | echo "Done, you can now use Node.js on your device."
46 | echo "If you need to build the current library run 'npm install' inside the NodeJS folder"
47 | echo "otherwise you can already start using it including the npm package (node-gopigo3) in your application."
48 | echo
49 | echo "For any other hint please check the repository."
50 | echo "Bye!"
51 | echo
52 | echo
53 |
54 | bash -l
55 | fi
--------------------------------------------------------------------------------
/Software/NodeJS/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "node-gopigo3",
3 | "version": "0.0.3",
4 | "description": "GoPiGo3 library for Node.js",
5 | "scripts": {
6 | "clean": "rimraf lib",
7 | "test": "cross-env BABEL_ENV=commonjs mocha --compilers js:babel-register --recursive",
8 | "test:watch": "npm test -- --watch",
9 | "test:examples": "node examples/",
10 | "cover": "cross-env BABEL_ENV=commonjs istanbul cover _mocha -- --compilers js:babel-register --recursive",
11 | "lint": "eslint src test",
12 | "build": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
13 | "prepublish": "npm run-script clean && npm run-script lint && npm run-script build && npm run-script test"
14 | },
15 | "main": "lib/index.js",
16 | "files": [
17 | "lib",
18 | "src"
19 | ],
20 | "repository": {
21 | "type": "git",
22 | "url": "git+https://github.com/marcellobarile/GoPiGo3.git"
23 | },
24 | "keywords": [
25 | "learning",
26 | "education",
27 | "IoT",
28 | "Internet of Things",
29 | "prototyping",
30 | "dexter industries",
31 | "grovepi",
32 | "grovepi+",
33 | "gopigo",
34 | "gopigo3",
35 | "robot",
36 | "robotic",
37 | "gpio",
38 | "spi",
39 | "i2c"
40 | ],
41 | "author": "Marcello Barile (http://www.barile.eu)",
42 | "license": "MIT",
43 | "bugs": {
44 | "url": "https://github.com/marcellobarile/GoPiGo3/issues"
45 | },
46 | "homepage": "https://github.com/marcellobarile/GoPiGo3#readme",
47 | "devDependencies": {
48 | "babel": "^6.5.2",
49 | "babel-cli": "^6.14.0",
50 | "babel-eslint": "^7.0.0",
51 | "babel-plugin-add-module-exports": "^0.2.1",
52 | "babel-plugin-transform-class-properties": "^6.24.1",
53 | "babel-preset-es2015": "^6.14.0",
54 | "babel-preset-stage-2": "^6.13.0",
55 | "chai": "^3.5.0",
56 | "cross-env": "^3.0.0",
57 | "eslint": ">=4.18.2",
58 | "eslint-config-airbnb": "^13.0.0",
59 | "eslint-plugin-import": "^2.0.0",
60 | "eslint-plugin-jsx-a11y": "^2.2.2",
61 | "eslint-plugin-react": "^6.3.0",
62 | "istanbul": "^1.0.0-alpha",
63 | "mocha": "^3.0.2",
64 | "rimraf": "^2.5.4"
65 | },
66 | "dependencies": {
67 | "i2c-bus": "^1.2.2",
68 | "lockfile": "^1.0.3",
69 | "lodash": "^4.17.4",
70 | "mathjs": ">=7.5.1",
71 | "readline-sync": "^1.4.7",
72 | "sleep": "^5.1.1",
73 | "spi-device": "^0.2.6",
74 | "di-sensors": "^0.0.2"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/analogSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const sleep = require('sleep');
10 | const Sensor = require('./sensor');
11 |
12 | class AnalogSensor extends Sensor {
13 |
14 | constructor(port, pinMode, gpg) {
15 | console.log('AnalogSensor init');
16 |
17 | super(port, pinMode, gpg);
18 |
19 | this.value = 0;
20 | this.freq = 24000;
21 | this.maxValue = 4096;
22 |
23 | // select the outwards pin of the grove connector
24 | this.setPin(1);
25 |
26 | // this delay is at least needed by the Light sensor
27 | // TODO: Why don't move it in the light sensor class then?
28 | sleep.msleep(1000);
29 | }
30 |
31 | /**
32 | * Read an analog value from a sensor.
33 | * Will make up to two attempts to get a valid value
34 | * If it succeeds, the valid value is returned
35 | * Otherwise it prints an error statement and returns 0
36 | */
37 | read() {
38 | const getValue = () => this.gpg.getGroveAnalog(this.getPin());
39 |
40 | try {
41 | this.value = getValue();
42 | } catch (err) {
43 | console.log(err);
44 | try {
45 | this.value = getValue();
46 | } catch (err2) {
47 | console.log(err2);
48 | return 0;
49 | }
50 | }
51 |
52 | return this.value;
53 | }
54 |
55 | /**
56 | * Brings the sensor read to a percent scale
57 | */
58 | percentRead() {
59 | let percent = Math.round(this.read() * 100 / this.maxValue);
60 |
61 | if (percent > 100) {
62 | percent = 100;
63 | }
64 |
65 | return percent;
66 | }
67 |
68 | /**
69 | * TODO: Missing documentation
70 | * @param {*} power
71 | */
72 | write(power) {
73 | this.value = power;
74 | return this.gpg.setGrovePwmDuty(this.getPin(), power);
75 | }
76 |
77 | /**
78 | * TODO: Missing documentation
79 | * @param {*} freq
80 | */
81 | writeFreq(freq) {
82 | this.freq = freq;
83 | const output = this.gpg.setGrovePwmFrequency(this.getPortId(), this.freq);
84 | console.log('Analog write on %s at %s', this.getPortId(), this.freq);
85 | return output;
86 | }
87 | }
88 |
89 | module.exports = AnalogSensor;
90 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/buttonSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const DigitalSensor = require('./digitalSensor');
10 |
11 | class ButtonSensor extends DigitalSensor {
12 | constructor(port = 'AD1', gpg = null) {
13 | console.log('ButtonSensor init');
14 | super(port, 'DIGITAL_INPUT', gpg);
15 | this.setDescriptor('Button sensor');
16 | }
17 |
18 | /**
19 | *
20 | */
21 | isButtonPressed() {
22 | return this.read() === 1;
23 | }
24 | }
25 |
26 | module.exports = ButtonSensor;
27 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/dhtSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const DHT = require('di-sensors').DHT;
10 | const utils = require('../utils/misc');
11 |
12 | class DHTSensor {
13 | constructor(port, sensorType = 0, gpg) {
14 | this.gpg = gpg;
15 | const scale = 'c';
16 | this.dhtSensor = new DHT(sensorType, scale);
17 | }
18 |
19 | /**
20 | * Return values may be a float, or error strings
21 | TODO: raise errors instead of returning strings
22 | import done internally so it's done on a as needed basis only
23 | */
24 | readTemperature() {
25 | const temp = this.readDht()[0];
26 | return temp;
27 | }
28 |
29 | /**
30 | * Return values may be a float, or error strings
31 | TODO: raise errors instead of returning strings
32 | */
33 | readHumidity() {
34 | const humidity = this.readDht()[1];
35 | return humidity;
36 | }
37 |
38 | /**
39 | *
40 | */
41 | readDht() {
42 | utils.grabI2CRead();
43 | const data = this.dhtSensor.read();
44 | utils.releaseI2CRead();
45 | return data;
46 | }
47 | }
48 |
49 | module.exports = DHTSensor;
50 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/digitalSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const Sensor = require('./sensor');
10 |
11 | class DigitalSensor extends Sensor {
12 |
13 | constructor(port, pinMode, gpg) {
14 | console.log('DigitalSensor init');
15 | super(port, pinMode, gpg);
16 | this.setPin(1);
17 | }
18 |
19 | /**
20 | * Return values:
21 | * 0 or 1 are valid values
22 | * -1 may occur when there's a reading error
23 |
24 | * On a reading error, a second attempt will be made before
25 | * returning a -1 value
26 | */
27 | read() {
28 | const getValue = () => this.gpg.getGroveState(this.getPin());
29 |
30 | try {
31 | this.value = getValue();
32 | } catch (err) {
33 | console.log(err);
34 | try {
35 | this.value = getValue();
36 | } catch (err2) {
37 | console.log(err2);
38 | throw new Error(err2);
39 | }
40 | }
41 |
42 | return this.value;
43 | }
44 |
45 | /**
46 | * TODO: Missing documentation
47 | * @param {*} power
48 | */
49 | write(power) {
50 | this.power = power;
51 | // TODO: Not ported to GPG3 yet
52 | return 1;
53 | }
54 | }
55 |
56 | module.exports = DigitalSensor;
57 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/led.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const AnalogSensor = require('./analogSensor');
10 |
11 | class Led extends AnalogSensor {
12 | /**
13 | *
14 | */
15 | constructor(port = 'AD1', gpg = null) {
16 | console.log('Led init');
17 |
18 | try {
19 | super(port, 'OUTPUT', gpg);
20 | this.setDescriptor('LED');
21 | } catch (err) {
22 | console.log(err);
23 | throw new Error(err);
24 | }
25 | }
26 |
27 | /**
28 | *
29 | * @param {*} power
30 | */
31 | lightOn(power) {
32 | this.write(power);
33 | }
34 |
35 | /**
36 | *
37 | */
38 | lightMax() {
39 | this.lightOn(100);
40 | }
41 |
42 | /**
43 | *
44 | */
45 | lightOff() {
46 | this.write(0);
47 | }
48 |
49 | /**
50 | *
51 | */
52 | isOn() {
53 | return this.value > 0;
54 | }
55 |
56 | /**
57 | *
58 | */
59 | isOff() {
60 | return this.value === 0;
61 | }
62 | }
63 |
64 | module.exports = Led;
65 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/lightSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const AnalogSensor = require('./analogSensor');
10 |
11 | class LightSensor extends AnalogSensor {
12 | /**
13 | * Creates a light sensor from which we can read.
14 | * Light sensor is by default on pin A1(A-one)
15 | * self.pin takes a value of 0 when on analog pin (default value)
16 | * takes a value of 1 when on digital pin
17 | */
18 | constructor(port = 'AD1', gpg = null) {
19 | console.log('LightSensor init');
20 | super(port, 'INPUT', gpg);
21 | this.setDescriptor('Light sensor');
22 | }
23 | }
24 |
25 | module.exports = LightSensor;
26 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/lineFollower/blackLine.txt:
--------------------------------------------------------------------------------
1 | (I987
2 | I1010
3 | I1004
4 | I996
5 | I986
6 | tp0
7 | .
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/lineFollower/lineThresholdSet.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const readlineSync = require('readline-sync');
10 | const LineSensor = require('./lineFollow');
11 |
12 | class LineThresholdSet {
13 | lineSensor;
14 |
15 | constructor() {
16 | console.log('LineThresholdSet init');
17 | }
18 |
19 | calibrate() {
20 | this.lineSensor = new LineSensor();
21 | this.whiteLineSetup();
22 | this.blackLineSetup();
23 | }
24 |
25 | getSensorVal() {
26 | let val;
27 | while (true) {
28 | val = this.lineSensor.readSensor();
29 | if (val[0] !== -1) {
30 | return val;
31 | }
32 | }
33 | }
34 |
35 | whiteLineSetup() {
36 | this.lineSensor.resetBuffer();
37 |
38 | console.log('WHITE LINE SETUP');
39 | readlineSync.question('Keep all the sensors over a white strip and press ENTER');
40 | console.log('--> Line sensor readings:');
41 | console.log(this.getSensorVal());
42 | const save = readlineSync.keyInYN('If the reading look good, press \'y\' and ENTER to continue, any other key to read again');
43 | if (save) {
44 | this.lineSensor.setWhiteLine();
45 | }
46 | console.log('Current White Line values:', this.lineSensor.getWhiteLine());
47 | }
48 |
49 | blackLineSetup() {
50 | this.lineSensor.resetBuffer();
51 |
52 | console.log('BLACK LINE SETUP');
53 | readlineSync.question('Keep all the sensors over a black strip and press ENTER');
54 | console.log('--> Line sensor readings:');
55 | console.log(this.getSensorVal());
56 | const save = readlineSync.keyInYN('If the reading look good, press \'y\' and ENTER to continue, any other key to read again');
57 | if (save) {
58 | this.lineSensor.setBlackLine();
59 | }
60 | console.log('Current Black Line values:', this.lineSensor.getBlackLine());
61 | }
62 | }
63 |
64 | module.exports = LineThresholdSet;
65 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/lineFollower/rangeLine.txt:
--------------------------------------------------------------------------------
1 | (lp0
2 | I698
3 | aI654
4 | aI572
5 | aI937
6 | aI938
7 | a.
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/lineFollower/whiteLine.txt:
--------------------------------------------------------------------------------
1 | (I289
2 | I356
3 | I432
4 | I59
5 | I48
6 | tp0
7 | .
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/loudnessSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const AnalogSensor = require('./analogSensor');
10 |
11 | class LoudnessSensor extends AnalogSensor {
12 | constructor(port = 'AD1', gpg = null) {
13 | console.log('LoudnessSensor init');
14 | super(port, 'INPUT', gpg);
15 | this.setDescriptor('Loudness sensor');
16 | this.maxValue = 1024; // based on empirical tests
17 | }
18 | }
19 |
20 | module.exports = LoudnessSensor;
21 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/motionSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const DigitalSensor = require('./digitalSensor');
10 |
11 | class MotionSensor extends DigitalSensor {
12 | constructor(port = 'AD1', gpg = null) {
13 | console.log('MotionSensor init');
14 | super(port, 'DIGITAL_INPUT', gpg);
15 | this.setDescriptor('Motion sensor');
16 | }
17 |
18 | motionDetected() {
19 | return this.read() === 1;
20 | }
21 | }
22 |
23 | module.exports = MotionSensor;
24 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/remote.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const Sensor = require('./sensor');
10 |
11 | class Remote extends Sensor {
12 | /**
13 | * Creates a remote sensor
14 | */
15 |
16 | keycodes = ['up', 'left', 'ok', 'right', 'down', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '0', '#'];
17 |
18 | constructor(port = 'AD1', gpg = null) {
19 | console.log('Remote init');
20 | super(port, 'IR', gpg);
21 | this.setDescriptor('Remote Control');
22 | }
23 |
24 | read() {
25 | let value;
26 |
27 | try {
28 | value = this.gpg.getGroveValue(this.getPortId());
29 | } catch (err) {
30 | console.log(err);
31 | value = -1;
32 | }
33 |
34 | return value;
35 | }
36 |
37 | getRemoteCode() {
38 | let string = '';
39 | const key = this.read();
40 |
41 | if (key > 0 && key < this.keycodes.length + 1) {
42 | string = this.keycodes[key - 1];
43 | }
44 |
45 | return string;
46 | }
47 | }
48 |
49 | module.exports = Remote;
50 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/servo.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const ValueError = require('../errors/valueError');
10 |
11 | const Sensor = require('./sensor');
12 |
13 | /**
14 | * Wrapper to control the Servo Motors on the GPG3.
15 | Allows you to rotate the servo by feeding in the angle of rotation.
16 | Connect the Servo to the Servo1 and Servo2 ports of GPG3.
17 | */
18 | class Servo extends Sensor {
19 | static PULSE_WIDTH_RANGE = 1850;
20 | // Pulse width range in us corresponding to 0 to 180 degrees
21 |
22 | constructor(port = 'SERVO1', gpg) {
23 | try {
24 | super(port, 'OUTPUT', gpg);
25 | this.setDescriptor('GoPiGo3 Servo');
26 | } catch (err) {
27 | throw new ValueError('GoPiGo3 Servo not found');
28 | }
29 | }
30 |
31 | /**
32 | * This calculation will vary with servo and is an approximate angular movement of the servo
33 | Pulse Width varies between 575us to 24250us for a 60KHz Servo Motor which
34 | rotates between 0 to 180 degrees.
35 |
36 | 0 degree ~= 575us
37 | 180 degree ~= 2425us
38 | Pulse width Range= 2425-575 =1850
39 | => 1 degree rotation requires ~= 10.27us
40 | * @param {*} servoPosition
41 | */
42 | rotateServo(servoPosition) {
43 | servoPosition = servoPosition > 180 ? 180 : servoPosition;
44 | servoPosition = servoPosition < 0 ? 0 : servoPosition;
45 |
46 | const pulseWidth = Math.round(
47 | (1500 - (Servo.PULSE_WIDTH_RANGE / 2)) +
48 | ((Servo.PULSE_WIDTH_RANGE / 180) * servoPosition)
49 | );
50 | this.gpg.setServo(this.getPortId(), parseInt(pulseWidth, 0));
51 | }
52 |
53 | /**
54 | *
55 | */
56 | resetServo() {
57 | this.gpg.setServo(this.getPortId(), 0);
58 | }
59 |
60 | }
61 |
62 | module.exports = Servo;
63 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/components/soundSensor.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const AnalogSensor = require('./analogSensor');
10 |
11 | class SoundSensor extends AnalogSensor {
12 | /**
13 | * Creates a sound sensor
14 | */
15 | constructor(port = 'AD1', gpg = null) {
16 | console.log('SoundSensor init');
17 | super(port, 'INPUT', gpg);
18 | this.setDescriptor('Sound sensor');
19 | }
20 | }
21 |
22 | module.exports = SoundSensor;
23 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/errors/firmwareVersionError.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | // Exception raised if the GoPiGo3 firmware needs to be updated
10 | module.exports = class FirmwareVersionError extends Error {};
11 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/errors/i2cError.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | // Exception raised if there was an error on an I2C bus
10 | module.exports = class I2cError extends Error {};
11 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/errors/sensorError.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | // Exception raised if a sensor is not yet configured when trying to read it
10 | module.exports = class SensorError extends Error {};
11 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/errors/valueError.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | // Exception raised if trying to read an invalid value
10 | module.exports = class ValueError extends Error {};
11 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/index.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/DI_Sensors
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 |
8 | const Gopigo3 = require('./gopigo3');
9 | const EasyGopigo3 = require('./easyGopigo3');
10 |
11 | module.exports = {
12 | 'Gopigo3': Gopigo3,
13 | 'EasyGopigo3': EasyGopigo3
14 | };
15 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/utils/enumeration.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const _ = require('lodash');
10 |
11 | class Enumeration {
12 | constructor(names) {
13 | const lines = names.split('\n');
14 | let number = 0;
15 |
16 | _.each(lines, (line) => {
17 | if (line.indexOf(',') >= 0) {
18 | // strip out the spaces + commas
19 | line = line.replace(/\s\s+/g, '').replace(',', '');
20 |
21 | if (line.indexOf('=') !== -1) {
22 | const slices = line.split('=');
23 | number = parseInt(slices[1], 0);
24 | line = slices[0];
25 | }
26 |
27 | this[line] = number;
28 | number++;
29 | }
30 | });
31 | }
32 | }
33 |
34 | module.exports = Enumeration;
35 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/utils/i2cMutex.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const Lock = require('lockfile');
10 | const sleep = require('sleep');
11 |
12 | class I2cMutex {
13 | isAcquired = false;
14 | lockFile = '/run/lock/DexterLockI2C';
15 |
16 | I2CMutexAcquire() {
17 | const _this = this;
18 |
19 | while (this.isAcquired) {
20 | sleep.msleep(1);
21 | }
22 |
23 | this.isAcquired = false;
24 |
25 | while (!this.isAcquired) {
26 | Lock.lockSync(this.lockFile);
27 | _this.isAcquired = true;
28 | }
29 |
30 | return this.isAcquired;
31 | }
32 |
33 | I2CMutexRelease() {
34 | const _this = this;
35 |
36 | Lock.unlock(this.lockFile, (err) => {
37 | if (err) {
38 | throw err;
39 | }
40 | // unlocked
41 | _this.isAcquired = false;
42 | sleep.msleep(1);
43 | });
44 | }
45 | }
46 |
47 | module.exports = I2cMutex;
48 |
--------------------------------------------------------------------------------
/Software/NodeJS/src/utils/misc.js:
--------------------------------------------------------------------------------
1 | // https://www.dexterindustries.com/GoPiGo/
2 | // https://github.com/DexterInd/GoPiGo3
3 | //
4 | // Copyright (c) 2017 Dexter Industries
5 | // Released under the MIT license (http://choosealicense.com/licenses/mit/).
6 | // For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
7 | //
8 |
9 | const I2CMutex = require('./i2cMutex');
10 |
11 | const i2cMutex = new I2CMutex();
12 |
13 | module.exports = {
14 | twoDigitHex: (c) => {
15 | const hex = c.toString(16);
16 | return hex.length === 1 ? `0${hex}` : hex;
17 | },
18 |
19 | grabI2CRead: () => i2cMutex.I2CMutexAcquire(),
20 | releaseI2CRead: () => i2cMutex.I2CMutexRelease()
21 | };
22 |
--------------------------------------------------------------------------------
/Software/NodeJS/test/index.js:
--------------------------------------------------------------------------------
1 | import { assert } from 'chai';
2 | const EasyGopigo3 = require('../lib/easyGopigo3');
3 | const gpg = new EasyGopigo3();
4 |
5 | /*
6 | describe('GoPiGo test.', () => {
7 | it('should test GoPiGo manufacturer', () => {
8 | assert(gpg.getManufacturer() === '', 'Empty manufacturer');
9 | });
10 | });
11 | */
--------------------------------------------------------------------------------
/Software/NodeJS/uninstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Remove NPM / NodeJS / NVM from the current user
4 | #
5 |
6 | read -p "This operation will remove NPM, Node.js and NVM from your user profile, are you sure? [Y/N] " answer
7 | if [[ $answer = [Yy] ]] ; then
8 | echo "Executing..."
9 | rm -rf $NVM_DIR ~/.npm ~/.bower && unset NVM_DIR && source ~/.bashrc
10 | echo "Done."
11 |
12 | bash -l
13 | fi
--------------------------------------------------------------------------------
/Software/Python/Examples/Calibration_Panel/drive-config-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Python/Examples/Calibration_Panel/drive-config-icon.png
--------------------------------------------------------------------------------
/Software/Python/Examples/Calibration_Panel/gopigo3_calibration.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Encoding=UTF-8
3 | Type=Application
4 | Name=GoPiGo3 Calibration Panel
5 | Comment=GoPiGo3 Calibration Panel
6 | Icon=/home/pi/Dexter/GoPiGo3/Software/Python/Examples/Calibration_Panel/drive-config-icon.png
7 | Exec=/usr/bin/python3 /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Calibration_Panel/calibration_panel_gui.py
8 | NoDisplay=true
--------------------------------------------------------------------------------
/Software/Python/Examples/Control_Panel/GoPiGo3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Python/Examples/Control_Panel/GoPiGo3.png
--------------------------------------------------------------------------------
/Software/Python/Examples/Control_Panel/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Python/Examples/Control_Panel/__init__.py
--------------------------------------------------------------------------------
/Software/Python/Examples/Control_Panel/dex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Python/Examples/Control_Panel/dex.png
--------------------------------------------------------------------------------
/Software/Python/Examples/Control_Panel/gopigo3_control_panel.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Encoding=UTF-8
3 | Type=Application
4 | Name=GoPiGo3 Control Panel
5 | Comment=GoPiGo3 Control Panel
6 | #Icon=/usr/share/icons/gnome/scalable/devices/input-gaming-symbolic.svg
7 | Icon=/home/pi/Dexter/GoPiGo3/Software/Python/Examples/Control_Panel/GoPiGo3.png
8 | Exec=python2 /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Control_Panel/control_panel_gui_3.py
9 | NoDisplay=true
10 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for demonstrating grove devices with the GoPiGo3.
11 | #
12 | # Hardware: Connect a grove buzzer to port AD1, and a grove potentiometer to port AD2.
13 | #
14 | # Results: When you run this program, the position of the potentiometer will determine the tone of the buzzer.
15 |
16 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
17 | from __future__ import division # ''
18 |
19 | import time # import the time library for the sleep function
20 | import gopigo3 # import the GoPiGo3 drivers
21 |
22 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
23 |
24 | try:
25 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.CUSTOM)
26 | GPG.set_grove_type(GPG.GROVE_2, GPG.GROVE_TYPE.CUSTOM)
27 |
28 | GPG.set_grove_mode(GPG.GROVE_1_1, GPG.GROVE_OUTPUT_PWM)
29 | GPG.set_grove_mode(GPG.GROVE_2, GPG.GROVE_INPUT_ANALOG)
30 |
31 | duty = 10
32 | #freq = 0
33 | while(True):
34 | try:
35 | print("Battery: %6.3fv 5v: %5.3fv State: %d Voltage: %4.2fv ADC: %4d" % (GPG.get_voltage_battery(), GPG.get_voltage_5v(), GPG.get_grove_state(GPG.GROVE_2_1), GPG.get_grove_voltage(GPG.GROVE_2_1), GPG.get_grove_analog(GPG.GROVE_2_1)))
36 | duty = duty + 1
37 | if duty > 90:
38 | duty = 10
39 | GPG.set_grove_pwm_duty(GPG.GROVE_1_1, duty)
40 |
41 | GPG.set_grove_pwm_frequency(GPG.GROVE_1, GPG.get_grove_analog(GPG.GROVE_2_1))
42 | time.sleep(0.1)
43 | except gopigo3.ValueError as error:
44 | pass
45 |
46 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
47 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
48 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_Buzzer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for using the grove buzzer with the GoPiGo3.
11 | #
12 | # Hardware: Connect a grove buzzer to AD1 port.
13 | #
14 | # Results: When you run this program, the buzzer should repeat the scale of middle C through tenor C.
15 |
16 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
17 | from __future__ import division # ''
18 |
19 | import time # import the time library for the sleep function
20 | import gopigo3 # import the GoPiGo3 drivers
21 |
22 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
23 |
24 | scale = [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25]
25 |
26 | try:
27 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.CUSTOM) # set AD1 as custom
28 | GPG.set_grove_mode(GPG.GROVE_1_1, GPG.GROVE_OUTPUT_PWM) # enable PWM output on AD1 pin 1
29 |
30 | GPG.set_grove_pwm_duty(GPG.GROVE_1_1, 50) # set the duty cycle to 50%. 10-90 should work, and changing it will effect the sound.
31 |
32 | note = 0
33 | while(True):
34 | GPG.set_grove_pwm_frequency(GPG.GROVE_1, scale[note]) # set the frequency.
35 | note += 1
36 | if note >= 8:
37 | note = 0
38 | time.sleep(0.5)
39 |
40 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
41 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
42 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_I2C.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for using the GoPiGo3 software I2C busses.
11 | #
12 | # Hardware: Connect an I2C device to port AD1.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | I2C_Slave_Address = 0x24 # the address of the I2C slave
23 |
24 | try:
25 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.I2C)
26 | i = 0
27 | while(True):
28 | GPG.grove_i2c_transfer(GPG.GROVE_1, I2C_Slave_Address, [i]) # write one byte
29 | #print(GPG.grove_i2c_transfer(GPG.GROVE_1, I2C_Slave_Address, [0, 1, 0, 1], 1)) # write four bytes and read one byte
30 | print(i, GPG.grove_i2c_transfer(GPG.GROVE_1, I2C_Slave_Address, [], 16)) # read sixteen bytes
31 |
32 | time.sleep(0.1)
33 |
34 | i += 1
35 | if i > 15:
36 | i = 0
37 |
38 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
39 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
40 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_IR.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for using the GoPiGo3 with the IR Receiver and Go Box remote.
11 | #
12 | # Hardware: Connect a grove IR receiver to port AD1.
13 | #
14 | # Results: When you run this program, a value will be printed that corresponds to the button being pressed on the remote.
15 |
16 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
17 | from __future__ import division # ''
18 |
19 | import time # import the time library for the sleep function
20 | import gopigo3 # import the GoPiGo3 drivers
21 |
22 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
23 |
24 | try:
25 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.IR_DI_REMOTE)
26 |
27 | while(True):
28 | try:
29 | print(GPG.get_grove_value(GPG.GROVE_1))
30 | except gopigo3.SensorError as error:
31 | print(error)
32 | time.sleep(0.05)
33 |
34 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
35 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
36 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_LED.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for using a grove LED with GoPiGo3.
11 | #
12 | # Hardware: Connect a grove LED to port AD2 of the GoPiGo3.
13 | #
14 | # Results: When you run this program, the grove LED should turn on for two seconds.
15 |
16 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
17 | from __future__ import division # ''
18 |
19 | import time # import the time library for the sleep function
20 | import gopigo3 # import the GoPiGo3 drivers
21 |
22 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
23 |
24 | try:
25 | GPG.set_grove_type(GPG.GROVE_2, GPG.GROVE_TYPE.CUSTOM)
26 | GPG.set_grove_mode(GPG.GROVE_2_1, GPG.GROVE_OUTPUT_DIGITAL)
27 | GPG.set_grove_state(GPG.GROVE_2_1, True)
28 | #GPG.set_grove_mode(GPG.GROVE_2_1, GPG.GROVE_OUTPUT_PWM)
29 | #GPG.set_grove_pwm_duty(GPG.GROVE_2_1, 50)
30 |
31 | time.sleep(2)
32 | GPG.reset_all()
33 |
34 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
35 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
36 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_Light_Sensor.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license
8 | # (http://choosealicense.com/licenses/mit/).
9 | #
10 | # For more information see
11 | # https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
12 | #
13 | # This code is an example for controlling the GoPiGo3 LED.
14 | #
15 | # Results: When you run this program, the GoPiGo3 will take
16 | # readings from a Grove light sensor connected to its
17 | # port Analog/Digital 1
18 | #
19 |
20 |
21 | # use python 3 syntax but make it compatible with python 2
22 | from __future__ import print_function
23 | from __future__ import division
24 |
25 | # import the time library for the sleep function
26 | import time
27 |
28 | # import the GoPiGo3 drivers
29 | import gopigo3
30 |
31 | # Create an instance of the GoPiGo3 class.
32 | # GPG will be the GoPiGo3 object.
33 | GPG = gopigo3.GoPiGo3()
34 |
35 |
36 | # Connect the light sensor to port Analog/Digital 1
37 | LIGHT_PORT = GPG.GROVE_1
38 | LIGHT_PIN = GPG.GROVE_1_1
39 |
40 |
41 | # set the port as an analog input port
42 | GPG.set_grove_type(LIGHT_PORT, GPG.GROVE_TYPE.CUSTOM)
43 | GPG.set_grove_mode(LIGHT_PORT, GPG.GROVE_INPUT_ANALOG)
44 |
45 | # loop forever while polling the sensor
46 | while(True):
47 | try:
48 | time.sleep(0.05)
49 | reading = GPG.get_grove_analog(LIGHT_PIN)
50 | # scale the reading to a 0-100 scale
51 | percent_reading = reading * 100 / 4095
52 | print("{}, {:.1f}%".format(reading, percent_reading))
53 |
54 | except KeyboardInterrupt:
55 | GPG.reset_all()
56 | exit(0)
57 | except:
58 | pass
59 |
60 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_US.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for using the grove ultrasonic sensor with the GoPiGo3.
11 | #
12 | # Hardware: Connect a grove ultrasonic sensor to port AD1 of the GoPiGo3.
13 | #
14 | # Results: When you run this program, the distance measured with the ultrasonic sensor should be printed.
15 |
16 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
17 | from __future__ import division # ''
18 |
19 | import time # import the time library for the sleep function
20 | import gopigo3 # import the GoPiGo3 drivers
21 |
22 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
23 |
24 | try:
25 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.US)
26 |
27 | while(True):
28 | try:
29 | print("%4dmm" % GPG.get_grove_value(GPG.GROVE_1))
30 | except gopigo3.SensorError as error:
31 | print(error)
32 | except gopigo3.ValueError as error:
33 | print(error)
34 | time.sleep(0.05)
35 |
36 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
37 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
38 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Grove_US2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for using the grove ultrasonic sensor with the GoPiGo3.
11 | #
12 | # Hardware: Connect a grove ultrasonic sensor to port AD1 and another to port AD2 of the GoPiGo3.
13 | #
14 | # Results: When you run this program, the distance measured with the ultrasonic sensors should be printed.
15 |
16 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
17 | from __future__ import division # ''
18 |
19 | import time # import the time library for the sleep function
20 | import gopigo3 # import the GoPiGo3 drivers
21 |
22 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
23 |
24 | sensor1 = 0
25 | sensor2 = 0
26 |
27 | try:
28 | # configure both ultrasonic sensors
29 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.US)
30 | GPG.set_grove_type(GPG.GROVE_2, GPG.GROVE_TYPE.US)
31 |
32 | # wait for the sensors to get configured
33 | time.sleep(0.05)
34 |
35 | while(True):
36 | # try reading sensor 1
37 | try:
38 | sensor1 = GPG.get_grove_value(GPG.GROVE_1)
39 | except gopigo3.SensorError:
40 | sensor1 = 0
41 | except gopigo3.ValueError:
42 | sensor1 = 0
43 |
44 | # try reading sensor 2
45 | try:
46 | sensor2 = GPG.get_grove_value(GPG.GROVE_2)
47 | except gopigo3.SensorError:
48 | sensor2 = 0
49 | except gopigo3.ValueError:
50 | sensor2 = 0
51 |
52 | # print the sensor values
53 | print("Sensor 1: %4dmm Sensor 2: %4dmm" % (sensor1, sensor2))
54 |
55 | # slow down a little
56 | time.sleep(0.05)
57 |
58 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
59 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
60 |
61 | except Exception as e:
62 | print(e)
63 | GPG.reset_all()
64 |
--------------------------------------------------------------------------------
/Software/Python/Examples/LED.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for controlling the GoPiGo3 LED.
11 | #
12 | # Results: When you run this program, the GoPiGo3 LEDs will fade up and down.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | while True:
24 | for i in range(11): # count from 0-10
25 | GPG.set_led(GPG.LED_EYE_LEFT, i, i, i) # set the LED brightness (0 to 255)
26 | GPG.set_led(GPG.LED_EYE_RIGHT, 10 - i, 10 - i, 10 - i) # set the LED brightness (255 to 0)
27 | GPG.set_led(GPG.LED_BLINKER_LEFT, (i * 25)) # set the LED brightness (0 to 255)
28 | GPG.set_led(GPG.LED_BLINKER_RIGHT, ((10 - i) * 25)) # set the LED brightness (255 to 0)
29 | time.sleep(0.02) # delay for 0.02 seconds (20ms) to reduce the Raspberry Pi CPU load and give time to see the LED pulsing.
30 |
31 | GPG.set_led(GPG.LED_WIFI, 0, 0, 10)
32 |
33 | for i in range(11): # count from 0-10
34 | GPG.set_led(GPG.LED_EYE_LEFT, 10 - i, 10 - i, 10 - i) # set the LED brightness (255 to 0)
35 | GPG.set_led(GPG.LED_EYE_RIGHT, i, i, i) # set the LED brightness (0 to 255)
36 | GPG.set_led(GPG.LED_BLINKER_LEFT, ((10 - i) * 25)) # set the LED brightness (0 to 255)
37 | GPG.set_led(GPG.LED_BLINKER_RIGHT, (i * 25)) # set the LED brightness (255 to 0)
38 | time.sleep(0.02) # delay for 0.02 seconds (20ms) to reduce the Raspberry Pi CPU load and give time to see the LED pulsing.
39 |
40 | GPG.set_led(GPG.LED_WIFI, 0, 0, 0)
41 |
42 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
43 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
44 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Line_Sensor/README.md:
--------------------------------------------------------------------------------
1 | # LINE FOLLOWER SENSOR
2 |
3 | # THIS REPO IS DEPRECATED
4 |
5 | These files showcase how to use the RED line follower with a GoPiGo3 (the black line follower will not work)
6 |
7 | For these files to work, the DI Sensors drivers must first be installed. On Raspbian for Robots they are pre-installed already.
8 |
9 | ## Installation
10 | If you need to install the DI Sensors repo, this is how to do it:
11 |
12 | `curl -kL dexterindustries.com/update_sensors | bash`
13 |
14 | ## More
15 | See more at https://github.com/DexterInd/DI_Sensors
16 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Line_Sensor/basic_example.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # Dexter Industries line sensor basic example
3 | #
4 | # This example shows a basic example to read sensor data from the line sensor. Most basic example prints out the data from the 5 sensors on the line follower.
5 | #
6 | # Have a question about this example? Ask on the forums here: http://forum.dexterindustries.com/c/gopigo
7 | #
8 | #
9 | # Initial Date: 13 Dec 2015 Karan Nayan
10 | # Last Updated: 16 Feb 2016 John Cole
11 | # http://www.dexterindustries.com/
12 | '''
13 | ## License
14 | Copyright (C) 2017 Dexter Industries
15 |
16 | This program is free software: you can redistribute it and/or modify
17 | it under the terms of the GNU General Public License as published by
18 | the Free Software Foundation, either version 3 of the License, or
19 | (at your option) any later version.
20 |
21 | This program is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | GNU General Public License for more details.
25 |
26 | You should have received a copy of the GNU General Public License
27 | along with this program. If not, see .
28 | '''
29 | from __future__ import print_function
30 | from __future__ import division
31 | # the above lines are meant for Python3 compatibility.
32 | # they force the use of Python3 functionality for print(),
33 | # the integer division and input()
34 | # mind your parentheses!
35 |
36 | from line_follower import line_sensor
37 | import time
38 |
39 | def get_sensorval():
40 | while True:
41 | val=line_sensor.read_sensor()
42 | if val[0]!=-1:
43 | return val
44 | #else:
45 | #Read once more to clear buffer and remove junk values
46 | # val=line_sensor.read_sensor()
47 |
48 | print("THIS IS DEPRECATED. IT WILL ONLY WORK WITH THE RED LINE FOLLOWER")
49 |
50 | while True:
51 | l0,l1,l2,l3,l4=get_sensorval()
52 | print (l0,l1,l2,l3,l4)
53 | #time.sleep(.05)
54 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Line_Sensor/line_follower-basic_example.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # Dexter Industries line sensor basic example
3 | #
4 | # This example shows a basic example to read sensor data from the line sensor. Most basic example prints out the data from the 5 sensors on the line follower.
5 | #
6 | # Have a question about this example? Ask on the forums here: http://www.dexterindustries.com/forum/?forum=gopigo
7 | #
8 | #
9 | # Initial Date: 13 Dec 2015 Karan Nayan
10 | # Last Updated: 16 Feb 2016 John Cole
11 | # http://www.dexterindustries.com/
12 | '''
13 | ## License
14 | Copyright (C) 2017 Dexter Industries
15 |
16 | This program is free software: you can redistribute it and/or modify
17 | it under the terms of the GNU General Public License as published by
18 | the Free Software Foundation, either version 3 of the License, or
19 | (at your option) any later version.
20 |
21 | This program is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | GNU General Public License for more details.
25 |
26 | You should have received a copy of the GNU General Public License
27 | along with this program. If not, see .
28 | '''
29 | from __future__ import print_function
30 | from __future__ import division
31 | # the above lines are meant for Python3 compatibility.
32 | # they force the use of Python3 functionality for print(),
33 | # the integer division and input()
34 | # mind your parentheses!
35 |
36 | import easygopigo3 as easy
37 | import time
38 |
39 | sensor_readings = None
40 |
41 | gpg = easy.EasyGoPiGo3()
42 |
43 | try:
44 | my_linefollower = gpg.init_line_follower()
45 | time.sleep(0.1)
46 | except:
47 | print('Line Follower not responding')
48 | time.sleep(0.2)
49 | exit()
50 | my_linefollower.read_position()
51 | my_linefollower.read_position()
52 |
53 |
54 | # start
55 | gpg.forward()
56 | while not my_linefollower.read_position() == "black":
57 | if my_linefollower.read_position() == 'center':
58 | gpg.forward()
59 | if my_linefollower.read_position() == 'left':
60 | gpg.left()
61 | if my_linefollower.read_position() == 'right':
62 | gpg.right()
63 | gpg.stop()
64 |
65 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Motor.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for controlling the GoPiGo3 Motors
11 | #
12 | # Results: When you run this program, the GoPiGo3 Motors will rotate back and forth.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | for i in range(0, 101):
24 | GPG.set_motor_power(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, i)
25 | time.sleep(0.02)
26 | while True:
27 | for i in range(-100, 51):
28 | GPG.set_motor_power(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, -i)
29 | time.sleep(0.02)
30 |
31 | for i in range(-50, 101):
32 | GPG.set_motor_power(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, i)
33 | time.sleep(0.02)
34 |
35 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
36 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
37 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Motor_Encoder.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for reading the GoPiGo3 Motors' encoders
11 | #
12 | # Results: When you run this program, the GoPiGo3 Motors' position will be printed.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | GPG.offset_motor_encoder(GPG.MOTOR_LEFT, GPG.get_motor_encoder(GPG.MOTOR_LEFT))
24 | GPG.offset_motor_encoder(GPG.MOTOR_RIGHT, GPG.get_motor_encoder(GPG.MOTOR_RIGHT))
25 | while True:
26 | print("Encoder L: %6d R: %6d" % (GPG.get_motor_encoder(GPG.MOTOR_LEFT), GPG.get_motor_encoder(GPG.MOTOR_RIGHT)))
27 | time.sleep(0.025)
28 |
29 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
30 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
31 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Motor_Follow.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for controlling the GoPiGo3 Motors
11 | #
12 | # Results: When you run this program, the GoPiGo3 Motors will rotate back and forth.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | GPG.offset_motor_encoder(GPG.MOTOR_LEFT, GPG.get_motor_encoder(GPG.MOTOR_LEFT))
24 | GPG.offset_motor_encoder(GPG.MOTOR_RIGHT, GPG.get_motor_encoder(GPG.MOTOR_RIGHT))
25 | while True:
26 | EncoderLeft = GPG.get_motor_encoder(GPG.MOTOR_LEFT)
27 | EncoderRight = GPG.get_motor_encoder(GPG.MOTOR_RIGHT)
28 | print("Encoder L: %6d R: %6d" % (EncoderLeft, EncoderRight))
29 |
30 | GPG.set_motor_position(GPG.MOTOR_RIGHT, EncoderLeft)
31 | time.sleep(0.02)
32 |
33 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
34 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
35 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Motor_Position.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for controlling the GoPiGo3 Motors
11 | #
12 | # Results: When you run this program, the GoPiGo3 Motors will rotate back and forth.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | GPG.offset_motor_encoder(GPG.MOTOR_LEFT, GPG.get_motor_encoder(GPG.MOTOR_LEFT))
24 | GPG.offset_motor_encoder(GPG.MOTOR_RIGHT, GPG.get_motor_encoder(GPG.MOTOR_RIGHT))
25 | for i in range(0, 361):
26 | GPG.set_motor_position(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, i)
27 | time.sleep(0.01)
28 | while True:
29 | for i in range(-360, 361):
30 | GPG.set_motor_position(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, -i)
31 | time.sleep(0.01)
32 |
33 | for i in range(-360, 361):
34 | GPG.set_motor_position(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, i)
35 | time.sleep(0.01)
36 |
37 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
38 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
39 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Motor_Speed.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for controlling the GoPiGo3 Motors
11 | #
12 | # Results: When you run this program, manually rotate the left motor to control the speed of the right motor.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | GPG.offset_motor_encoder(GPG.MOTOR_LEFT, GPG.get_motor_encoder(GPG.MOTOR_LEFT))
24 | GPG.offset_motor_encoder(GPG.MOTOR_RIGHT, GPG.get_motor_encoder(GPG.MOTOR_RIGHT))
25 | while True:
26 | EncoderLeft = GPG.get_motor_encoder(GPG.MOTOR_LEFT)
27 | print("Motor Left Encoder: %6d" % EncoderLeft, " Motor Right status: ", GPG.get_motor_status(GPG.MOTOR_RIGHT))
28 |
29 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, EncoderLeft)
30 | time.sleep(0.02)
31 |
32 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
33 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
34 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Motor_Turn.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for making the GoPiGo3 turn accurately
11 | #
12 | # Results: When you run this program, the GoPiGo3 should turn 90 degrees to the right, 180 to the left, and then 90 to the right, ending where it started.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | def TurnDegrees(degrees, speed):
23 | # get the starting position of each motor
24 | StartPositionLeft = GPG.get_motor_encoder(GPG.MOTOR_LEFT)
25 | StartPositionRight = GPG.get_motor_encoder(GPG.MOTOR_RIGHT)
26 |
27 | # the distance in mm that each wheel needs to travel
28 | WheelTravelDistance = ((GPG.WHEEL_BASE_CIRCUMFERENCE * degrees) / 360)
29 |
30 | # the number of degrees each wheel needs to turn
31 | WheelTurnDegrees = ((WheelTravelDistance / GPG.WHEEL_CIRCUMFERENCE) * 360)
32 |
33 | # Limit the speed
34 | GPG.set_motor_limits(GPG.MOTOR_LEFT + GPG.MOTOR_RIGHT, dps = speed)
35 |
36 | # Set each motor target
37 | GPG.set_motor_position(GPG.MOTOR_LEFT, (StartPositionLeft + WheelTurnDegrees))
38 | GPG.set_motor_position(GPG.MOTOR_RIGHT, (StartPositionRight - WheelTurnDegrees))
39 |
40 | try:
41 | TurnDegrees(90, 100) # turn 90 degrees to the right, at a wheel speed of 100 degrees per second
42 | time.sleep(7)
43 | TurnDegrees(-180, 100) # turn 180 degrees to the left, at a wheel speed of 100 degrees per second
44 | time.sleep(8)
45 | TurnDegrees(90, 100) # turn 90 degrees to the right, at a wheel speed of 100 degrees per second
46 | time.sleep(3)
47 | GPG.reset_all()
48 |
49 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
50 | GPG.reset_all() # Unconfigure the sensors, disable and reset the motors, and turn off LEDs
51 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Read_Info.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for reading GoPiGo3 information
11 | #
12 | # Results: Print information about the attached GoPiGo3.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import gopigo3 # import the GoPiGo3 drivers
18 |
19 | try:
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | # Each of the following GPG.get functions return a list of 2 values
23 | print("Manufacturer : ", GPG.get_manufacturer() ) # read and display the serial number
24 | print("Board : ", GPG.get_board() ) # read and display the serial number
25 | print("Serial Number : ", GPG.get_id() ) # read and display the serial number
26 | print("Hardware version: ", GPG.get_version_hardware()) # read and display the hardware version
27 | print("Firmware version: ", GPG.get_version_firmware()) # read and display the firmware version
28 | print("Battery voltage : ", GPG.get_voltage_battery() ) # read and display the current battery voltage
29 | print("5v voltage : ", GPG.get_voltage_5v() ) # read and display the current 5v regulator voltage
30 |
31 | except IOError as error:
32 | print(error)
33 |
34 | except gopigo3.FirmwareVersionError as error:
35 | print(error)
36 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Remote_Control.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This program uses the IR Receiver connected to AD1 with the Go Box IR remote to drive the GoPiGo3.
11 |
12 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
13 | from __future__ import division # ''
14 |
15 | import time # import the time library for the sleep function
16 | import gopigo3 # import the GoPiGo3 drivers
17 |
18 | # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
19 | GPG = gopigo3.GoPiGo3()
20 |
21 | value_last = -1
22 |
23 | def read_ir_keys():
24 | global value_last
25 | try:
26 | value = GPG.get_grove_value(GPG.GROVE_1)
27 | if value != value_last:
28 | value_last = value
29 | if value == 1:
30 | GPG.set_motor_dps(GPG.MOTOR_LEFT , 300)
31 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, 300)
32 | elif value == 2:
33 | GPG.set_motor_dps(GPG.MOTOR_LEFT , -150)
34 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, 150)
35 | elif value == 4:
36 | GPG.set_motor_dps(GPG.MOTOR_LEFT , 150)
37 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, -150)
38 | elif value == 5:
39 | GPG.set_motor_dps(GPG.MOTOR_LEFT , -300)
40 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, -300)
41 | else:
42 | GPG.set_motor_dps(GPG.MOTOR_LEFT , 0)
43 | GPG.set_motor_dps(GPG.MOTOR_RIGHT, 0)
44 | except IOError or gopigo3.SensorError as e:
45 | pass
46 |
47 |
48 | print("Use the arrows on your remote controller to control your GoPiGo3")
49 | print("The IR Receiver (remote sensor) should connected to port AD1")
50 | print("Ctrl-C to exit the program")
51 |
52 |
53 | GPG.set_grove_type(GPG.GROVE_1, GPG.GROVE_TYPE.IR_DI_REMOTE)
54 | while True:
55 | try:
56 | read_ir_keys()
57 |
58 | # except the program gets interrupted by Ctrl+C on the keyboard.
59 | except KeyboardInterrupt:
60 | # Unconfigure the sensors, disable the motors, and
61 | # restore the LED to the control of the GoPiGo3 firmware.
62 | GPG.reset_all()
63 | exit(0)
64 |
65 | except:
66 | pass
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Software/Python/Examples/Servo.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 | #
10 | # This code is an example for controlling the GoPiGo3 Servos
11 | #
12 | # Results: When you run this program, the GoPiGo3 Servos will rotate back and forth.
13 |
14 | from __future__ import print_function # use python 3 syntax but make it compatible with python 2
15 | from __future__ import division # ''
16 |
17 | import time # import the time library for the sleep function
18 | import gopigo3 # import the GoPiGo3 drivers
19 |
20 | GPG = gopigo3.GoPiGo3() # Create an instance of the GoPiGo3 class. GPG will be the GoPiGo3 object.
21 |
22 | try:
23 | while True:
24 | for i in range(1000, 2001): # count from 1000 to 2000
25 | GPG.set_servo(GPG.SERVO_1, i)
26 | GPG.set_servo(GPG.SERVO_2, 3000-i)
27 | time.sleep(0.001)
28 |
29 | for i in range(1000, 2001): # count from 1000 to 2000
30 | GPG.set_servo(GPG.SERVO_2, i)
31 | GPG.set_servo(GPG.SERVO_1, 3000-i)
32 | time.sleep(0.001)
33 |
34 | except KeyboardInterrupt: # except the program gets interrupted by Ctrl+C on the keyboard.
35 | GPG.reset_all() # Unconfigure the sensors, disable the motors, and restore the LED to the control of the GoPiGo3 firmware.
36 |
--------------------------------------------------------------------------------
/Software/Python/Examples/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Python/Examples/__init__.py
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_Blinkers.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo3/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license
8 | # (http://choosealicense.com/licenses/mit/).
9 | #
10 | # For more information see
11 | # https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
12 | #
13 | # This code is an example for controlling the GoPiGo3 blinkers. This uses
14 | # the EasyGoPiGo3 library. You can find more information on the library
15 | # here: http://gopigo3.readthedocs.io/en/latest/api-basic.html#easygopigo3
16 | # These "Blinkers" are the LED's are located under the I2C ports on the GoPiGo3
17 | #
18 | # Results: The GoPiGo3 will turn the LED's on, then the left LED off, and then
19 | # the right LED off.
20 |
21 |
22 | # import the time library for the sleep function
23 | import time
24 | # import the GoPiGo3 drivers
25 | import easygopigo3 as easy
26 |
27 | # Create an instance of the GoPiGo3 class.
28 | # GPG will be the GoPiGo3 object.
29 | gpg = easy.EasyGoPiGo3()
30 |
31 | left = 0
32 | right = 1
33 |
34 | while True:
35 | # Turn both LEDs on
36 | # These LED's are located under the I2C ports on the GoPiGo3
37 | gpg.led_on("left")
38 | gpg.led_on("right")
39 | time.sleep(1)
40 |
41 | # Turn the left LED off
42 | gpg.led_off("left")
43 | time.sleep(1)
44 |
45 | # Turn the right LED Off
46 | gpg.led_off("right")
47 | time.sleep(1)
48 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_Button.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # import the time library for the sleep function
3 | import time
4 |
5 | # import the GoPiGo3 drivers
6 | import easygopigo3 as easy
7 |
8 | # Create an instance of the GoPiGo3 class.
9 | # GPG will be the GoPiGo3 object.
10 | gpg = easy.EasyGoPiGo3()
11 |
12 | # Put a grove button in port AD1
13 | my_button = gpg.init_button_sensor("AD1")
14 |
15 | print("Ensure there's a button in port AD1")
16 | print("Press and release the button as often as you want")
17 | print("the program will run for 2 minutes or")
18 | print("Ctrl-C to interrupt it")
19 |
20 |
21 | start = time.time()
22 | RELEASED = 0
23 | PRESSED = 1
24 | state = RELEASED
25 |
26 | while time.time() - start < 120:
27 |
28 | if state == RELEASED and my_button.read() == 1:
29 | print("PRESSED")
30 | gpg.open_eyes()
31 | state = PRESSED
32 | if state == PRESSED and my_button.read() == 0:
33 | print("RELEASED")
34 | gpg.close_eyes()
35 | state = RELEASED
36 | time.sleep(0.05)
37 |
38 | print("All done!")
39 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_Buzzer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # import the time library for the sleep function
3 | import time
4 |
5 | # import the GoPiGo3 drivers
6 | import easygopigo3 as easy
7 |
8 | # Create an instance of the GoPiGo3 class.
9 | # GPG will be the GoPiGo3 object.
10 | gpg = easy.EasyGoPiGo3()
11 |
12 | # Create an instance of the Buzzer
13 | # connect a buzzer to port AD2
14 | my_buzzer = gpg.init_buzzer("AD2")
15 |
16 | twinkle = ["C4","C4","G4","G4","A4","A4","G4"]
17 |
18 | print("Expecting a buzzer on Port AD2")
19 | print("A4")
20 | my_buzzer.sound(440)
21 | time.sleep(1)
22 | print("A5")
23 | my_buzzer.sound(880)
24 | time.sleep(1)
25 | print("A3")
26 | my_buzzer.sound(220)
27 | time.sleep(1)
28 |
29 | for note in twinkle:
30 | print(note)
31 | my_buzzer.sound(my_buzzer.scale[note])
32 | time.sleep(0.5)
33 | my_buzzer.sound_off()
34 | time.sleep(0.25)
35 |
36 | my_buzzer.sound_off()
37 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_DexEyes.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo3/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license
8 | # (http://choosealicense.com/licenses/mit/).
9 | #
10 | # For more information see
11 | # https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
12 | #
13 | # This code is an example for controlling the GoPiGo3 blinkers. This uses
14 | # the EasyGoPiGo3 library. You can find more information on the library
15 | # here: http://gopigo3.readthedocs.io/en/latest/api-basic.html#easygopigo3
16 | # These "Blinkers" are the LED's are located under the I2C ports on the GoPiGo3
17 | #
18 | # Results: The GoPiGo3 will turn the LED's on, then the left LED off, and then
19 | # the right LED off.
20 |
21 |
22 | # import the time library for the sleep function
23 | import time
24 | # import the GoPiGo3 drivers
25 | import easygopigo3 as easy
26 |
27 | # Create an instance of the GoPiGo3 class.
28 | # GPG will be the GoPiGo3 object.
29 | gpg = easy.EasyGoPiGo3()
30 |
31 | while True:
32 | # Set the eye color to blue.
33 | # Setting the eye color is a tuple of (R, G, B) values, greater than
34 | # zero and less than 255.
35 | gpg.set_left_eye_color((1,1,125))
36 | gpg.set_right_eye_color((1,1,125))
37 | time.sleep(1)
38 |
39 | # Open the left eye with the blue color
40 | gpg.open_left_eye()
41 | time.sleep(1)
42 |
43 | # Open the right eye with the blue color
44 | gpg.open_right_eye()
45 | time.sleep(1)
46 |
47 | # Set BOTH eye color to red.
48 |
49 | gpg.set_eye_color((125,1,1))
50 |
51 | # Change the left eye to red.
52 | gpg.open_left_eye()
53 | time.sleep(1)
54 |
55 | # Change the right eye to red.
56 | gpg.open_right_eye()
57 | time.sleep(2)
58 |
59 | # Close both eyes.
60 | gpg.close_eyes()
61 | time.sleep(1)
62 |
63 | # Set the left eye to red, the right eye to blue.
64 | gpg.set_left_eye_color((125,1,1))
65 | gpg.set_right_eye_color((1,1,125))
66 |
67 | # Open both eyes at once
68 | gpg.open_eyes()
69 | time.sleep(1)
70 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_Distance_Sensor.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # Dexter Industries Distance Sensor example for the GoPiGo3
3 | #
4 | # This example shows a basic example to read sensor data from the Dexter Industries Distance Sensor. This sensor is a white PCB.
5 | #
6 | # Connect the Dexter Industries Distance Sensor to an I2C port on the GoPiGo3.
7 | # You can find the Distance Sensor here: https://www.dexterindustries.com/shop/distance-sensor/
8 | # Have a question about this example? Ask on the forums here:
9 | # http://forum.dexterindustries.com/c/gopigo
10 | #
11 | # Initial Date: 16 Jun 2017 John Cole
12 | # http://www.dexterindustries.com/GoPiGo
13 | '''
14 | ## License
15 | Copyright (C) 2017 Dexter Industries
16 |
17 | This program is free software: you can redistribute it and/or modify
18 | it under the terms of the GNU General Public License as published by
19 | the Free Software Foundation, either version 3 of the License, or
20 | (at your option) any later version.
21 |
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
26 |
27 | You should have received a copy of the GNU General Public License
28 | along with this program. If not, see .
29 | '''
30 |
31 | # import the GoPiGo3 drivers
32 | import time
33 | import easygopigo3 as easy
34 |
35 | # This example shows how to read values from the Distance Sensor
36 |
37 | # Create an instance of the GoPiGo3 class.
38 | # GPG will be the GoPiGo3 object.
39 | gpg = easy.EasyGoPiGo3()
40 |
41 | # Create an instance of the Distance Sensor class.
42 | # I2C1 and I2C2 are just labels used for identifyng the port on the GoPiGo3 board.
43 | # But technically, I2C1 and I2C2 are the same thing, so we don't have to pass any port to the constructor.
44 | my_distance_sensor = gpg.init_distance_sensor()
45 |
46 | while True:
47 | # Directly print the values of the sensor.
48 | print("Distance Sensor Reading: {} mm ".format(my_distance_sensor.read_mm()))
49 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_LED.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # import the EasyGoPiGo3 drivers
3 | import time
4 | import easygopigo3 as easy
5 |
6 | # This example will turn a Grove LED on the GoPiGo3 AD1 port on and off.
7 |
8 | # Create an instance of the GoPiGo3 class.
9 | # GPG will be the GoPiGo3 object.
10 | gpg = easy.EasyGoPiGo3()
11 |
12 |
13 | # create the LED instance, passing the port and GPG
14 | my_led = gpg.init_led("AD1")
15 | # or
16 | # my_LED = easy.Led("AD1", GPG)
17 |
18 | # loop 100 times
19 | for i in range(100):
20 | my_led.light_max() # turn LED at max power
21 | time.sleep(0.5)
22 |
23 | my_led.light_on(30) # 30% power
24 | time.sleep(0.5)
25 |
26 | my_led.light_off() # turn LED off
27 | time.sleep(0.5)
28 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_Light_Sensor.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license
8 | # (http://choosealicense.com/licenses/mit/).
9 | #
10 | # For more information see
11 | # https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
12 | #
13 | # This code is an example for controlling the GoPiGo3 LED.
14 | #
15 | # Results: When you run this program, the GoPiGo3 will take
16 | # readings from a Grove light sensor connected to its
17 | # port Analog/Digital 1
18 | #
19 |
20 |
21 | # import the time library for the sleep function
22 | import time
23 |
24 | # import the GoPiGo3 drivers
25 | import easygopigo3 as easy
26 |
27 | # Create an instance of the GoPiGo3 class.
28 | # GPG will be the GoPiGo3 object.
29 | gpg = easy.EasyGoPiGo3()
30 |
31 | # Create an instance of the Light sensor
32 | my_light_sensor = gpg.init_light_sensor("AD1")
33 | my_led = gpg.init_led("AD2")
34 |
35 | # loop forever while polling the sensor
36 | while(True):
37 | # get absolute value
38 | reading = my_light_sensor.read()
39 | # scale the reading to a 0-100 scale
40 | percent_reading = my_light_sensor.percent_read()
41 |
42 | # check if the light's intensity is above 50%
43 | if percent_reading >= 50:
44 | my_led.light_off()
45 | else:
46 | my_led.light_max()
47 | print("{}, {:.1f}%".format(reading, percent_reading))
48 |
49 | time.sleep(0.05)
50 |
--------------------------------------------------------------------------------
/Software/Python/Examples/easy_Motors.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com/GoPiGo/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2017 Dexter Industries
7 | # Released under the MIT license
8 | # (http://choosealicense.com/licenses/mit/).
9 | #
10 | # For more information see
11 | # https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
12 | #
13 | # This code is an example for controlling the GoPiGo3 motors. This uses
14 | # the EasyGoPiGo3 library. You can find more information on the library
15 | # here: http://gopigo3.readthedocs.io/en/latest/api-basic.html#easygopigo3
16 | #
17 | # Results: The GoPiGo3 will move forward for 2 seconds, and then
18 | # backward for 2 second.
19 |
20 |
21 | # import the time library for the sleep function
22 | import time
23 | # import the GoPiGo3 drivers
24 | from easygopigo3 import EasyGoPiGo3
25 |
26 | # Create an instance of the GoPiGo3 class.
27 | # GPG will be the GoPiGo3 object.
28 | gpg = EasyGoPiGo3()
29 |
30 | print("Move the motors forward freely for 1 second.")
31 | gpg.forward()
32 | time.sleep(1)
33 | gpg.stop()
34 |
35 | print("Stop the motors for 1 second.")
36 | time.sleep(1)
37 |
38 | print("Drive the motors 50 cm and then stop.")
39 | gpg.drive_cm(50, True)
40 | time.sleep(1)
41 |
42 | print("Turn right 1 second.")
43 | gpg.right()
44 | time.sleep(1)
45 |
46 | print("Turn left 1 second.")
47 | gpg.left()
48 | time.sleep(1)
49 |
50 | print("Stop!")
51 | gpg.stop()
52 | print("Done!")
53 |
--------------------------------------------------------------------------------
/Software/Python/hardware_test.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # This program is for testing GoPiGo3 Hardware.
3 |
4 | '''
5 | ## License
6 | GoPiGo3 for the Raspberry Pi: an open source robotics platform for the Raspberry Pi.
7 | Copyright (C) 2017 Dexter Industries
8 |
9 | This program is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | This program is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with this program. If not, see .
21 | '''
22 | from __future__ import print_function
23 | from __future__ import division
24 | from builtins import input
25 | # the above lines are meant for Python3 compatibility.
26 | # they force the use of Python3 functionality for print(),
27 | # the integer division and input()
28 | # mind your parentheses!
29 |
30 | import time
31 | import easygopigo3 as easy
32 | import sys
33 | import atexit
34 |
35 |
36 | gpg = easy.EasyGoPiGo3()
37 | atexit.register(gpg.stop)
38 |
39 | gpg.reset_all()
40 | print("Warning: The robot is about to move forward. ")
41 | time.sleep(1) # let's give the reset_all() some time to finish
42 | gpg.set_speed(300)
43 |
44 | print ("Both motors moving Forward with Dex Eyes On")
45 | gpg.open_eyes()
46 | gpg.drive_cm(100)
47 |
48 | print ("Both motors stopped with Dex Eyes Off")
49 | gpg.close_eyes()
50 | gpg.stop()
51 | time.sleep(2)
52 |
53 | print ("Both motors moving back with blinkers On")
54 | gpg.blinker_on(1)
55 | gpg.blinker_on(0)
56 | gpg.drive_cm(-100)
57 |
58 | print ("Both motors stopped with blinkers Off")
59 | gpg.blinker_off(1)
60 | gpg.blinker_off(0)
61 | gpg.stop()
62 |
63 | print ("Hardware test finished.")
64 | time.sleep(5)
--------------------------------------------------------------------------------
/Software/Python/mock_package/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Python/mock_package/__init__.py
--------------------------------------------------------------------------------
/Software/Python/mock_package/distance_sensor.py:
--------------------------------------------------------------------------------
1 | def distance_sensor():
2 | pass
3 |
4 | class DistanceSensor:
5 | pass
6 |
--------------------------------------------------------------------------------
/Software/Python/package_description.rst:
--------------------------------------------------------------------------------
1 | This is the python library for GoPiGo3, which is a robot car that can be programmed to do anything.
2 |
3 | Please visit:
4 |
5 | * Our `official documentation `_ for instructions on how to use the robot.
6 | * Our `github repo folder `_ for using one of our many example programs.
7 | * Or our `official page `_ for more details about this robot.
8 |
--------------------------------------------------------------------------------
/Software/Python/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | description-file = README.md
3 |
--------------------------------------------------------------------------------
/Software/Python/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://GoPiGo.io/
4 | # https://github.com/DexterInd/GoPiGo3
5 | #
6 | # Copyright (c) 2022 Modular Robotics
7 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
8 | # For more information see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
9 |
10 | try:
11 | with open('package_description.rst', 'r') as file_description:
12 | description = file_description.read()
13 |
14 | except IOError:
15 | description = "Check more on https://pypi.python.org/pypi/gopigo3"
16 |
17 | from setuptools import setup, find_packages
18 |
19 | setup(
20 | name = "gopigo3",
21 | version = "1.3.2.1",
22 |
23 | description = "Drivers and Examples for using the GoPiGo3 in Python",
24 | long_description = description,
25 |
26 | author = "Modular Robotics",
27 | author_email = "info@modrobotics.com",
28 |
29 | license = 'MIT',
30 | classifiers = [
31 | 'Development Status :: 5 - Production/Stable',
32 | 'Intended Audience :: Developers',
33 | 'Intended Audience :: Education',
34 | 'License :: OSI Approved :: MIT License',
35 | 'Operating System :: POSIX :: Linux',
36 | 'Programming Language :: Python :: 2',
37 | 'Programming Language :: Python :: 3',
38 | 'Topic :: Software Development :: Embedded Systems',
39 | 'Topic :: Software Development :: Libraries :: Python Modules',
40 | ],
41 | url = "https://github.com/DexterInd/GoPiGo3",
42 |
43 | keywords = ['robot', 'gopigo', 'gopigo3', 'modular robotics', 'learning', 'education'],
44 |
45 | packages=find_packages(),
46 | py_modules = ['gopigo3','easygopigo3', 'easysensors'],
47 | install_requires = ['spidev', 'pigpio']
48 | )
49 |
--------------------------------------------------------------------------------
/Software/Python/tests/test_distance_sensor.py:
--------------------------------------------------------------------------------
1 | ####################################################
2 | # This file contains a short test to determine
3 | # if it is possible to access the distance sensor
4 | # from two separate processes using mutex.
5 | # Run in parallel with test_distance_sensor_2.py
6 | ####################################################
7 |
8 | import time
9 | import easygopigo3 as easy
10 | gpg = easy.EasyGoPiGo3(use_mutex=True)
11 |
12 | my_Distance_portI2C = easy.DistanceSensor('I2C', gpg, use_mutex=True)
13 | time.sleep(0.1)
14 |
15 |
16 | # start()
17 | while True:
18 | dist = my_Distance_portI2C.read_mm()
19 | print(dist)
20 | if dist == 0:
21 | exit()
22 | else:
23 | print(".")
24 | time.sleep(0.1)
25 |
26 |
--------------------------------------------------------------------------------
/Software/Python/tests/test_distance_sensor_2.py:
--------------------------------------------------------------------------------
1 | ####################################################
2 | # This file contains a short test to determine
3 | # if it is possible to access the distance sensor
4 | # from two separate processes using mutex.
5 | # Run in parallel with test_distance_sensor.py
6 | ####################################################
7 |
8 | import time
9 | import easygopigo3 as easy
10 | gpg = easy.EasyGoPiGo3(use_mutex=True)
11 |
12 | my_Distance_portI2C = easy.DistanceSensor('I2C', gpg, use_mutex=True)
13 | time.sleep(0.1)
14 |
15 |
16 | # start()
17 | while True:
18 | dist = my_Distance_portI2C.read_mm()
19 | print(dist)
20 | if dist == 0:
21 | exit()
22 | else:
23 | print(".")
24 | time.sleep(0.1)
25 |
26 |
--------------------------------------------------------------------------------
/Software/Python/tests/test_heavy_mutex.py:
--------------------------------------------------------------------------------
1 | ####################################################
2 | # This file tests the mutex class
3 | # Run it in parallel with text_heavy_mutext_2.py
4 | # in order to verify that mutex is functional.
5 | # This one acquires and releases every half second
6 | # the other one is every 5 seconds
7 | ####################################################
8 | import time
9 | from I2C_mutex import Mutex
10 | import fcntl
11 |
12 | mutex = Mutex(debug=True)
13 |
14 | DexterLockI2C_handle = open('/run/lock/DexterLockI2C')
15 |
16 | while True:
17 | try:
18 | mutex.acquire()
19 | time.sleep(0.5)
20 | mutex.release()
21 | except KeyboardInterrupt:
22 | mutex.release()
23 | exit(0)
24 | except Exception as e:
25 | print(e)
26 |
--------------------------------------------------------------------------------
/Software/Python/tests/test_heavy_mutex_2.py:
--------------------------------------------------------------------------------
1 | ####################################################
2 | # This file tests the mutex class
3 | # Run it in parallel with text_heavy_mutext_2.py
4 | # in order to verify that mutex is functional.
5 | # This one acquires and releases every 5 seconds
6 | # the other one is every half second
7 | ####################################################
8 | import time
9 | from I2C_mutex import Mutex
10 | import fcntl
11 |
12 | mutex = Mutex(debug=True)
13 |
14 | DexterLockI2C_handle = open('/run/lock/DexterLockI2C')
15 |
16 | while True:
17 | try:
18 | mutex.acquire()
19 | time.sleep(5)
20 | mutex.release()
21 | except KeyboardInterrupt:
22 | mutex.release()
23 | exit()
24 | except Exception as e:
25 | print(e)
26 |
--------------------------------------------------------------------------------
/Software/Python/tests/test_mutex.py:
--------------------------------------------------------------------------------
1 | ####################################################
2 | # This file attempts to create one of each sensor and
3 | # sets its mutex use to True.
4 | # As the use_mutex is a member of the base Sensor class,
5 | # we check if the info is passed down properly.
6 | # It does not test whether mutex is properly used inside each sensor.
7 | # In fact some sensors will make no use of it at all
8 | # (on GPG3 some sensors do not require mutex)
9 | # Nicole Parrot
10 | ####################################################
11 |
12 | import easygopigo3 as easy
13 |
14 | g = easy.EasyGoPiGo3(use_mutex=True)
15 |
16 | light_sensor = easy.LightSensor(gpg=g, use_mutex = True)
17 | buzzer = easy.Buzzer(gpg=g, use_mutex = True)
18 | led = easy.Led(gpg=g, use_mutex = True)
19 | motion = easy.MotionSensor(gpg=g, use_mutex = True)
20 | button = easy.ButtonSensor(gpg=g, use_mutex = True)
21 | remote = easy.Remote(gpg=g, use_mutex = True)
22 | line_follower = easy.LineFollower(gpg=g, use_mutex = True)
23 | servo = easy.Servo(gpg=g, use_mutex = True)
24 | distance_sensor = easy.DistanceSensor(gpg=g, use_mutex = True)
25 | dht = easy.DHTSensor(gpg=g, use_mutex = True)
26 | assert(g.use_mutex == True)
27 | assert(light_sensor.use_mutex == True)
28 | assert(buzzer.use_mutex == True)
29 | assert(led.use_mutex == True)
30 | assert(motion.use_mutex == True)
31 | assert(button.use_mutex == True)
32 | assert(remote.use_mutex == True)
33 | assert(line_follower.use_mutex == True)
34 | assert(servo.use_mutex == True)
35 | assert(distance_sensor.use_mutex == True)
36 | assert(dht.use_mutex == True)
37 | print("Done")
38 |
39 |
--------------------------------------------------------------------------------
/Software/Python/tests/test_sensor_mutex.py:
--------------------------------------------------------------------------------
1 | #################################################
2 | '''
3 | This file checks that the mutex value trickles down
4 | to each sensor, when the init methods are called
5 | from easygopigo3
6 | '''
7 | #################################################
8 |
9 |
10 | import easygopigo3 as easy
11 |
12 | gpg3 = easy.EasyGoPiGo3(use_mutex=True)
13 | print(gpg3.use_mutex)
14 |
15 | init_calls = [
16 | gpg3.init_light_sensor,
17 | gpg3.init_sound_sensor,
18 | gpg3.init_loudness_sensor,
19 | gpg3.init_ultrasonic_sensor,
20 | gpg3.init_buzzer,
21 | gpg3.init_led,
22 | gpg3.init_button_sensor,
23 | gpg3.init_line_follower,
24 | gpg3.init_servo,
25 | gpg3.init_distance_sensor,
26 | gpg3.init_dht_sensor,
27 | gpg3.init_remote,
28 | gpg3.init_motion_sensor
29 | ]
30 |
31 | count = 0
32 | for init_call in init_calls:
33 | count += 1
34 |
35 | # line follower raises an error if not connected
36 | try:
37 | sensor = init_call()
38 | except:
39 | sensor = None
40 | if sensor != None:
41 | print(count, sensor.use_mutex)
42 | assert(sensor.use_mutex == gpg3.use_mutex)
43 | else:
44 | print("skipped {}".format(count))
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_Basic_test.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_Basic_test.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_Light_Sensor.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_Light_Sensor.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_Loudness.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_Loudness.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_Ultrasonic_Servo.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_Ultrasonic_Servo.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_button_example.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_button_example.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_control_panel.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_control_panel.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_line_follower.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_line_follower.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/GoPiGo3_square.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/GoPiGo3_square.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/button_example.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/button_example.sb
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/GPG_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/GPG_small.png
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/arrow89.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/arrow89.png
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/dex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/dex.png
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/fast19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/fast19.png
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/light59.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/light59.png
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/off.png
--------------------------------------------------------------------------------
/Software/Scratch/Examples/icons/stop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/Examples/icons/stop.png
--------------------------------------------------------------------------------
/Software/Scratch/Local_Scratch_Start.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Encoding=UTF-8
3 | Version=1.0
4 | Type=Application
5 | Exec=xhost +
6 | Icon=scratch
7 | Exec=bash /home/pi/Dexter/GoPiGo3/Software/Scratch/start_local_scratch.sh
8 | Terminal=false
9 | Name=Scratch for GoPiGo3
10 | Comment= Programming system and content development tool
11 | Categories=Development;
12 | MimeType=application/x-scratch-project
13 |
--------------------------------------------------------------------------------
/Software/Scratch/gopigo3addons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/gopigo3addons.png
--------------------------------------------------------------------------------
/Software/Scratch/gopigo3commands.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/gopigo3commands.png
--------------------------------------------------------------------------------
/Software/Scratch/gopigo3deprecated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/gopigo3deprecated.png
--------------------------------------------------------------------------------
/Software/Scratch/gopigo3led.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/gopigo3led.png
--------------------------------------------------------------------------------
/Software/Scratch/gopigo3sensors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/gopigo3sensors.png
--------------------------------------------------------------------------------
/Software/Scratch/new.sb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/Software/Scratch/new.sb
--------------------------------------------------------------------------------
/Software/Scratch/start_local_scratch.sh:
--------------------------------------------------------------------------------
1 |
2 | echo "ensuring only one instance of GoPiGo3 Scratch Communicator"
3 | sudo pkill -f GoPiGo3Scratch.py
4 | sudo python2 /home/pi/Dexter/GoPiGo3/Software/Scratch/GoPiGo3Scratch.py &
5 |
6 | echo "starting Scratch"
7 | scratch /home/pi/Dexter/lib/Dexter/Scratch_GUI/new.sb
8 |
9 | echo "killing background process"
10 | sudo pkill -f GoPiGo3Scratch.py
11 | echo "background process killed"
12 |
--------------------------------------------------------------------------------
/Software/gopigo3_power.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # https://www.dexterindustries.com
4 | #
5 | # Copyright (c) 2017 Dexter Industries
6 | # Released under the MIT license (http://choosealicense.com/licenses/mit/).
7 | # For more information, see https://github.com/DexterInd/GoPiGo3/blob/master/LICENSE.md
8 | #
9 | # This code is for power management on a Raspberry Pi with GoPiGo3.
10 | #
11 | # GPIO 22 will be configured as input with pulldown. If pulled high, the RPi will halt.
12 | #
13 | # GPIO 23 needs to remain low impedance (output) set to a HIGH state. If GPIO 23 gets
14 | # left floating (high impedance) the GoPiGo3 assumes the RPi has shut down fully.
15 | # SW should never write GPIO 23 to LOW or set it as an INPUT.
16 |
17 |
18 | import RPi.GPIO as GPIO
19 | import time
20 | import os
21 |
22 | GPIO.setmode(GPIO.BCM)
23 | GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
24 |
25 | GPIO.setup(23, GPIO.OUT)
26 | GPIO.output(23, True)
27 |
28 | while True:
29 | if GPIO.input(22):
30 | os.system("shutdown now -h")
31 | time.sleep(0.1)
32 |
--------------------------------------------------------------------------------
/Troubleshooting/README.md:
--------------------------------------------------------------------------------
1 | To troubleshoot the GoPiGo3
2 | ----------------------------
3 |
4 | If the GoPiGo3 is not performing as expected, here are some things to try:
5 |
6 | * Run the troubleshooting script `all_tests.sh`. Look through the output to
7 | see if there's anything unexpected. If you don't find the problem, you can
8 | upload the `log.txt` file from the desktop (`/home/pi/Desktop/log.txt`) to
9 | the [forums] and ask for help (please give a clear description of the problem
10 | you're experiencing). You can run the troubleshooting script by running this:
11 |
12 | sudo bash /home/pi/Dexter/GoPiGo3/Troubleshooting/all_tests.sh
13 |
14 | [forums]: http://forum.dexterindustries.com/c/gopigo
15 |
--------------------------------------------------------------------------------
/Troubleshooting/all_tests.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | cd /home/pi/Dexter/GoPiGo3/Troubleshooting/
4 |
5 | echo "==============================="
6 | echo "GoPiGo3 Troubleshooting Script"
7 | echo "==============================="
8 |
9 | echo "GoPiGo3 Troubleshooting Script log" > log.txt
10 | sudo bash hardware_and_firmware_test.sh 2>&1| tee -a log.txt
11 |
12 | echo ""
13 | cp log.txt /home/pi/Desktop/log.txt
14 | echo "Log has been saved to Desktop. Please copy it and send it by email or upload it on the forums"
15 |
--------------------------------------------------------------------------------
/Troubleshooting/hardware_and_firmware_test.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 | echo ""
3 | echo "Checking for hardware, and checking hardware and firmware version."
4 | echo "=================================================================="
5 | sudo python /home/pi/Dexter/GoPiGo3/Software/Python/Examples/Read_Info.py
6 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = python -msphinx
7 | SPHINXPROJ = GoPiGo3
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
--------------------------------------------------------------------------------
/docs/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=python -msphinx
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 | set SPHINXPROJ=GoPiGo3
13 |
14 | if "%1" == "" goto help
15 |
16 | %SPHINXBUILD% >NUL 2>NUL
17 | if errorlevel 9009 (
18 | echo.
19 | echo.The Sphinx module was not found. Make sure you have Sphinx installed,
20 | echo.then set the SPHINXBUILD environment variable to point to the full
21 | echo.path of the 'sphinx-build' executable. Alternatively you may add the
22 | echo.Sphinx directory to PATH.
23 | echo.
24 | echo.If you don't have Sphinx installed, grab it from
25 | echo.http://sphinx-doc.org/
26 | exit /b 1
27 | )
28 |
29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30 | goto end
31 |
32 | :help
33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34 |
35 | :end
36 | popd
37 |
--------------------------------------------------------------------------------
/docs/source/about.rst:
--------------------------------------------------------------------------------
1 | .. _about-chapter:
2 |
3 | #############
4 | About GoPiGo3
5 | #############
6 |
7 | **************************
8 | Who are we and what we do.
9 | **************************
10 |
11 | .. image:: images/modular_robotics_logo.png
12 | :scale: 10
13 |
14 | `Modular Robotics`_ started as a spin-off from Carnegie Mellon University, where founder Eric Schweikardt invented Cubelets_ while working on a PhD. After years of research and development, Cubelets robot blocks were released to the public in 2010. Funding came from National Science Foundation grants and venture capital from the Foundry Group. This began our work of trying to make the world a better place with thousands and thousands of tiny robots.
15 | In 2019, we added to our product line when we acquired Dexter Industries, the original creators of the GoPiGo.
16 |
17 | ********************************
18 | What's this documentation about.
19 | ********************************
20 |
21 | This documentation is all about the `GoPiGo3`_ robot.
22 | Within this, you will find instructions on:
23 |
24 | * How to get started with the `GoPiGo3`_ robot - assembling, setting up the environment, etc.
25 | * How to get started with the example programs found in our repo.
26 | * How to operate the `GoPiGo3`_ with our API. The user has a comprehensive documentation of all the modules/functions/classes that are needed for controlling the robot.
27 | * How to troubleshoot the `GoPiGo3`_ in case of unsuspected situations.
28 |
29 | .. image:: images/gopigo3.jpg
30 |
31 | .. _gopigo3: https://gopigo.io/
32 | .. _Modular Robotics: https://www.modrobotics.com
33 | .. _Cubelets: https://www.modrobotics.com
34 |
--------------------------------------------------------------------------------
/docs/source/api-basic/easygopigo3.rst:
--------------------------------------------------------------------------------
1 | *************************************
2 | API - Library - EasyGoPiGo3
3 | *************************************
4 |
5 | =====================================
6 | EasyGoPiGo3
7 | =====================================
8 |
9 | .. autoclass:: easygopigo3.EasyGoPiGo3
10 | :members:
11 | :special-members:
12 | :show-inheritance:
13 |
14 | .. _gopigo3: https://gopigo.io/
15 | .. _assembling instructions: https://gopigo.io/getting-started/
16 | .. _connecting to robot: https://gopigo.io/pairing-gopigo-os/
17 | .. _Tutorials - Basic: tutorials-basic/index.html
18 | .. _shop: https://gopigo.io/shop/
19 | .. _distance sensor: https://gopigo.io/distance-sensor/
20 | .. _light & color sensor: https://gopigo.io/light-and-color-sensor/
21 | .. _grove loudness sensor: https://gopigo.io/grove-loudness-sensor/
22 | .. _grove buzzer: https://gopigo.io/grove-buzzer/
23 | .. _grove led: https://gopigo.io/grove-led-red/
24 | .. _grove button: https://gopigo.io/grove-button/
25 | .. _grove motion sensor: https://gopigo.io/grove-pir-motion-sensor/
26 | .. _servo: https://gopigo.io/servo-package/
27 | .. _line follower sensor: https://gopigo.io/line-follower-for-robots/
28 | .. _infrared receiver: https://gopigo.io/grove-infrared-receiver/
29 | .. _infrared remote: https://gopigo.io/remote-control/
30 | .. _raspbian for robots: https://sourceforge.net/projects/dexterindustriesraspbianflavor/
31 | .. _forum: http://forum.dexterindustries.com/categories
32 | .. _DI-Sensors: http://di-sensors.readthedocs.io
33 | .. _imu sensor: https://gopigo.io/imu-sensor/
34 | .. _temperature humidity pressure sensor: https://gopigo.io/thp-sensor/
35 | .. _Raspberry Pi camera: https://gopigo.io/raspberry-pi-camera/
36 | .. _DI-Sensors: http://di-sensors.readthedocs.io
--------------------------------------------------------------------------------
/docs/source/api-basic/index.rst:
--------------------------------------------------------------------------------
1 | .. _api-basic-chapter:
2 |
3 | #####################################
4 | API GoPiGo3 - Basic
5 | #####################################
6 |
7 | .. toctree::
8 | :maxdepth: 4
9 | :caption: Contents:
10 |
11 | structure
12 | easygopigo3
13 | sensors
14 | deprecated
15 |
16 | .. _gopigo3: https://gopigo.io/
17 | .. _assembling instructions: https://gopigo.io/getting-started/
18 | .. _connecting to robot: https://gopigo.io/pairing-gopigo-os/
19 | .. _Tutorials - Basic: tutorials-basic/index.html
20 | .. _shop: https://gopigo.io/shop/
21 | .. _distance sensor: https://gopigo.io/distance-sensor/
22 | .. _light & color sensor: https://gopigo.io/light-and-color-sensor/
23 | .. _grove loudness sensor: https://gopigo.io/grove-loudness-sensor/
24 | .. _grove buzzer: https://gopigo.io/grove-buzzer/
25 | .. _grove led: https://gopigo.io/grove-led-red/
26 | .. _grove button: https://gopigo.io/grove-button/
27 | .. _grove motion sensor: https://gopigo.io/grove-pir-motion-sensor/
28 | .. _servo: https://gopigo.io/servo-package/
29 | .. _line follower sensor: https://gopigo.io/line-follower-for-robots/
30 | .. _infrared receiver: https://gopigo.io/grove-infrared-receiver/
31 | .. _infrared remote: https://gopigo.io/remote-control/
32 | .. _raspbian for robots: https://sourceforge.net/projects/dexterindustriesraspbianflavor/
33 | .. _forum: http://forum.dexterindustries.com/categories
34 | .. _DI-Sensors: http://di-sensors.readthedocs.io
35 | .. _imu sensor: https://gopigo.io/imu-sensor/
36 | .. _temperature humidity pressure sensor: https://gopigo.io/thp-sensor/
37 | .. _Raspberry Pi camera: https://gopigo.io/raspberry-pi-camera/
38 | .. _DI-Sensors: http://di-sensors.readthedocs.io
--------------------------------------------------------------------------------
/docs/source/devguide.rst:
--------------------------------------------------------------------------------
1 | .. _devguide-chapter:
2 |
3 | #################
4 | Developer's Guide
5 | #################
6 |
7 |
8 | ..
9 | ************************
10 | Debugging a faulty board
11 | ************************
12 |
13 | ********************************
14 | Reflashing GoPiGo3
15 | ********************************
16 |
17 | ****************************************
18 | Custom libraries
19 | ****************************************
20 |
21 | *****************
22 | Our collaborators
23 | *****************
24 |
25 | The following collaborators are ordered alphabetically:
26 |
27 | * John Cole - `Github Account `__.
28 | * Matt Richardson - `Github Account `__.
29 | * Nicole Parrot - `Github Account `__.
30 | * Robert Lucian Chiriac - `Github Account `__.
31 | * Shoban Narayan - `Github account `__.
32 |
--------------------------------------------------------------------------------
/docs/source/faq.rst:
--------------------------------------------------------------------------------
1 | .. _faq-chapter:
2 |
3 | ##########################
4 | Frequently Asked Questions
5 | ##########################
6 |
7 | For more questions, please head over to our `forum`_.
8 |
9 | .. _forum: http://forum.dexterindustries.com/categories
10 |
--------------------------------------------------------------------------------
/docs/source/images/GoPiGo3-Bottom_annotated-768x565.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/GoPiGo3-Bottom_annotated-768x565.jpg
--------------------------------------------------------------------------------
/docs/source/images/GoPiGo3-Top-768x565.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/GoPiGo3-Top-768x565.jpg
--------------------------------------------------------------------------------
/docs/source/images/button.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/button.gif
--------------------------------------------------------------------------------
/docs/source/images/dexter-logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/dexter-logo.jpg
--------------------------------------------------------------------------------
/docs/source/images/dexter-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/dexter-logo.png
--------------------------------------------------------------------------------
/docs/source/images/dist_sensor.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/dist_sensor.gif
--------------------------------------------------------------------------------
/docs/source/images/driving1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/driving1.gif
--------------------------------------------------------------------------------
/docs/source/images/driving2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/driving2.gif
--------------------------------------------------------------------------------
/docs/source/images/driving3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/driving3.gif
--------------------------------------------------------------------------------
/docs/source/images/driving4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/driving4.gif
--------------------------------------------------------------------------------
/docs/source/images/driving5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/driving5.gif
--------------------------------------------------------------------------------
/docs/source/images/gopigo3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/gopigo3.jpg
--------------------------------------------------------------------------------
/docs/source/images/gpg3_and_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/gpg3_and_logo.jpg
--------------------------------------------------------------------------------
/docs/source/images/gpg3_ports.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/gpg3_ports.jpg
--------------------------------------------------------------------------------
/docs/source/images/gpg3_ports_clean.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/gpg3_ports_clean.jpg
--------------------------------------------------------------------------------
/docs/source/images/led.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/led.gif
--------------------------------------------------------------------------------
/docs/source/images/light_sensor.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/light_sensor.gif
--------------------------------------------------------------------------------
/docs/source/images/modular_robotics_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DexterInd/GoPiGo3/b50cfce3eced2b8d97132b1eef58cd3606ec1025/docs/source/images/modular_robotics_logo.png
--------------------------------------------------------------------------------
/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | .. GoPiGo3 documentation master file, created by
2 | sphinx-quickstart on Wed Jun 28 20:09:24 2017.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | ########################################
7 | Modular Robotics GoPiGo3 Documentation!
8 | ########################################
9 |
10 | .. image:: images/gpg3_and_logo.jpg
11 |
12 | .. toctree::
13 | :glob:
14 | :maxdepth: 2
15 | :numbered:
16 | :caption: Contents:
17 |
18 | about
19 | quickstart
20 |
21 | tutorials-basic/index
22 | tutorials-advanced/*
23 |
24 | api-basic/index
25 | api-advanced
26 |
27 | devguide
28 | faq
29 |
30 | Indices and tables
31 | ==================
32 |
33 | * :ref:`genindex`
34 | * :ref:`modindex`
35 | * :ref:`search`
36 |
--------------------------------------------------------------------------------
/docs/source/tutorials-advanced/tut-advanced.rst:
--------------------------------------------------------------------------------
1 | .. _tutorials-advanced-chapter:
2 |
3 | ####################
4 | Tutorials - Advanced
5 | ####################
6 |
7 | .. note::
8 |
9 | Coming soon!
10 |
--------------------------------------------------------------------------------
/docs/source/tutorials-basic/index.rst:
--------------------------------------------------------------------------------
1 | .. _tutorials-basic-chapter:
2 |
3 | #################
4 | Tutorials - Basic
5 | #################
6 |
7 | This chapter revolves around the :py:mod:`easygopigo3` module and just a bit around :py:mod:`di_sensors`.
8 |
9 | Please make sure you have followed all the instructions found in :ref:`Getting Started ` before jumping into tutorials.
10 | In all these tutorials, you will need:
11 |
12 | 1. A `GoPiGo3`_ robot.
13 | 2. A sensor/actuator if requested in the tutorial : i.e.: a `Grove Buzzer`_, a `Line Follower sensor`_, etc.
14 |
15 | .. toctree::
16 | :maxdepth: 1
17 | :caption: Contents:
18 |
19 | driving
20 | led
21 | button
22 | buzzer
23 | light_sensor
24 | distance_sensor
25 |
26 | .. _gopigo3: https://gopigo.io/
27 | .. _assembling instructions: https://gopigo.io/getting-started/
28 | .. _connecting to robot: https://gopigo.io/pairing-gopigo-os/
29 | .. _Tutorials - Basic: tutorials-basic/index.html
30 | .. _shop: https://gopigo.io/shop/
31 | .. _distance sensor: https://gopigo.io/distance-sensor/
32 | .. _light & color sensor: https://gopigo.io/light-and-color-sensor/
33 | .. _grove loudness sensor: https://gopigo.io/grove-loudness-sensor/
34 | .. _grove buzzer: https://gopigo.io/grove-buzzer/
35 | .. _grove led: https://gopigo.io/grove-led-red/
36 | .. _grove button: https://gopigo.io/grove-button/
37 | .. _grove motion sensor: https://gopigo.io/grove-pir-motion-sensor/
38 | .. _servo: https://gopigo.io/servo-package/
39 | .. _line follower sensor: https://gopigo.io/line-follower-for-robots/
40 | .. _infrared receiver: https://gopigo.io/grove-infrared-receiver/
41 | .. _infrared remote: https://gopigo.io/remote-control/
42 | .. _raspbian for robots: https://sourceforge.net/projects/dexterindustriesraspbianflavor/
43 | .. _forum: http://forum.dexterindustries.com/categories
44 | .. _DI-Sensors: http://di-sensors.readthedocs.io
45 | .. _imu sensor: https://gopigo.io/imu-sensor/
46 | .. _temperature humidity pressure sensor: https://gopigo.io/thp-sensor/
47 | .. _Raspberry Pi camera: https://gopigo.io/raspberry-pi-camera/
48 | .. _DI-Sensors: http://di-sensors.readthedocs.io
--------------------------------------------------------------------------------
/environment.yml:
--------------------------------------------------------------------------------
1 | name: readthedocs
2 | dependencies:
3 | - python=3
4 | - pip
5 | - graphviz
6 | - mock
7 | - six
8 | - sphinx==4.2.0
9 | - pip:
10 | - sphinx_rtd_theme==1.0.0
11 |
--------------------------------------------------------------------------------