Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fbe3eae
Initial successful test of I2S mic and speaker modules. Installers to…
danic85 Jan 2, 2025
760f7ab
Added basic i2c servo control. Successful test
danic85 Jan 2, 2025
ea6d606
Clean up
danic85 Jan 2, 2025
e9c1d6d
Successful TFT display test script
danic85 Jan 3, 2025
0e5db49
Test servos
danic85 Jan 3, 2025
b45c2d2
MPU6050 test and sensor test
danic85 Jan 3, 2025
19f57c6
Ignore error
danic85 Jan 3, 2025
6a24b55
Merge branch 'main' of https://github.com/dmt-labs/modular-biped into…
danic85 Jan 6, 2025
a013aba
Re-add svg
danic85 Jan 6, 2025
1ebf764
Working speech recognition, GPT interpretation, and TTS output on CM5
danic85 Jan 27, 2025
0cc7dc4
Clear lock on audio devices before running. Tweak config to allow for…
danic85 Jan 27, 2025
cf51ec2
WIP, fixing other tts engine
danic85 Jan 27, 2025
a86e631
Cleanup
danic85 Jan 28, 2025
1cb35b7
Move logger to module
danic85 Jan 29, 2025
9f68256
Creation of messaging service class. Pubsub tested
danic85 Jan 29, 2025
bb68931
WIP mqtt support
danic85 Jan 29, 2025
6688462
Improved logging tool
danic85 Jan 30, 2025
0a1ed4c
Remove unused depdendencies
danic85 Jan 30, 2025
5a2632c
cleanup
danic85 Jan 30, 2025
3c2e442
Merge pull request #115 from makerforgetech/feature/messaging_service
danic85 Jan 30, 2025
ca44a04
`Merge branch 'develop' of https://github.com/dmt-labs/modular-biped …
danic85 Feb 22, 2025
00074c9
PR template
danic85 Mar 9, 2025
23d820a
Merge pull request #121 from makerforgetech/feature/pr_template
danic85 Mar 9, 2025
b395351
Created unit test framework
danic85 Mar 9, 2025
48ec1a2
Fix version issue
danic85 Mar 9, 2025
17b141f
Fix version issue
danic85 Mar 9, 2025
a0d31fa
Fix version issue
danic85 Mar 9, 2025
2e01c98
Fix version issue
danic85 Mar 9, 2025
fbdaa4b
Fix test workflow
danic85 Mar 9, 2025
3c44d36
Fix test workflow
danic85 Mar 9, 2025
90f50b9
Fix test workflow
danic85 Mar 9, 2025
4c55db6
Fix test workflow
danic85 Mar 9, 2025
6a3503b
Fix test workflow
danic85 Mar 9, 2025
13b7376
Fix test workflow
danic85 Mar 9, 2025
3bfc464
Fix test workflow
danic85 Mar 9, 2025
ccb1811
Fix test workflow
danic85 Mar 9, 2025
1f234ca
Fix test workflow
danic85 Mar 9, 2025
bf68be7
Fix test workflow
danic85 Mar 9, 2025
171d5d5
Fix test workflow
danic85 Mar 9, 2025
f632872
Fix test workflow
danic85 Mar 9, 2025
4d8b60b
Fix test workflow
danic85 Mar 9, 2025
772d20a
Fix test workflow
danic85 Mar 9, 2025
dd547a4
Fix test workflow
danic85 Mar 9, 2025
b8715cf
simplify
danic85 Mar 9, 2025
f78801e
Failure
danic85 Mar 9, 2025
aaa8024
Pass
danic85 Mar 9, 2025
5eb1866
Merge pull request #122 from makerforgetech/feature/tests
danic85 Mar 9, 2025
6fc0e72
Merge branch 'main' of https://github.com/dmt-labs/modular-biped into…
danic85 Mar 10, 2025
979a2e2
Unit tests
danic85 Mar 10, 2025
0eae2fc
Clean up and docs
danic85 Mar 11, 2025
6d6a138
fix test
danic85 Mar 11, 2025
db2f94b
fix test
danic85 Mar 11, 2025
6be4231
Rename
danic85 Mar 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- Thanks for submitting a new change request, please fill out the following template to help us review your PR. [Read the documentation on how to contribute to this project](https://github.com/makerforgetech/modular-biped/wiki/Contributing) BEFORE creating a PR! -->

## What type of change is this?
- [ ] New module
- [ ] Change to an existing module
- [ ] Core improvement
- [ ] Other (please describe)

## πŸ“ What does this change do?
<!-- Clearly and concisely describe the purpose of this PR. What feature, fix, or improvement does it add? -->

## ❓ Why is this change needed?
<!-- Explain the problem this solves or the motivation behind this change. -->

## πŸ› οΈ How was this implemented?
<!-- Summarize the approach, design decisions, and key changes made. -->

## πŸ§ͺ How was this tested?
<!-- Describe how you verified the behavior of your changes (e.g., unit tests, integration tests, manual testing). Has it been tested using the latest release of the project? If not, it will need to be tested before it is reviewed. -->

## πŸ’₯ Breaking changes
<!-- Does this change affect existing functionality or APIs? If so, explain what changes and how to mitigate them. -->
- [ ] Yes (please describe)
- [ ] No

## πŸ—‚ Related issues
<!-- Link any related issues (e.g., "Closes #123", "Fixes #456"). -->

## βœ… PR Checklist
- [ ] **Title & Description:** PR title and description are clear and complete.
- [ ] **Documentation:** PR links to idea in github discussion group containing complete documentation.
- [ ] **Scope & Size:** PR is focused on a single issue/feature and is a reasonable size.
- [ ] **Code Quality:** Code is clean, consistent, and follows the project style guide.
- [ ] **Tests:** Tests have been added/updated if needed.
- [ ] **Manual Testing:** Changes have been tested on the latest release of the project.
- [ ] **Self-Review:** I’ve reviewed my own code and ensured there are no obvious issues.

πŸš€ Thank you for your contribution to the project!
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python Unittest on PR

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
run-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Run unittests
run: |
python -m unittest discover -s tests -p 'test_*.py'

permissions:
pull-requests: write
contents: read
147 changes: 9 additions & 138 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,145 +14,16 @@ battery*.csv
timelapse/*
.coverage

.venv/
Adafruit_Blinka-8.28.0.dist-info/
Adafruit_PlatformDetect-3.57.0.dist-info/
Adafruit_PureIO-1.1.11.dist-info/
Adafruit_PureIO/
PIL/
Pillow-10.1.0.dist-info/
Pillow.libs/
PyYAML-6.0.1.dist-info/
Pypubsub-4.0.3.dist-info/
RPi.GPIO-0.7.1.dist-info/
RPi/
_distutils_hack/
_rpi_ws281x.cpython-311-aarch64-linux-gnu.so
_yaml/
adafruit_blinka/
adafruit_bus_device/
adafruit_circuitpython_busdevice-5.2.6.dist-info/
adafruit_circuitpython_pixelbuf-2.0.4.dist-info/
adafruit_circuitpython_requests-2.0.3.dist-info/
adafruit_circuitpython_seesaw-1.16.1.dist-info/
adafruit_circuitpython_typing-1.9.6.dist-info/
adafruit_pixelbuf.py
adafruit_platformdetect/
adafruit_requests.py
adafruit_seesaw/
analogio.py
bin/
bitbangio.py
board.py
busio.py
certifi-2023.11.17.dist-info/
certifi/
chardet-3.0.4.dist-info/
chardet/
circuitpython_typing/
click-8.1.7.dist-info/
click/
colorzero-2.0.dist-info/
colorzero/
colour-0.1.5.dist-info/
colour.py
# storing old dependencies that aren't used anymore
dependencies.bu

data/
digitalio.py
distutils-precedence.pth
google/
googleapis_common_protos-1.62.0.dist-info/
googleapis_common_protos-1.63.0.dist-info/
googletrans-3.1.0a0.dist-info/
googletrans/
gpiozero-2.0.dist-info/
gpiozero/
gpiozerocli/
grpclib-0.4.6.dist-info/
grpclib/
h11-0.9.0.dist-info/
h11/
h2-3.2.0.dist-info/
h2-4.1.0.dist-info/
h2/
hpack-3.0.0.dist-info/
hpack-4.0.0.dist-info/
hpack/
hstspreload-2023.1.1.dist-info/
hstspreload/
httpcore-0.9.1.dist-info/
httpcore/
httpx-0.13.3.dist-info/
httpx/
hyperframe-5.2.0.dist-info/
hyperframe-6.0.1.dist-info/
hyperframe/
idna-2.10.dist-info/
idna/
include/
joblib-1.3.2.dist-info/
joblib/
keypad.py
microcontroller/
micropython-stubs/
micropython.py
modular-biped-venv/
multidict-6.0.4.dist-info/
multidict-6.0.5.dist-info/
multidict/
neopixel_write.py
nltk-3.8.1.dist-info/
nltk/
numpy-1.26.2.dist-info/
numpy.libs/
numpy/
onewireio.py
pillow-10.2.0.dist-info/
pillow.libs/
pkg_resources/
protobuf-4.25.1.dist-info/
protobuf-4.25.3.dist-info/
pubsub/
pulseio.py
pwmio.py
pyftdi-0.55.0.dist-info/
pyftdi/
pygame-2.5.2.dist-info/
pygame.libs/
pygame/
pyserial-3.5.dist-info/
pyusb-1.2.1.dist-info/
rainbowio.py
regex-2023.10.3.dist-info/
regex/
rfc3986-1.5.0.dist-info/
rfc3986/
rpi_ws281x-5.0.0.dist-info/
rpi_ws281x/
run_viam.sh
schedule-1.2.1.dist-info/
schedule/
serial/
setenv.py
setuptools-69.0.2.dist-info/
setuptools/
sniffio-1.3.0.dist-info/
sniffio/
sysv_ipc-1.1.0.dist-info/
sysv_ipc.cpython-311-aarch64-linux-gnu.so
tqdm-4.66.1.dist-info/
tqdm/
typing_extensions-4.10.0.dist-info/
typing_extensions-4.9.0.dist-info/
typing_extensions.py
usb/
usb_hid.py
venv/
viam-config-example.json
/viam/
viam_sdk-0.12.0.dist-info/
viam_sdk-0.15.0.dist-info/
yaml/
myvenv/
.circleci/
.vscode
myenv

# installation flags and installed libraries
installers/i2s_mic_installed.flag
installers/i2s_speech_recognition_installed.flag

speech.wav
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The **Modular Bipedal Robot** project aims to educate and inspire individuals in
- TTS: Converts text to speech using the onboard speaker.
- Viam: Uses the VIAM API to integrate Viam modules for additional functionality.
- Vision: Handles image processing and computer vision tasks using the onboard IMX500 Raspberry Pi AI camera.
- Voice Recognition: Uses the Google Speech API to convert speech to text.
- [Read more](https://github.com/makerforgetech/modular-biped/wiki/Software#modules)!

## Project Background
Expand All @@ -41,3 +42,113 @@ The open source framework is designed for flexibility, allowing users to easily
- **Code**: Check out the modular open source software on [GitHub](https://github.com/makerforgetech/modular-biped)
- **YouTube Playlist**: Explore the development process through our build videos: [Watch on YouTube](https://www.youtube.com/watch?v=2DVJ5xxAuWY&list=PL_ua9QbuRTv6Kh8hiEXXVqywS8pklZraT)
- **Community**: Have a question or want to show off your build? Join the communities on [GitHub](https://bit.ly/maker-forge-community) and [Discord](https://bit.ly/makerforge-community)!


## A Note On Branches

The `main` branch is the latest stable release of the Modular Biped Robot project. This is compatible with the 'buddy' release, the latest supported release.

The `develop` branch is the development branch and may contain experimental features and changes that are not yet stable. Please use the `main` branch for the most stable experience. This will eventually become the next release, 'cody'. To facilitate testing modules are disabled by default in the `develop` branch. Enable each as needed in the config yaml files to test.

## Modules

The 'Cody' release includes a new BaseModule class that must be extended by all modules. This class provides a common interface for all modules to interact with the main robot controller. The BaseModule class includes a messaging_service object that references the main robot controller's messaging service. This object is used to send and receive messages between modules and the main robot controller.

Both `pypubsub` and `paho-mqtt` can be used to facilitate message passing between modules (mqtt support is not implemented yet). Which service is used can be set in the messaging_service configuration YAML file.

```yaml
messaging_service:
enabled: true
config:
protocol: 'pubsub' # 'mqtt' or 'pubsub'
mqtt_host: 'localhost'
mqtt_port: 1883
```

The introduction of mqtt allows distributed communication between modules, even across different devices.

The methods publish() and subscribe() can be utilised from within any module to send and receive messages to topics.

For example:

```python
class MyModule(BaseModule):
def __init__(self):
# Don't subscribe here
pass

def setup_messaging(self):
"""Subscribe to necessary topics."""
self.subscribe('my_topic', self.my_callback)

def my_callback(self, message):
print(f'Received message: {message}')
self.publish('my_response_topic', 'Hello from MyModule!')
self.log(level='info', message='MyModule received a message!')
```
Core and common topics include:
- `log` - Used for logging messages, accepts a string. or kwargs `type` (info by default) and `message`.
- `log/info` - Used for logging informational messages.
- `log/warning` - Used for logging warning messages.
- `log/error` - Used for logging error messages.
- `log/debug` - Used for logging debug messages.
- `log/critical` - Used for logging critical messages.
- `system/loop` - The main loop event. Subscribe to this for an action to trigger every loop.
- `system/loop/1` - Triggers a loop every second.
- `system/loop/10` - Triggers a loop every 10 seconds.
- `system/loop/60` - Triggers a loop every 60 seconds.
- `system/loop/exit` - Triggers a loop exit event.
- `system/temperature` - The current temperature of the Pi.
- `motion` - Output from the motion sensor, only triggered if motion is detected.
- `speech` - Input from speech recognition module converted to text.
- `tts` - Output to be spoken by the TTS module.
- `animate` - Output to be animated by the Animation module.
- `vision/detections` - Output from the Vision module, containing detected objects.
- `led` - Output to the Neopixel LED module.

## Logging

An upgraded log manager has been included in this version. This allows logs to be published either via the above messaging service, or directly to a 'log' method within the BaseModule class. The log manager can be configured in the `logwrapper.yaml` file.

```yaml
logwrapper:
enabled: true # Highly recommended to enable this module
path: modules.logwrapper.LogWrapper
config:
filename: app.log
log_level: 'debug' # debug, info, warning, error, critical
cli_level: 'info' # debug, info, warning, error, critical
dependencies:
python:
- pypubsub
```

Both the log level of the app.log file and the output to the CLI during runtime can be determined and defined separately. For any log level set, logs of a level equal to or above that level will be output. For example, if the log level is set to 'info', all logs of level 'info', 'warning', 'error', and 'critical' will be output.

Example usage:

```python
class MyModule(BaseModule):
def my_method(self):
self.log(level='info', message='MyModule has been initialised!')
self.log(f"Current value: {value}")
self.log(message=f"Current value is too high: {value}", level='critical')
```

In addition, for modules that extend BaseModule, the class, method and line number are prefixed to the message for output, making it easier to track down where the log was generated.

```
log/info: [Personality.random_neopixel_status:117] [Personality] Neopixel status triggered set to green
log/info: [PiTemperature.monitor:30] Temperature: 45.5Β°C
log/critical: [PiTemperature.monitor:28] Temperature is critical: 45.5Β°C
```

The app.log also includes timestamps and log levels for easy reference.

```
INFO: 01/30/2025 12:05:26 PM [Main] Loop started using pubsub protocol
INFO: 01/30/2025 12:05:27 PM [Personality.random_neopixel_status:117] [Personality] Neopixel status triggered set to green
INFO: 01/30/2025 12:05:27 PM [PiTemperature.monitor:30] Temperature: 42.2Β°C
INFO: 01/30/2025 12:05:28 PM [PiTemperature.monitor:30] Temperature: 42.2Β°C
INFO: 01/30/2025 12:05:28 PM [Main] Loop ended
```
4 changes: 4 additions & 0 deletions circuits/CM5 Modules.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 2 additions & 5 deletions config/animate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
animate:
enabled: true
path: modules.animate.Animate
dependencies:
python:
- pypubsub
enabled: false
path: modules.animate.Animate
5 changes: 1 addition & 4 deletions config/braillespeak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ braillespeak:
enabled: false
path: modules.audio.braillespeak.BrailleSpeak
config:
pin: 27
dependencies:
python:
- pypubsub
pin: 27
1 change: 0 additions & 1 deletion config/buzzer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ buzzer:
dependencies:
python:
- gpiozero
- pypubsub
5 changes: 4 additions & 1 deletion config/chatgpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ chatgpt:
path: 'modules.chatgpt.ChatGPT'
config:
model: gpt-4o-mini
persona: "You are a helpful assistant robot. You respond with short phrases where possible.
Alternatively, you can respond with the following commands instead of text if you feel they are appropriate:
- animate:head_nod
- animate:head_shake"
dependencies:
python:
- openai
- pypubsub
additional:
- https://platform.openai.com/api-keys
Loading