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

First debug log message after connecting to Agent has all-zeros timestamp #97

Open
gavanderhoorn opened this issue Jul 14, 2023 · 1 comment
Labels
bug Something isn't working yrc1000

Comments

@gavanderhoorn
Copy link
Collaborator

Minor, but the very first debug listener message received after MotoROS2 connects to the Agent has an all-zeros timestamp associated with it:

[2023-07-14 18:14:40.488481] [192.168.255.1:61992]: THU 1970-01-01 00:00:00.000 Found micro-ROS PC Agent

Everything before and after that is OK.

@gavanderhoorn gavanderhoorn added bug Something isn't working yrc1000 labels Jul 14, 2023
@gavanderhoorn
Copy link
Collaborator Author

I believe it's due to the conditional used:

motoros2/src/Debug.c

Lines 58 to 72 in f26d997

if (g_Ros_Communication_AgentIsConnected)
{
//get synchronized time from the agent
int64_t nanosecs = rmw_uros_epoch_nanos();
Ros_Nanos_To_Time_Msg(nanosecs, &debug_msg_timestamp);
strftime(timestamp, FORMATTED_TIME_SIZE, "%a %Y-%m-%d %H:%M:%S", localtime_r((const time_t*)&debug_msg_timestamp.sec, &synced_time));
snprintf(timestamp + strlen(timestamp), FORMATTED_TIME_SIZE - strlen(timestamp), ".%03d ", (int)debug_msg_timestamp.nanosec / 1000000);
}
else
{
//rmw_uros_epoch_nanos cannot sync with agent because it's not connected
gettimeofday(&tv, NULL);
strftime(timestamp, FORMATTED_TIME_SIZE, "%a %Y-%m-%d %H:%M:%S", localtime_r(&tv.tv_sec, &synced_time));
snprintf(timestamp + strlen(timestamp), FORMATTED_TIME_SIZE - strlen(timestamp), ".%03d ", tv.tv_usec / 1000);
}

this checks whether the Agent is connected (g_Ros_Communication_AgentIsConnected), but it's likely MotoROS2 hasn't had a chance yet to sync time with the Agent leading to rmw_uros_epoch_nanos() to still return 0.

Perhaps a fallback could be added to use clock_gettime(..) not just when the Agent hasn't connected yet, but also when rmw_uros_epoch_nanos() returns 0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working yrc1000
Projects
None yet
Development

No branches or pull requests

1 participant