Hi!
I use this docker image:
# Base l4t container with Jetpack 5.0
FROM nvcr.io/nvidia/l4t-base:r34.1.1
WORKDIR /usr/src/car/utils
ADD . /usr/src/car/utils
RUN apt-get update
RUN apt-get install -y python3-opencv && apt-get install -y python3-pip
RUN apt-get install -y python3-pip && pip3 install --upgrade pip
# Setting up Servo and DC Motor control
RUN pip3 install adafruit-circuitpython-servokit==1.3.8 Jetson.GPIO
And after running this code:
import Jetson.GPIO as GPIO
class DCMotor:
"""
Control DC Motor Jetson Nano
"""
def __init__(self):
self.dc = 0
GPIO.setmode(GPIO.TEGRA_SOC)
self._ENA = "GPIO_PE6"
self._IN1 = "DAP4_FS"
self._IN2 = "SPI2_MOSI"
GPIO.setup(self._ENA, GPIO.OUT, initial=GPIO.LOW)
self.pwm = GPIO.PWM(self._ENA, 120)
self.pwm.start(0)
GPIO.setup(self._IN1, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(self._IN2, GPIO.OUT, initial=GPIO.LOW)
def stop(self):
self.pwm.stop()
GPIO.output(self._IN1, GPIO.LOW)
GPIO.output(self._IN2, GPIO.LOW)
def forward(self, speed):
self._change_duty_cycle(speed)
GPIO.output(self._IN1, GPIO.HIGH)
GPIO.output(self._IN2, GPIO.LOW)
def backward(self, speed):
self._change_duty_cycle(speed)
GPIO.output(self._IN1, GPIO.LOW)
GPIO.output(self._IN2, GPIO.HIGH)
def _change_duty_cycle(self, dc):
if dc > 100:
dc = 100
elif dc < 60:
dc = 60
self.pwm.ChangeDutyCycle(dc)
self.dc = dc
I have this error: RuntimeError: The current user does not have permissions set to access the library functionalites. Please configure permissions or use the root user to run this
And after running this code:
import time
from adafruit_servokit import ServoKit
from adafruit_pca9685 import PCA9685
import board
import busio
class ServoMotor:
"""
Control ServoMotor Jetson Nano
"""
def __init__(self, channel):
self.angle = 0
i2c = busio.I2C(board.SCL, board.SDA)
self.channel = channel
self._pca = PCA9685(i2c)
self.motor = ServoKit(channels=16)
self._set_actuation_range(50)
self._set_pca_frequency(100)
self._set_pca_duty_cycle(0xffff)
def set_rotation_angle(self, angle):
self.motor.servo[self.channel].angle = angle
self.angle = angle
time.sleep(0.005)
def _set_pca_frequency(self, freq):
self._pca.frequency = freq
def _set_pca_duty_cycle(self, dc):
ch = self._pca.channels[self.channel]
ch.duty_cycle = dc
def _set_actuation_range(self, act_range):
self.motor.actuation_range = act_range
I have this error: RecursionError: maximum recursion depth exceeded while calling a Python object
Maybe u know how to fix this?