#include <HardwareSerial.h>
#include <TMCStepper.h>
#include <FastAccelStepper.h>
#include <micro_ros_arduino.h>
#include <rcl/rcl.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>
#include <std_msgs/msg/float32.h>
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));
}
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.
Hello, I'm trying to compile this simple code:
But I get this:
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.