uf-mil / ros_alarms

Alarm system implementation in ROS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add tab completion

mattlangford opened this issue · comments

Mainly for raise, clear, and report.

Tab completing those alarms with the data in the param /known_alarms

@uf-mil/developers anyone want to work on this?
It would be pretty useful.

I will take a stab at this, if I fail you or someone wants to try it in parallel, feel free.

I have done this on all the scripts; however they were written in bash. Seeing as bash is the shell we use, that makes sense to me. Were you going for a pure Python solution? If not, I should be able to knock this out in a day.

How would you do this? Current alarms have to loaded via a ros param

There is a rosparam bash command that I could make use of. If you are implying that there is no way to easily discover the data needed for this to work, then that is another problem entirely.

I would think a pure python solution would be the best way to go since the bash script would be like a wrapper around the current python script which sounds messy. There's a python library call argcomplete which should do it. I think it'd be something good to add to the deps since it would be pretty useful library for a lot of other things we have too

Feel free to go that route, but rosbash uses the model I have described and that seems to be the standard for autocompletion in ROS.

Just to add another option into the mix: python-fire completion

True, I'd tend toward argcomplete since it'd be pretty easy to check if someone has it installed and not tab complete if it can't without much mess. Python fire would require pretty big restructuring I think.

It could turn out not to be a big change though, do we plan on adding support for python fire on the sub soon?

Looks like it's completion does what Anthony suggested (kind of). It generates a static completion bash script and you have to source that. Wouldn't really be useful here.

Yeah, it was just a thought. Actually let's just stick to proven methods for now. I think @whispercoros' solution is probably the most practical. It's really easy to source custom stuff now that we have our own .milrc. And ros does it.

But ros alarms shouldn't require the milrc to run, putting bash scripts that need to be sourced seems against the idea. For the sub it would be preferred but in general, it doesn't seem right.

Oh yeah, I forgot it should be independent of the rest of the sub.

Then again it is as easy as having this bash script in the scripts directory of the pkg and sourcing it via the launch file right along with the server node: (something like this)
<node name="completion_script" pkg="ros_alarms" type="ros_alrams_completion.sh" />
Which could do something similar to what argcomplete does which is add to /etc/bash_completion.d

I say you two should see who can get it done first

Since we are planning on packaging this for the community, we will be able to take advantage of the fact that we are using the deb format. Our pre and post install scripts will be able to create files and directories in the ROS root directory, /opt/ros/<version>. See /opt/ros/kinetic/etc/catkin/profile.d/20.transform.bash for an example of bash completion functions installed by a package. If you have run the MIL install script, it should be there.

So if you're saying doing this kind of thing is not too obtrusive to the user and not a crazy thing to do, I think we should do bash autocompletion.

@whispercoros ETA?

This is complete now that #22, #23, and uf-mil/mil_common#53 have been merged. If ros_alarms is packaged, the Bash aliases script can be added to the list of scripts sourced with the ROS stack. For our use while developing the package, the script will be sourced from the Bash aliases script in mil_common.