diff --git a/Dockerfile.gazebo b/Dockerfile.gazebo index d281b69..0da3f75 100644 --- a/Dockerfile.gazebo +++ b/Dockerfile.gazebo @@ -104,9 +104,13 @@ RUN apt-get update && apt-get install -y \ rm -rf src && \ rm -rf /var/lib/apt/lists/* -COPY ros_entrypoint.sh / -COPY vulcanexus_entrypoint.sh / COPY healthcheck.sh / HEALTHCHECK --interval=5s --timeout=2s --start-period=5s --retries=4 \ CMD ["/healthcheck.sh"] + +RUN new_content1='source "/ros2_ws_healthcheck/install/setup.bash"' && \ + new_content2='gosu $USER bash -c "ros2 run healthcheck_pkg healthcheck_node &"' && \ + file=$(ls /*_entrypoint.sh | head -n 1) && \ + sed -i "/exec/i $new_content1" $file && \ + sed -i "/exec/i $new_content2" $file diff --git a/Dockerfile.hardware b/Dockerfile.hardware index 778ff04..398fb07 100644 --- a/Dockerfile.hardware +++ b/Dockerfile.hardware @@ -125,8 +125,6 @@ RUN apt-get update && apt-get install -y \ COPY --from=cpu_id_builder /read_cpu_id/.pio/build/olimex_e407/firmware.bin /firmware_read_cpu_id.bin -COPY ros_entrypoint.sh / -COPY vulcanexus_entrypoint.sh / COPY healthcheck.sh / COPY print-serial-number.py /usr/bin/ @@ -138,5 +136,6 @@ HEALTHCHECK --interval=5s --timeout=2s --start-period=10s --retries=6 \ RUN new_content1='source "/ros2_ws_healthcheck/install/setup.bash"' && \ new_content2='gosu $USER bash -c "ros2 run healthcheck_pkg healthcheck_node &"' && \ - sed -i "/exec/i $new_content1" /ros_entrypoint.sh && \ - sed -i "/exec/i $new_content2" /ros_entrypoint.sh + file=$(ls /*_entrypoint.sh | head -n 1) && \ + sed -i "/exec/i $new_content1" $file && \ + sed -i "/exec/i $new_content2" $file diff --git a/flash-firmware.py b/flash-firmware.py deleted file mode 100644 index 27c0f1b..0000000 --- a/flash-firmware.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/python3 - -import sh -import time -import sys -import argparse -from periphery import GPIO - - -class FirmwareFlasher: - def __init__(self, sys_arch, binary_file): - self.binary_file = binary_file - self.sys_arch = sys_arch - - self.max_approach_no = 3 - - print(f"System architecture: {self.sys_arch}") - - if self.sys_arch.stdout == b"armv7l\n": - # Setups ThinkerBoard pins - print("Device: ThinkerBoard\n") - self.port = "/dev/ttyS1" - boot0_pin_no = 164 - reset_pin_no = 184 - - elif self.sys_arch.stdout == b"x86_64\n": - # Setups UpBoard pins - print("Device: UpBoard\n") - self.port = "/dev/ttyS4" - boot0_pin_no = 17 - reset_pin_no = 18 - - elif self.sys_arch.stdout == b"aarch64\n": - # Setups RPi pins - print("Device: RPi\n") - self.port = "/dev/ttyAMA0" - boot0_pin_no = 17 - reset_pin_no = 18 - - else: - print("Unknown device...") - - self.boot0_pin = GPIO(boot0_pin_no, "out") - self.reset_pin = GPIO(reset_pin_no, "out") - - def enter_bootloader_mode(self): - self.boot0_pin.write(True) - self.reset_pin.write(True) - time.sleep(0.2) - self.reset_pin.write(False) - time.sleep(0.2) - - def exit_bootloader_mode(self): - self.boot0_pin.write(False) - self.reset_pin.write(True) - time.sleep(0.2) - self.reset_pin.write(False) - time.sleep(0.2) - - def try_flash_operation(self, operation_name, flash_command, flash_args): - for i in range(self.max_approach_no): - try: - flash_command(self.port, *flash_args, _out=sys.stdout) - time.sleep(0.2) - break - except Exception as e: - print(f"{operation_name} error! Trying again.") - print(f"Error: {e}") - print("---------------------------------------") - else: - print(f"WARNING! {operation_name} went wrong.") - - def flash_firmware(self): - self.enter_bootloader_mode() - - # Disable the flash write-protection - self.try_flash_operation("Write-UnProtection", sh.stm32flash, ["-u"]) - - # Disable the flash read-protection - self.try_flash_operation("Read-UnProtection", sh.stm32flash, ["-k"]) - - # Flashing the firmware - flash_args = ["-v", "-w", self.binary_file, "-b", "115200"] - self.try_flash_operation("Flashing", sh.stm32flash, flash_args) - - self.exit_bootloader_mode() - - -def main(): - parser = argparse.ArgumentParser( - description="Flashing the firmware on STM32 microcontroller in ROSbot" - ) - - parser.add_argument( - "file", - nargs="?", - default="/root/firmware.bin", - help="Path to a firmware file. Default = /root/firmware.bin", - ) - - binary_file = parser.parse_args().file - sys_arch = sh.uname("-m") - - flasher = FirmwareFlasher(sys_arch, binary_file) - flasher.flash_firmware() - print("Done!") - - -if __name__ == "__main__": - main() diff --git a/ros_entrypoint.sh b/ros_entrypoint.sh deleted file mode 100755 index bebe56c..0000000 --- a/ros_entrypoint.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -set -e - -output=$(husarnet-dds singleshot) || true -if [[ "$HUSARNET_DDS_DEBUG" == "TRUE" ]]; then - echo "$output" -fi - -# setup ros environment -source "/opt/ros/$ROS_DISTRO/setup.bash" -test -f "/ros2_ws/install/setup.bash" && source "/ros2_ws/install/setup.bash" - -if [ -z "$USER" ]; then - export USER=root -elif ! id "$USER" &>/dev/null; then - useradd -ms /bin/bash "$USER" -fi - -exec gosu $USER "$@" diff --git a/vulcanexus_entrypoint.sh b/vulcanexus_entrypoint.sh deleted file mode 100755 index a1d99ff..0000000 --- a/vulcanexus_entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -set -e - -output=$(husarnet-dds singleshot) || true -if [[ "$HUSARNET_DDS_DEBUG" == "TRUE" ]]; then - echo "$output" -fi - -# Check if XRCE_DOMAIN_ID_OVERRIDE is unset or empty -if [ -z "$XRCE_DOMAIN_ID_OVERRIDE" ]; then - # If ROS_DOMAIN_ID is set and not empty, set XRCE_DOMAIN_ID_OVERRIDE to its value - if [ -n "$ROS_DOMAIN_ID" ]; then - export XRCE_DOMAIN_ID_OVERRIDE="$ROS_DOMAIN_ID" - fi -fi - -# setup ros environment -source "/opt/vulcanexus/$ROS_DISTRO/setup.bash" -source "/ros2_ws/install/setup.bash" -source "/ros2_ws_healthcheck/install/setup.bash" - -ros2 run healthcheck_pkg healthcheck_node & - -exec "$@"