Skip to content

Micro-ros Ping utility issue #206

Open

Description

@apurva-peppermint

Issue template

  • Hardware description: esp32s3 devkit
  • RTOS: freertos
  • Installation type: standard
  • Version or commit hash: humble

Steps to reproduce the issue

try the rmw_uros_ping_agent() utility to see whether the Agent is up or not it does not require creating a micro-ros context first...

Expected behavior

When I turn the Agent on it should output as RMW_RET_OK else it should throw an error value

Actual behavior

Screenshot from 2023-08-09 16-09-54
There is a variable called agent_state_flag in the code which gives 0 when agent is off and 1 when agent is on...

Screenshot from 2023-08-09 16-10-13
Here I have not started the agent yet

Screenshot from 2023-08-09 16-10-38
Here I have started the agent

Screenshot from 2023-08-09 16-09-54
Still it the rmw_uros_ping_agent() is not giving me a RMW_RET_OK even when the agent is alive

Additional information

Screenshot from 2023-08-09 16-11-22
The code snippet which I am using...

Activity

  1. pablogs9 commented on Aug 10, 2023

    @pablogs9
    Member

    Hello @apurva-peppermint please provide code for replicating this.

  2. apurva-peppermint commented on Aug 10, 2023

    @apurva-peppermint
    Author

    Hey @pablogs9 I'm using this code for the agent liveliness testing...

    #include <string.h>
    #include <stdio.h>
    #include <unistd.h>
    
    #include "freertos/FreeRTOS.h"
    #include "freertos/task.h"
    #include "esp_log.h"
    #include "esp_system.h"
    #include "driver/gpio.h"
    #include "freertos/queue.h"
    #include "driver/uart.h"
    
    #include <uros_network_interfaces.h>
    #include <rcl/rcl.h>
    #include <rcl/error_handling.h>
    // #include <std_msgs/msg/int32.h>
    #include <std_msgs/msg/float32.h>
    #include <rclc/rclc.h>
    #include <rclc/executor.h>
    
    #ifdef CONFIG_MICRO_ROS_ESP_XRCE_DDS_MIDDLEWARE
    #include <rmw_microros/rmw_microros.h>
    #endif
    
    #define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Aborting.\n",__LINE__,(int)temp_rc);vTaskDelete(NULL);}}
    #define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){printf("Failed status on line %d: %d. Continuing.\n",__LINE__,(int)temp_rc);}}
    
    int agent_state_flag = 0;
    
    void agent_notifier(void *arg)
    {
    	while(1)
    	{
    		if(rmw_uros_ping_agent(100, 1) == RMW_RET_OK)
    		{
    			agent_state_flag = 1;
    			printf("agent_state_flag = %d\n", agent_state_flag);
    		}
    		else
    		{
    			agent_state_flag = 0;
    			printf("agent_state_flag = %d\n", agent_state_flag);
    		}
    	}		
    }
    
    void app_main(void)
    {
    #if defined(CONFIG_MICRO_ROS_ESP_NETIF_WLAN) || defined(CONFIG_MICRO_ROS_ESP_NETIF_ENET)
        ESP_ERROR_CHECK(uros_network_interface_initialize());
    #endif
    
         xTaskCreate(agent_notifier,
         			"agent_notifier_task",
         			1024 * 4,
         			NULL,
         			CONFIG_MICRO_ROS_APP_TASK_PRIO ,
        			NULL);
    }
  3. pablogs9 commented on Aug 10, 2023

    @pablogs9
    Member

    Please paste here the output of the micro-ROS Agent using the flag -v6 to increase verbosity.

  4. apurva-peppermint commented on Aug 10, 2023

    @apurva-peppermint
    Author

    Screenshot from 2023-08-10 14-51-35

  5. pablogs9 commented on Aug 10, 2023

    @pablogs9
    Member

    If you use a normal micro-ROS example (publisher for example), does it works?

  6. apurva-peppermint commented on Aug 10, 2023

    @apurva-peppermint
    Author

    I have not tried that yet. So I want the client to start the context only when it detects that an agent has started or has become alive again. This ping function works when I first start the Agent and then my client with all the initializations and running the executor. but if I try pinging the agent before creating anything as I have written in the code it does not work

  7. pablogs9 commented on Aug 10, 2023

    @pablogs9
    Member

    Probable dealing with an agent pinging on a non-initialized session can be weird due to the fact that it will try to open/close sockets...In your example, does the board send any UDP packet to multicast or to the agent IP address?

  8. apurva-peppermint commented on Aug 10, 2023

    @apurva-peppermint
    Author

    I will check and let you know here

  9. apurva-peppermint commented on Aug 10, 2023

    @apurva-peppermint
    Author

    hey @pablogs9 I just checked it and the board does not send any kind of UDP packet to the agents IP address. It only sends a packet when a micro ros session is on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions