micro-ROS / micro_ros_renesas_demos

Demo code for Renesas e2 studio
Apache License 2.0
4 stars 5 forks source link

Timeout for rclc_support_init() #74

Closed gsokoll closed 1 year ago

gsokoll commented 2 years ago

Issue template

Steps to reproduce the issue

I have been running some of the micro ros renesas demo apps on an EV-RA6M5 board. I have had issues where it seems that the rclc_support_init() call early in the microros_app function does not timeout and return an error code when a micro ros agent is not running.

Expected behavior

Typical sample code from microros_app.c (I have added the green LED lines before and after rclc_support_init to provide a visual indication of whether the function had returned or not, but otherwise this code is straight from the demo apps). Documentation for rclc_support_init() suggests it should return either a success code or error code, but it seems in mosst cases if an agent is not running, it does not timeout and hence never returns at all.

void microros_app(void)
{
    rcl_allocator_t allocator = rcl_get_default_allocator();

    set_led_status(LED_GREEN, true);
    //create init_options
    rclc_support_t support;
    rclc_support_init(&support, 0, NULL, &allocator);
    set_led_status(LED_GREEN, false);
    .....
}

Actual behavior

I have tested the following demo apps, with the results as shown:

I have seen a few other posts which might be related: https://github.com/micro-ROS/micro_ros_arduino/issues/40 https://github.com/micro-ROS/micro_ros_zephyr_module/issues/62 (says problem goes away with Humble) https://github.com/micro-ROS/micro_ros_arduino/issues/989

The last one suggests (at least on the Arduino version) that rclc_support_init() will attempt to reconnect for a certain number of times and with a certain timeout, but this doesn't seem to be true for the Renesas board.

Is this expected behaviour? Is there an option to force a timeout value?

Acuadros95 commented 2 years ago

The last one suggests (at least on the Arduino version) that rclc_support_init() will attempt to reconnect for a certain number of times and with a certain timeout, but this doesn't seem to be true for the Renesas board.

That is the expected behavior, let me check this.

gsokoll commented 2 years ago

Thanks. It would be much preferable to return immediately with either success or error codes. Blocking indefinitely is not helpful!

Acuadros95 commented 2 years ago

You were right, if the interface was not available rclc_support_init would wait forever.

This PR shall fix this for all demos except micro_ros_udp_freertos and micro_ros_udp_threadX:https://github.com/micro-ROS/micro_ros_renesas2estudio_component/pull/56

On those network transports the problem will persist if the Ethernet link cannot be established, as the RTOS will wait forever on its network stack initialization.

We will handle this problem on a future FSP upgrade, on the meantime you can always check the ETH link before initializing micro-ROS.

dhanuzch commented 2 years ago

Hi! Hardware: EK-RA6M5 Demo App: micro_ros_udp_freertos and micro_ros_udp_threadX ROS2 version: Humble

Problem: Serial transport is working fine. But UDP and TCP doesn't.

Physical Setup: I have connected my PC and EK-RA6M5 board to a router. Am I doing it right? If I am wrong, can you help me set-up the hardware for UDP/TCP.

on the meantime you can always check the ETH link before initializing micro-ROS.

Doubt 1: How to ensure that the ETH Link is established before initializing micro-ROS. I tried ethtool <eth?> and it says Link is detected. Is this a right way to determine the ETH Link?

Doubt 2: I'm running the demo with default board config. Is there any physical changes (such as changing jumper config) needed?

Doubt 3: Is the problem only in ROS humble. Or is it Independent of ROS version and more of an issue with the FSP?

Doubt 4: In continuation to doubt 3, If it is a problem with ROS2 humble. It should work with other versions, right? I tried it. And it doesn't seem to work.

Thanks.

Acuadros95 commented 2 years ago

Physical Setup: I have connected my PC and EK-RA6M5 board to a router. Am I doing it right? If I am wrong, can you help me set-up the hardware for UDP/TCP.

Did you modify the expected Agent IP and port (here)? Can you use a network analyzer (as wireshark) to check if the board is actually sending packets?

Also, the TCP demo targets the wifi external module, check here for more details on the available transports and how to configure them: micro-ROS transports for Renesas e2 studio

dhanuzch commented 2 years ago

Thanks a lot @Acuadros95. It was an amateur mistake. Didn't configure the Agent IP properly.

pablogs9 commented 1 year ago

Solved, closing