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

Socket driver #32

Merged
merged 17 commits into from
Aug 26, 2018
Merged

Socket driver #32

merged 17 commits into from
Aug 26, 2018

Conversation

LoyVanBeek
Copy link
Contributor

This PR addresses/fixes comments on #16

@evenator evenator changed the base branch from jade-devel to master August 11, 2018 15:11
@evenator
Copy link
Collaborator

Retargeted to master.

Copy link
Collaborator

@evenator evenator left a comment

Choose a reason for hiding this comment

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

Sorry for my tardy response on this. ROS isn't my day job anymore, and most of these PRs actually predate me taking over maintenance of the repo.
Overall, this looks like a good improvement to the repo, although I don't have any way to test it personally.
I requested a few changes. If you can make those changes, I think we can merge this PR and probably even back port it to supported releases.

local_ip = rospy.get_param('~ip', '0.0.0.0')
local_port = rospy.get_param('~port', 10110)
buffer_size = rospy.get_param('~buffer_size', 4096)
timeout = rospy.get_param('~timeout', 2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a units suffix, e.g. if this is in seconds, call it ~timeout_s or ~timeout_sec


try:
# Create a socket
_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the name of _socket prefixed with an underscore? Usually, this indicates a global variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because there is also a module imported as socket and mixing the two would seriously mess things up :).
I don't know of a naming convention that uses a _ prefix for globals, but there is a convention for postfixing to avoid conflicts with builtins and keyword, so I'll change it to that.

data, remote_address = _socket.recvfrom(buffer_size)
except socket.error, exc:
rospy.logerr("Caught exception socket.error during recvfrom: %s" % exc)
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this try to reconnect here, rather than breaking out and killing the node?

self.vel_pub = rospy.Publisher('vel', TwistStamped, queue_size=1)
self.time_ref_pub = rospy.Publisher('time_reference', TimeReference, queue_size=1)
self.vel_pub = rospy.Publisher('fix_velocity', TwistStamped, queue_size=1)
self.time_ref_pub = rospy.Publisher('time', TimeReference, queue_size=1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately, these two API changes would break users' existing systems. Please keep the ROS API the same so we can release your new functionality without breaking existing functionality.

return "%s/%s" % (prefix, frame_id)
else:
return frame_id
return frame_id
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change was rejected in #40. A similar, but less destructive solution is going to be merged in #33. Please remove this change from your PR.

@@ -126,7 +126,8 @@ def convert_deg_to_rads(degs):

def parse_nmea_sentence(nmea_sentence):
# Check for a valid nmea sentence
if not re.match('(^\$GP|^\$GN|^\$GL).*\*[0-9A-Fa-f]{2}$', nmea_sentence):

if not re.match('^\$(GP|GN|GL|GA|II|IN|GB|BD|QZ).*\*[0-9A-Fa-f]{2}$', nmea_sentence):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change related to your new node? It seems like it might be a good addition, but it's not necessary for the new node. Please remove it from this PR and put it in its own PR if you'd like it to be considered.

@evenator
Copy link
Collaborator

Also please add the new node to the list of installed scripts in the CMakeLists.txt file.

loy and others added 6 commits August 18, 2018 15:30
@LoyVanBeek
Copy link
Contributor Author

Reviews processed. Please note that this PR is building on an older PR (not by me) that had some unprocessed review comments, so not all the code in this PR is mine.

@evenator evenator assigned evenator and unassigned LoyVanBeek Aug 20, 2018
Copy link
Collaborator

@evenator evenator left a comment

Choose a reason for hiding this comment

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

Thanks for iterating on this!

Is the regex change in the parser intentional? It looks like a regression.

@@ -126,7 +126,8 @@ def convert_deg_to_rads(degs):

def parse_nmea_sentence(nmea_sentence):
# Check for a valid nmea sentence
if not re.match('(^\$GP|^\$GN|^\$GL).*\*[0-9A-Fa-f]{2}$', nmea_sentence):

if not re.match('^\$(GP|GN).*\*[0-9A-Fa-f]{2}$', nmea_sentence):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this is a regression, because the parser would no longer support $GL* messages.

@evenator evenator assigned LoyVanBeek and unassigned evenator Aug 22, 2018
The commit 0296231 reverted 4be9192 but that predates 904ea24, hence all the confusion about this line
@LoyVanBeek
Copy link
Contributor Author

LoyVanBeek commented Aug 23, 2018

Done. There is some git archeology in 92d156c concerning that regression.

@evenator evenator assigned evenator and unassigned evenator and LoyVanBeek Aug 25, 2018
Copy link
Collaborator

@evenator evenator left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. I've tested this out by writing a quick UDP forwarder for my serial device, and this node seems to work.

I'll merge this to master. Because it doesn't break any existing APIs or add any new dependencies, I think it's a good candidate to be backported to existing releases.

@evenator evenator merged commit e36f9cd into ros-drivers:master Aug 26, 2018
@LoyVanBeek
Copy link
Contributor Author

Could the UDP forwarder be added as well, as a test tool?

@LoyVanBeek LoyVanBeek deleted the socket_driver branch August 27, 2018 06:41
evenator pushed a commit that referenced this pull request Dec 29, 2018
Add a NMEA socket driver node, which is like the existing serial driver node, but instead of attaching to a TTY handle from a serial port, it listens to a UDP port for NMEA sentences.
@evenator evenator mentioned this pull request Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants