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

Inconsistent handling of type attribute in <param command=""> tags #138

Closed
jarvisschultz opened this issue Nov 19, 2020 · 8 comments · Fixed by #141
Closed

Inconsistent handling of type attribute in <param command=""> tags #138

jarvisschultz opened this issue Nov 19, 2020 · 8 comments · Fixed by #141

Comments

@jarvisschultz
Copy link

When using roslaunch, if you use a command= attribute inside of a param tag, the value of stdout is set to the parameter server as a string, regardless of the value of the type attribute. In rosmon, the value of type is read and respected (in other words, the correct behavior even though it's inconsistent with roslaunch).

example.launch

<launch>
  <param name="command_param" type="double" command="echo -n 1.23" />
</launch>

Running that with roslaunch:

jarvis@jschultz:~⟫ rosparam get /command_param
'1.23'

Running with rosmon:

jarvis@jschultz:~⟫ rosparam get /command_param
1.23

FWIW, even though the roslaunch behavior seems wrong, it is inline with the documentation. For the command attribute they say:

The output of the command will be read and stored as a string.

@xqms
Copy link
Owner

xqms commented Nov 19, 2020

Hey, good catch - incompatibility with roslaunch is definitely a bug. I started to look into this, but don't have time to finish, so I'll keep my notes here:

I think we also need to look at <param textfile="file"> - does it have the same behavior? If yes, we can just scrap the auto-conversion code at

return paramToXmlRpc(ctx, computeString->get(), fullType);

See also the comment further up:

// Dynamic parameters are more complicated. We split the computation in
// two parts:
// 1) Compute the value as std::string
// 2) Convert to desired type (or dissect into multiple parameters in
// case of YAML-typed parameters).

Seems that type="yaml" is respected - or at least I thought so at some point ;)

I need to write a full unit test on this - probably I'll have time over the weekend.

@jarvisschultz
Copy link
Author

jarvisschultz commented Nov 19, 2020

Great questions. I just tried with <param textfile="file" /> and in roslaunch, just like the command attribute, it doesn't matter what the value of type is, the param is always loaded as a string. This seems to be true even if the contents of the text file are valid YAML and type="yaml". Note, the docs for textfile say the same thing as for command:

The contents of the file will be read and stored as a string

It's also worth noting that this is probably ROS version specific. The section about type="yaml" at the bottom currently says new in Lunar. I haven't dug into PRs, relevant changes, etc. but it is worth noting the computer I'm currently on is running Kinetic. Might be worth seeing if there is different behavior for some of these conclusions across ROS versions

@xqms
Copy link
Owner

xqms commented Nov 29, 2020

It seems that this inconsistency in roslaunch has been fixed in the meantime. Starting from ROS Lunar, the type attribute is properly respected, at least in my tests:

$ docker run -it ros:lunar-ros-core
root@14354222f2d4:/# cat > test.launch
<launch>
  <param name="command_param" type="double" command="echo -n 1.23" />
</launch>
root@14354222f2d4:/# roscore &
[1] 34
[...]

root@14354222f2d4:/# roslaunch test.launch
... logging to /root/.ros/log/41ace022-328b-11eb-8895-0242ac110002/roslaunch-14354222f2d4-74.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://14354222f2d4:37539/

SUMMARY
========

PARAMETERS
 * /command_param: 1.23
 * /rosdistro: lunar
 * /rosversion: 1.13.7

NODES

ROS_MASTER_URI=http://localhost:11311

No processes to monitor
shutting down processing monitor...
... shutting down processing monitor complete
root@14354222f2d4:/# rosparam get /command_param
1.23
root@14354222f2d4:/#

What do you think about just printing a warning when $ROS_VERSION == "kinetic" and the type attribute is used together with command or textfile? In the end, users will want to fix their launch files / param clients anyway since they will break when they update to Lunar/Melodic/Noetic.

@xqms
Copy link
Owner

xqms commented Nov 29, 2020

... and this is the PR that changed the behavior: ros/ros_comm#1045
Commit: ros/ros_comm@df86805#diff-23538634097530a39f2541d19a84384c977a11aeead5de5956c2552cb0757c22

@jarvisschultz
Copy link
Author

Excellent summary! Thanks for digging into the roslaunch history to find the change. I think the proposed fix of just printing a warning is sufficient. Only possible suggestion I can think of would be to update the message printed to say something like:

On ROS versions older than ROS Lunar....

Just in case someone is still using Indigo or something

@xqms
Copy link
Owner

xqms commented Dec 10, 2020

I haven't forgotten about this - I just discovered some other inconsistencies with the param type system, which I'd like to fix at the same time. So progress on this will take some more time.

@xqms
Copy link
Owner

xqms commented Jan 3, 2021

Finally got around to this 🎉

The warning and some other fixes for whitespaced parameters are now in master and will sit there for a few weeks for testing before I'll release a new version into the ROS repos. Thanks again for raising the issue!

@jarvisschultz
Copy link
Author

Awesome... thanks for taking care of this! All looks good to me

gauthamm added a commit to rapyuta-robotics/rosmon that referenced this issue Jul 15, 2021
* core: launch_config: parse attributes in parent context

and make it mutable (required for $(anon))

* core: launch_config: handle $(anon) in ParseContext, see xqms#100

* core: test: node_utils: more debug output

* core: test: test_subst: test for nested $(anon), see xqms#100

* fix two typos in the README

* rosmon_core: fix a lot of whitespace issues introduced in xqms#76

