micro-ROS / micro-ROS/micro_ros_arduino

Failing to compile on ESP32

Open
#2,040 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
576
Forks
146
PR merge metrics
No merged PRs in 30d

Description

Hello, I'm trying to compile this simple code:
```
#include
#include
#include
#include
#include
#include
#include
#include

HardwareSerial TMCSerial(1);
TMC2209Stepper driver(&TMCSerial, 0.11f, 0b00);

FastAccelStepperEngine engine = FastAccelStepperEngine();
FastAccelStepper *stepper = NULL;

rcl_node_t node;
rclc_support_t support;
rcl_allocator_t allocator;
rclc_executor_t executor;
rcl_subscription_t subscriber;
std_msgs__msg__Float32 msg;

void setup(){
Serial.begin(115200);
pinMode(5, INPUT);

TMCSerial.begin(115200, SERIAL_8N1, 7, 6);
driver.begin();
driver.toff(4);
driver.blank_time(24);
driver.pdn_disable(true);
driver.I_scale_analog(false);
driver.en_spreadCycle(false);
driver.pwm_autoscale(true);
driver.rms_current(300);
driver.microsteps(16);
driver.TCOOLTHRS(0xFFFFF);
driver.SGTHRS(50);

engine.init();
stepper = engine.stepperConnectToPin(3);
stepper->setDirectionPin(2);
stepper->setEnablePin(4, true);
stepper->setAutoEnable(true);
stepper->setSpeedInHz(500);
stepper->setAcceleration(1500);

set_microros_wifi_transports("[my SSID]", "[my password]", "[my IP]", 8888);
allocator = rcl_get_default_allocator();
rclc_support_init(&support, 0, NULL, &allocator);
rclc_node_init_default(&node, "kitchen_dock_node", "", &support);
rclc_subscription_init_default(&subscriber, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Float32), "/kitchen_dock_cmd");
rclc_executor_init(&executor, &support.context, 1, &allocator);
rclc_executor_add_subscription(&executor, &subscriber, &msg, &command_callback, ON_NEW_DATA);
home();
}

void home(){
stepper->runBackward();
while(digitalRead(5) == LOW){
delay(20);
}
stepper->forceStop();
stepper->setCurrentPosition(0);
}

void command_callback(const void *msgin){
const std_msgs__msg__Float32 *cmd = (const std_msgs__msg__Float32 *)msgin;
float target_pos_mm = cmd->data;
int32_t target_steps = (int32_t)round(target_pos_mm * 320 / 9);
stepper->moveTo(target_steps);
}

void loop(){
rclc_executor_spin_some(&executor, RCL_MS_TO_NS(10));
}
```

But I get this:
```
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ignac\AppData\Local\arduino\sketches\896175D8851AC4286E084BD053A572EB\sketch\Robot_kitchen_dock_ESP32.ino.cpp.o: in function `micro_ros_agent_locator::micro_ros_agent_locator()':
c:\Users\ignac\OneDrive\Escritorio\Arduino\libraries\micro_ros_arduino\src/micro_ros_arduino.h:116:(.text._Z5setupv+0x1e6): undefined reference to `rmw_uros_set_custom_transport'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ignac\AppData\Local\arduino\sketches\896175D8851AC4286E084BD053A572EB\sketch\Robot_kitchen_dock_ESP32.ino.cpp.o: in function `setup()':
c:\Users\ignac\OneDrive\Escritorio\Arduino\libraries\micro_ros_arduino\src/micro_ros_arduino.h:127:(.text._Z5setupv+0x1f0): undefined reference to `rcutils_get_default_allocator'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ignac\AppData\Local\arduino\sketches\896175D8851AC4286E084BD053A572EB\sketch\Robot_kitchen_dock_ESP32.ino.cpp.o: in function `set_microros_wifi_transports':
c:\Users\ignac\OneDrive\Escritorio\Arduino\libraries\micro_ros_arduino\src/micro_ros_arduino.h:130:(.text._Z5setupv+0x21c): undefined reference to `rclc_support_init'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: c:\Users\ignac\OneDrive\Escritorio\Arduino\libraries\micro_ros_arduino\src/micro_ros_arduino.h:134:(.text._Z5setupv+0x240): undefined reference to `rclc_node_init_default'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: c:\Users\ignac\OneDrive\Escritorio\Arduino\libraries\micro_ros_arduino\src/micro_ros_arduino.h:134:(.text._Z5setupv+0x248): undefined reference to `rosidl_typesupport_c__get_message_type_support_handle__std_msgs__msg__Float32'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: c:\Users\ignac\OneDrive\Escritorio\Arduino\libraries\micro_ros_arduino\src/micro_ros_arduino.h:134:(.text._Z5setupv+0x266): undefined reference to `rclc_subscription_init_default'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ignac\AppData\Local\arduino\sketches\896175D8851AC4286E084BD053A572EB\sketch\Robot_kitchen_dock_ESP32.ino.cpp.o: in function `setup()':
C:\Users\ignac\OneDrive\Escritorio\Arduino\Projects\Robot_kitchen_dock_ESP32/Robot_kitchen_dock_ESP32.ino:49:(.text._Z5setupv+0x280): undefined reference to `rclc_executor_init'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ignac\OneDrive\Escritorio\Arduino\Projects\Robot_kitchen_dock_ESP32/Robot_kitchen_dock_ESP32.ino:50:(.text._Z5setupv+0x2a2): undefined reference to `rclc_executor_add_subscription'
C:/Users/ignac/AppData/Local/Arduino15/packages/esp32/tools/esp-rv32/2511/bin/../lib/gcc/riscv32-esp-elf/14.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ignac\AppData\Local\arduino\sketches\896175D8851AC4286E084BD053A572EB\sketch\Robot_kitchen_dock_ESP32.ino.cpp.o: in function `loop()':
C:\Users\ignac\OneDrive\Escritorio\Arduino\Projects\Robot_kitchen_dock_ESP32/Robot_kitchen_dock_ESP32.ino:52:(.text._Z4loopv+0x12): undefined reference to `rclc_executor_spin_some'
collect2.exe: error: ld returned 1 exit status
```

I'm using an ESP32-C3 SuperMini and the Humble 2.0.7 version of micro_ros_arduino from the library manager. I've tried downgrading the ESP32 core (to 2.0.17) in case some update broke this but no dice.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with micro_ros_arduino/src/micro_ros_arduino.h and the ESP32-C3 Arduino build that produces these undefined references. Reproduce the supplied sketch with micro_ros_arduino Humble 2.0.7 and compare the result with the reported ESP32 core versions; done means the sketch links successfully with the required micro-ROS symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
build-system, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.