micro-ROS / micro_ros_platformio

micro-ROS library for Platform.IO
Apache License 2.0
225 stars 80 forks source link

Stuck in rclc_support_init #158

Closed akvavit01 closed 1 month ago

akvavit01 commented 1 month ago

Issue template

Steps to reproduce the issue

Use this platformio.ini ''' ; PlatformIO Project Configuration File ; ; Build options: build flags, source filter ; Upload options: custom upload port, speed and extra flags ; Library options: dependencies, extra library storages ; Advanced options: extra scripting ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html

[env:esp32doit-devkit-v1] platform = espressif32 board = esp32doit-devkit-v1 framework = arduino lib_deps = waspinator/AccelStepper@^1.64 https://github.com/micro-ROS/micro_ros_platformio board_microros_distro = jazzy board_microros_transport = wifi monitor_speed = 115200 '''

Also, use this code, in main.cpp ''' // #include

include

include

// #include <mission_interfaces/msg/steps.h>

include <rcl/rcl.h>

include <rclc/executor.h>

include <rclc/rclc.h>

include <std_msgs/msg/int32.h>

/**

/**

// AccelStepper stepper(AccelStepper::DRIVER, 22, // 23);

rcl_allocator_t allocator; rclc_support_t support; rcl_node_t node; rclc_executor_t executor; rcl_subscription_t pos_cmd_sub;

std_msgsmsgInt32 pos_cmd_msg;

void PosCmdCallback(const void msg) { const std_msgsmsgInt32 pos_cmd_msg = (const std_msgsmsgInt32 *)msg;

char log_msg[60]{}; snprintf(log_msg, sizeof(log_msg), "Position command: %i", pos_cmd_msg->data); // logger::Log(logger::LogVerbosityLevel::kDebug, // log_msg); Serial.println(log_msg); }

void setup() { Serial.begin(115200); Serial.println( (char *)("Serial debug port ready!"));

// Set up LED uint8_t led_pin{2}; pinMode(led_pin, OUTPUT); digitalWrite(led_pin, HIGH);

delay(1000);

digitalWrite(led_pin, LOW);

delay(1000);

digitalWrite(led_pin, HIGH);

delay(1000);

// WiFi transport set_microros_wifi_transports( (char )("M2M-Network"), (char )("TritronikAJ9"), IPAddress(192, 168, 128, 72), 8888); Serial.println( (char *)("WiFi transport ready!!!"));

allocator = rcl_get_default_allocator();

// Create init options RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); Serial.println((char *)("Init options done!"));

// Create node RCCHECK(rclc_node_init_default( &node, "controller", "", &support)); Serial.println((char *)("Node ready!!!"));

// Create executor executor = rclc_executor_get_zero_initialized_executor(); RCCHECK(rclc_executor_init(&executor, &support.context, 6, &allocator)); Serial.println((char *)("Executor ready!!!"));

// Create position command subscriber RCCHECK(rclc_subscription_init_default( &pos_cmd_sub, &node, ROSIDL_GET_MSG_TYPE_SUPPORT(std_msgs, msg, Int32), "absolute_position_command"));

RCCHECK(rclc_executor_add_subscription( &executor, &pos_cmd_sub, &pos_cmd_msg, &PosCmdCallback, ON_NEW_DATA)); Serial.println((char *)("Subscriber ready!!!")); }

void loop() { RCSOFTCHECK(rclc_executor_spin_some( &executor, RCL_MS_TO_NS(100))); }

'''

Expected behavior

Code runs perfectly, able to subscribe to a topic.

Actual behavior

Stuck here image

It is crystal clear that somehow my code is stuck in rclc_support_init.

Additional information

Perhaps, is there a commit that changes the repo's behaviour?

hippo5329 commented 1 month ago

Please follow this wiki, https://github.com/hippo5329/micro_ros_arduino_examples_platformio/wiki#micro_ros_arduino_examples_platformio

akvavit01 commented 1 month ago

Wow, very comprehensive. Thanks Will update the results later

akvavit01 commented 1 month ago

It works, thanks Closing this issue then