Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.

[WIP] Synchronize time with Jetson using UDP #63

Open
wants to merge 7 commits into
base: development
Choose a base branch
from

Conversation

snowsignal
Copy link
Contributor

This is still a work in progress, but I'm making a PR now to get some early feedback on this. This fixes issue #61.

@sertbot
Copy link

sertbot bot commented Aug 23, 2018

Hi @JacksonCoder, thanks for opening this pull request!

Looks like this is an addition or fix for the robot. To make sure this change goes added in smoothly, make sure the following chores are complete (please check-off items as they are completed):

  • Test code changes on the robot (if possible).

  • Verify that significant changes have tests and pass successfully.

  • Ensure this pull request is appropriately titled.

Maintainers – please review this PR. A review from the @SouthEugeneRoboticsTeam/reviewers team is required before the PR can be merged.

Finally, use @sertbot merge to merge this PR into the appropriate branch.

Thanks!

Copy link
Member

@andrewda andrewda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you looked into broadcast messages? That will likely make our jobs a heck of a lot easier because we won't have to make the Jetson a static IP.

}

// Extract seconds from an epoch number
private fun epoch_secs(epoch: Long): Long {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything should be camelCase

}

// Extract milliseconds from the epoch number
private fun epoch_millis(epoch: Long): Long {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

// UDP port
private const val PORT: Int = 2521
// Change this to the Jetson's IP before deploying
private const val JETSON_IP = "127.0.0.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should all be constants set in the constants.kt file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except WAIT_PERIOD, which should stay here.


object TimeSync : Thread() {
// Time (in secs) to wait between syncs
private const val WAIT_PERIOD: Long = 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do this in milliseconds, will make everything easier.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also no need to specify the type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we do need to specify this as Long, otherwise it gets inferred as an Int.

// Time (in secs) to wait between syncs
private const val WAIT_PERIOD: Long = 5
// UDP port
private const val PORT: Int = 2521
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to specify the type

@andrewda andrewda changed the title Synchronize time with Jetson using UDP (Fixes #61) [WIP] [WIP] Synchronize time with Jetson using UDP Aug 23, 2018
@snowsignal
Copy link
Contributor Author

@andrewda, this can already broadcast as well. If we set JETSON_IP to either the universal broadcast address 255.255.255.255 or the subnet broadcast address (which depends on the IP of the network), the message will be broadcasted across the local network (as long as a router doesn't block it). However, most WiFi routers will block UDP requests, so it's better to set the IP to localhost for testing.

@andrewda
Copy link
Member

I think we'll be fine with 10.25.21.255 (again, value should be set in constants.kt).

@@ -42,6 +42,10 @@ const val MAX_VELOCITY = 0.6
const val MAX_ACCELERATION = 0.1
const val MAX_JERK = 60.0

// TimeSync
const val JETSON_PORT = 2521 // UDP Port for Jetson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://wpilib.screenstepslive.com/s/currentCS/m/troubleshooting/l/705152-fms-whitepaper#driver-station-and-robot-communications

This has gotta be a value between 5800 and 5810, but we're already using 5800 for Jetson -› Robot comms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's use 5801, then.

@snowsignal
Copy link
Contributor Author

I've also updated time-sync-server to be compatible with these changes.

@snowsignal
Copy link
Contributor Author

Should I write tests?

@andrewda
Copy link
Member

@JacksonCoder Eh, not necessary for this. And besides we don't really have any tests on this repo. Next year, though... Oh man we're gonna test everything ;).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants