正如标题所暗示的,我在将扩展上传到 BlueOS 时遇到了问题,并且收到一条错误消息,提示扩展已启用但容器未运行。
当我检查控制台日志时,它还说它正在不断尝试重新连接。
我已成功上传一个扩展程序来读取蓝色机器人 bar30 传感器的数据,并且没有遇到此错误。
我对 git 和 docker 等软件开发工具还很陌生,所以请告诉我我所写的内容是否有助于获得更好的诊断。
正如标题所暗示的,我在将扩展上传到 BlueOS 时遇到了问题,并且收到一条错误消息,提示扩展已启用但容器未运行。
当我检查控制台日志时,它还说它正在不断尝试重新连接。
我已成功上传一个扩展程序来读取蓝色机器人 bar30 传感器的数据,并且没有遇到此错误。
我对 git 和 docker 等软件开发工具还很陌生,所以请告诉我我所写的内容是否有助于获得更好的诊断。
你好,欢迎来到论坛!
扩展程序似乎无法启动,“查看日志”按钮显示什么了吗?
这个扩展程序的目标是什么?如果它尝试使用PWM执行操作,可能会与现有进程发生冲突?
如果您能分享这个扩展程序的GitHub日志,我很乐意看看……
查看日志打开后什么也不显示。我想制作一个简单的 pwm 扫描器并尝试将其连接到我手头的 T200 电机来尝试扩展开发。
name: Deploy t200 Extension Image
on:
workflow_dispatch:
jobs:
deploy-docker-image:
runs-on: ubuntu-latest
steps:
- name: Deploy BlueOS Extension
uses: BlueOS-community/Deploy-BlueOS-Extension@v1
with:
docker-username: ${{ secrets.DOCKER_USERNAME }}
docker-password: ${{ secrets.DOCKER_PASSWORD }}
github-token: ${{ secrets.GITHUB_TOKEN }}
image-name: 't200-pwm-extension' # no username, just the image name
image-prefix: 'blueos-' # optional; defaults to blueos-
dockerfile-location: 't200-pwm-extension' # where your Dockerfile is
author: ${{ vars.MY_NAME }}
author-email: ${{ vars.MY_EMAIL }}
maintainer: ${{ vars.ORG_NAME }}
maintainer-email: ${{ vars.ORG_EMAIL }}
build-platforms: linux/arm64,linux/amd64```
import time
from lib.pwm import NavigatorPWM
if __name__ == "__main__":
thruster = NavigatorPWM(channel=1) # Use SERVO1
try:
thruster.arm()
print("Starting PWM sweep...")
direction = 1 # +1 for up, -1 for down
pwm = 1100 # Start at minimum pulse width
step = 1 # µs step size
delay = 0.01 # Delay between steps (adjust to control speed)
while True:
thruster.set_pwm(pwm)
print(pwm)
time.sleep(delay)
pwm += direction * step
if pwm >= 1900:
pwm = 1900
direction = -1 # Reverse direction
elif pwm <= 1100:
pwm = 1100
direction = 1 # Forward direction
except KeyboardInterrupt:
print("Interrupted! Stopping thruster.")
thruster.stop()
FROM python:3.12.4-slim-bullseye
RUN apt update
RUN pip install --no-cache-dir --upgrade pip
COPY t200-pwm-extension/app /app
COPY t200-pwm-extension/lib /lib
ENV PYTHONPATH="${PYTHONPATH}:/lib"
LABEL version="0.0.1"
LABEL permissions='\
{\
"Tty": true,\
"ExposedPorts": {\
"80/tcp": {}\
},\
"HostConfig": {\
"PortBindings": {\
"80/tcp": [\
{\
"HostPort": ""\
}\
]\
},\
"Privileged": true,\
"Binds": [\
"/root/.config:/root/.config",\
"/sys/class/rc_output:/sys/class/rc_output"\
]\
}\
}'
LABEL authors='[\
{\
"name": "Duncan Ford",\
"email": "your@email.com"\
}\
]'
LABEL company='{\
"about": "",\
"name": "Offshore Designs",\
"email": "offshoredesigns@example.com"\
}'
LABEL type="example"
LABEL tags='[ "thruster", "navigator", "pwm" ]'
LABEL readme=''
LABEL links='{}'
LABEL requirements="core >= 1.1"
CMD python app/app.py
import time
import os
class NavigatorPWM:
def __init__(self, channel=1):
self.channel = channel
self.path = f"/sys/class/rc_output/rc_output{channel}"
self._ensure_enabled()
def _ensure_enabled(self):
# Enable output on the channel if it isn't already
enable_path = f"{self.path}/enabled"
with open(enable_path, 'w') as f:
f.write("1")
def set_pwm(self, pulse_us):
"""
Sets PWM pulse width in microseconds.
Typical ESC range: 1100 (min) to 1900 (max), 1500 = neutral
"""
pwm_path = f"{self.path}/pwm"
with open(pwm_path, 'w') as f:
f.write(str(int(pulse_us)))
def arm(self):
print("Sending neutral signal to arm ESC...")
self.set_pwm(1500)
time.sleep(2)
def stop(self):
print("Stopping (neutral signal)")
self.set_pwm(1500)
def set_throttle(self, value):
"""
Set throttle between -1.0 (full reverse) and 1.0 (full forward).
Maps to 1100µs – 1900µs.
"""
value = max(-1.0, min(1.0, value))
pwm_us = 1500 + (400 * value)
self.set_pwm(pwm_us)