Skip to content

Conversation

@chfritz
Copy link
Contributor

@chfritz chfritz commented Oct 15, 2016

Sorry, there was an issue with the previous attempt of fixing this.
This one seems to work.

@chris-smith
Copy link
Collaborator

Did the previous commit just have an issue with comments? ROS seems to use the entire line after the equals sign (up to a comment if it's not a string) to calculate the md5 text - so (float32 FLOAT_CONST=1.0 gives a different md5sum than float32 FLOAT_CONST=1.00)

I had to do something similar in the indigo branch actually - ended up consulting genmsg source code a lot. Mainly gentools, msgs, and msg_loader

@chfritz chfritz force-pushed the minor_fix_for_constants branch 2 times, most recently from fdd2b9e to c595cd1 Compare October 19, 2016 04:10
@chfritz
Copy link
Contributor Author

chfritz commented Oct 19, 2016

Thanks for the pointer. That is indeed a better way of dealing with the issue and I've adopted that now, but I still needed to store the constant value as a string, rather than a parsed value in order to stop javascript from doing things like turning 1.0 into 1.

@jeffadamsc
Copy link

Do you still have a problem with "1.0" vs "1.00" in this change? I see you're looking for whitespace, but not trailing zeros.

name : fieldName
, type : fieldType
, value : parsedConstant
<<<<<<< HEAD
Copy link
Collaborator

Choose a reason for hiding this comment

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

merge issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, sorry. fixed now.

// simple value
that[field.name] = values ? values[field.name] :
(field.value || fieldsUtil.getDefaultValue(field.type));
that[field.name] = values ? values[field.name] : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

also a merge issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no this one was intended.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this force users to specify values for all the fields in their messages?

const header = new std_msgs.msg.Header()
pub.publish(header); // invalid

whereas before that would have worked

@chris-smith
Copy link
Collaborator

Do you still have a problem with "1.0" vs "1.00" in this change? I see you're looking for whitespace, but not trailing zeros.

1.0 is different from 1.00 in ros' message md5 text so trailing zeros are correct.

@chfritz chfritz force-pushed the minor_fix_for_constants branch 2 times, most recently from f654905 to fec3d80 Compare October 24, 2016 02:49
@chfritz
Copy link
Contributor Author

chfritz commented Oct 24, 2016

I'm actually not sure what the right behavior is. We also want to allow users to leave (optional) values unspecified (null). Maybe we just need to set them explicitly to null then already in the JS object.

@chris-smith
Copy link
Collaborator

I don't think ROS 1.0's message serialization scheme allows for optional values.

If we want optional arguments when sending messages we typically will use constants or something and check against those on the other end.

if (msg.optionalField !== MyMessage.OPTIONAL_DEFAULT) { ... }
// or
if (msg.optionalList.length > 0) { ... }

It does start to get cumbersome when you want optional complex fields.

Automatically providing default values for fields allows devs sending a message to ignore certain fields if they don't care about them though - provided your subscriber interprets the default values correctly...

…otics-opensource#33)

Prior to this commit constant values like "1.0", i.e., floats that are
integer, were not correctly treated in the md5sum calculation -- they
were abbreviated to "1", causing incorrect md5sums. This commit fixes
that by using the original string value for md5sum calculation (up to
the start of a comment (for strings) or the first whitespace character
for any other field type).

- also fixing some wrong logic for null values
@chfritz chfritz force-pushed the minor_fix_for_constants branch from fec3d80 to 44a9f81 Compare October 27, 2016 04:47
@chfritz
Copy link
Contributor Author

chfritz commented Oct 27, 2016

I guess you are right. I was thrown off by some null values I saw in our messages, but I guess those are just used as constants the same way you guys are using them.

Fixed that now, allowing for null values but providing defaults for fields that are actually undefined, i.e., missing in the goal object.

@chris-smith
Copy link
Collaborator

Awesome - I'll release a new version with this and then pull the indigo merge changes in.

@chris-smith chris-smith merged commit 2a425c6 into RethinkRobotics-opensource:kinetic-devel Oct 27, 2016
chris-smith pushed a commit to chris-smith/rosjs that referenced this pull request Oct 27, 2016
…otics-opensource#33) (RethinkRobotics-opensource#34)

Prior to this commit constant values like "1.0", i.e., floats that are
integer, were not correctly treated in the md5sum calculation -- they
were abbreviated to "1", causing incorrect md5sums. This commit fixes
that by using the original string value for md5sum calculation (up to
the start of a comment (for strings) or the first whitespace character
for any other field type).

- also fixing some wrong logic for null values
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

Successfully merging this pull request may close these issues.

3 participants