welcom ! Handel home

2025年4月18日 星期五

freertos ESP32 micro-ROS code

 

# ROS2 建立專案目錄 以colcon build 編譯建立 bash

$mkdir -p ~/firmware_esp32_ws/src $cd ~/firmware_esp32_ws $git clone https://github.com/micro-ROS/micro_ros_setup src/micro_ros_setup $rosdep update
$sudo apt install flex $rosdep install --from-path src --ignore-src -y $source /opt/ros/humble/setup.bash
$colcon build $source install/local_setup.bash

#建立 micro ROS firmware code 當你執行指令:

bash
$ros2 run micro_ros_setup create_firmware_ws.sh freertos esp32

[micor ros firmware 支援平台]
Available platforms: . android +-- generic . freertos +-- crazyflie21 +-- esp32 +-- nucleo_f446re +-- nucleo_f446ze +-- nucleo_f746zg +-- nucleo_f767zi +-- olimex-stm32-e407 . generate_lib +-- generic . host +-- generic . raspbian +-- stretch_v8 +-- buster_v7 +-- buster_v8 . zephyr +-- discovery_l475_iot1 +-- olimex-stm32-e407 +-- nucleo_f401re +-- nucleo_h743zi +-- nucleo_f746zg


🔧 後續步驟(成功建立後)

  1. 建立 firmware workspace 成功後,會有結構如下:

  2. firmware/ ├── apps/ ├── esp-idf/ ├── mcu_ws/ │ ├── src/ │ └── install/ ├── CMakeLists.txt ├── sdkconfig

  3. 編譯韌體
ros2 run micro_ros_setup build_firmware.sh


  1. 燒錄 ESP32(設定 USB 埠):

bash
export MICROROS_FIRMWARE_SERIAL_DEVICE=/dev/ttyUSB0 ros2 run micro_ros_setup flash_firmware.sh

  1. 啟動 Agent

bash
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0

🎯 小提醒:使用 ESP32 S3?

若你用的是 ESP32-S3,建議你:

bash
export IDF_TARGET=esp32s3

並修改 sdkconfigmenuconfig 中 UART 設定與 flash size。


沒有留言: