Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micro-ros Ping utility issue #206

Open
apurva-peppermint opened this issue Aug 9, 2023 · 9 comments
Open

Micro-ros Ping utility issue #206

apurva-peppermint opened this issue Aug 9, 2023 · 9 comments

Comments

@apurva-peppermint
Copy link

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...

@pablogs9
Copy link
Member

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

@apurva-peppermint
Copy link
Author

apurva-peppermint commented Aug 10, 2023

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);
}

@pablogs9
Copy link
Member

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

@apurva-peppermint
Copy link
Author

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

@pablogs9
Copy link
Member

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

@apurva-peppermint
Copy link
Author

apurva-peppermint commented Aug 10, 2023

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

@pablogs9
Copy link
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?

@apurva-peppermint
Copy link
Author

I will check and let you know here

@apurva-peppermint
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants