Skip to content

Commit

Permalink
feat<servos> revert back to old pyvesc build from docker
Browse files Browse the repository at this point in the history
it turns out that the installation coded the current firmware of the vescs in pyvesc while installing it. I don't know how it would get the firmware of a connected USB before it even starts the pi to see what is connected to it. Instead of trying to adopt my solution to work with the new implementation of set Duty cycle, I decided to go back to the old solution. I tried to change and fetch the firmware from inside, but couldn't do it. I won't waste more time on it. Maybe i will return later for it
  • Loading branch information
Ahelsamahy committed Oct 10, 2024
1 parent 9573c9e commit 934aef0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pilot/pilot/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _config(self):
[parser.read(_f) for _f in glob.glob(os.path.join(self._config_dir, "*.ini"))]
config_data = {}

# Loop through all sections and store keys with section prefixes
# Loop through all sections and store keys
for section in parser.sections():
for key, value in parser.items(section):
config_data[f"{key}"] = value
Expand Down
8 changes: 7 additions & 1 deletion raspi/ras/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ RUN apt-get update && apt-get install -y \

# Upgrade pip and install Python dependencies
RUN pip install --upgrade pip setuptools wheel
RUN pip install --no-cache-dir pymodbus pyusb pytest crccheck RPi.GPIO pyvesc numpy six pyzmq cython pythoncrc pyserial gpiozero
RUN pip install --no-cache-dir pymodbus pyusb pytest crccheck RPi.GPIO numpy six pyzmq cython pythoncrc pyserial gpiozero

RUN git clone https://github.com/LiamBindle/PyVESC.git \
&& cd PyVESC \
&& sed -i 's/return f"{self.comm_fw_version}.{self.fw_version_major}.{self.fw_version_minor}"/return "{self.comm_fw_version}.{self.fw_version_major}.{self.fw_version_minor}"/' pyvesc/VESC/messages/getters.py \
&& python3 setup.py build \
&& python3 setup.py install

# Copy application files
COPY ./BYODR_utils/common/ /app/BYODR_utils/common/
Expand Down
8 changes: 4 additions & 4 deletions raspi/ras/core.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
import math
import threading

import pyvesc
import serial
from gpiozero import DigitalInputDevice
from pyvesc import GetValues, SetDutyCycle, SetRPM

from BYODR_utils.common import timestamp
from BYODR_utils.common.option import parse_option
from gpiozero import DigitalInputDevice
from pyvesc.VESC.messages import GetValues, SetDutyCycle, SetRPM

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -173,7 +173,7 @@ def set_effort(self, value):
if self._rpm_drive:
self._ser.write(pyvesc.encode(SetRPM(int(value * 1e3))))
else:
self._ser.write(pyvesc.encode(SetDutyCycle(int(value * 1e4))))
self._ser.write(pyvesc.encode(SetDutyCycle(float(value * 1e-1))))
except serial.serialutil.SerialException:
self._close()
_operational = False
Expand Down
4 changes: 3 additions & 1 deletion raspi/ras/servos.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def __init__(self, config_file):

self._setup_driver_configs()
self.update_drive_instances(self.driver_config)


self._relay.close()

def _setup_driver_configs(self):
Expand Down Expand Up @@ -224,7 +226,7 @@ def velocity(self):
return 0

def drive(self, steering, throttle):
logger.info(throttle)

_motor_scale = self._throttle_config.get("scale")
# Scale down throttle for one wheel, the other retains its value.
steering = min(1.0, max(-1.0, steering + self._steering_offset))
Expand Down

0 comments on commit 934aef0

Please sign in to comment.