* rosmon_core: option to obey output="XY" tags (see xqms#108)

Co-authored-by: Roger Pi <u1926981@campus.udg.edu>

* rosmon_core: unit test for output-attr parsing, refs xqms#108

* fix xqms#110

* rosmon_core: do not print node prefix in --disable-ui mode

--disable-ui is mostly used with ncurses-like nodes that have problems
with such additional outputs.

* rosmon_core: node_monitor: flush out remaining node output after node exit

* rosmon_core: new rosmon-disable-ui attribute for problematic launch files

* core: launch_config: accept empty yaml node

* rosmon_core: LaunchConfig warnings to stderr & make them captureable

* rosmon_core: test: unit tests for the warnings we trigger

* rosmon_core: Add YAML merge key parsing functionality.

* rosmon_core: Adding fix for rosparam parsing to equivilate with undocumented behavior of roslaunch

* rosmon_core: test: unit tests for merge keys feature

* rosmon_core: ui: UI DrawStatus optimized to only refresh on events.

* core: launch: add some comments & fix whitespace

* rosmon_core: depend on python2/3 conditioned on ROS_PYTHON_VERSION

* core: launch: add comments

* core: ui: just redraw on every keystroke

* core: launch: shift some node attributes into context

See xqms#116

* rosmon_core: parse scope attributes also for launch, include, group tags

* core: launch: make "enable-coredumps" a scoped attribute

* core: test: add test for scoped attributes on include tags

* core: monitor: support for systemd-coredump

* core: monitor: delete working directories from two runs ago

* capture stderr separately and correctly do output=log

* roscore: test: Fixing unit tests for stdout_stderr mod

* Adding alt. stderr output filter

* CHANGELOG

* CHANGELOG

* 2.3.0

* rosmon_core: cmake: request specific boost_python3 version

* rosmon_core: test: adapt test_node to python 3

* CHANGELOG

* 2.3.1

* rosmon_core: *really* fix search for boost_python for python 3

* rosmon_core: cmake: increase minimum version to address policy warnings

* CHANGELOG

* 2.3.2

* rosmon_core: cmake: older cmake versions don't have GREATER_EQUAL

* all: increase cmake minimum version to 3.4

* README: add installation hint for rosmon_core

* core: launch_config: loadYAMLParams: don't scope keys with leading slash

See xqms#130 for bug report. Basically, roslaunch respects leading slashes
during key resolution, we don't. We don't know what's better, but we have
to match whatever roslaunch is doing, as always.

* core: test: xml: rosparam: test leading slashes in keys

* core: consolidate floating point types used for stats

Fixes problems identified with -Wfloat-conversion

* core: ui: explicit float casts

Fixes problems identified with -Wfloat-conversion.

* rqt: make float/int casts explicit

Identified with -Wfloat-conversion.

* rosmon_core: env-hooks: follow symbolic links during file name suggestion

This fixes bash completion for colcon linked install spaces.

* core: substitution_python: catch by reference

Fixes a compiler warning on Ubuntu Focal.

* core: ui: display & search full name including namespace

* core: ui: use full name everywhere

* Start all and stop all options are added
F6 -> start all
F7 -> stop all

* core: launch: bytes_parser: add missing include

* Added option --stdout-print-source to print out node name when --disable-ui is used. Addresses xqms#139.

* Removed stdout-print-source option and print node name by default when --disable-ui is used. Right justify node names to the max node name length.

* core: fix compilation on Kinetic (boost::placeholders came later)

* core: monitor: do not leak stderr file descriptors

* core: launch_config: add warning for type= attrs on <param> tags on Kinetic

See xqms#138.

* update warning

* core: launch_config: strip off leading/trailing whitespace of params

* core: add utility to precisely dump ROS parameters

This is useful to analyze differences between roslaunch and rosmon in
parameter loading.

* core: launch_config: use double precision for auto type parameters

Previously we used floats, but XmlRpc stores doubles, so we should
make use of the full precision.

* core: launch_config: convert tabs + newlines in parameters

* core: test: add unit test for all sorts of whitespace in parameters

* core: test: basic.launch: make it work with roslaunch

* core: test: basic.py: adapt to fixed whitespace behavior

* core: fix aliasing problem using std::memcpy

* Resolves xqms#145 by providing a number of restarts threshold per node via ROS-launch arguments

* core: fix signed/unsigned comparison warning

* core: install tests (necessary for testing with colcon)

* core: monitor: use a second PTY for stderr, see xqms#147

* Inidicate when a node is actually Idle (e.g. stopped)

* Add missing dependency on libboost-pyhton-dev

Co-authored-by: Max Schwarz <max.schwarz@ais.uni-bonn.de>
Co-authored-by: Max Schwarz <max.schwarz@online.de>
Co-authored-by: Roger Pi <u1926981@campus.udg.edu>
Co-authored-by: Kazuhiro Hiratsuka <papino0319@gmail.com>
Co-authored-by: marco-tranzatto <marcot@ethz.ch>
Co-authored-by: Carl Colena <carl.colena@gmail.com>
Co-authored-by: Kutay YILMAZ <ktyylmz035@gmail.com>
Co-authored-by: Steve Golton <stevegolton@gmail.com>
Co-authored-by: mcfurry <f.b.f.schoenmakers@gmail.com>
Co-authored-by: Ferry Schoenmakers <ferry.schoenmakers@nobleo.nl>
Co-authored-by: Tim Clephas <tim.clephas@nobleo.nl>
gauthamm pushed a commit to rapyuta-robotics/rosmon that referenced this issue Jul 15, 2021
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 a pull request may close this issue.

2 participants