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

Slightly improved architecture of robot.yaml #177

Merged
merged 24 commits into from
Dec 24, 2021

Conversation

JanezCim
Copy link
Contributor

@JanezCim JanezCim commented Sep 9, 2021

Changes in how core.launch gets generated and launched. Biggest change: base.yaml does not exsist any more, everything gets loaded through magni_bringup/config/default_robot.yaml -> launch_core.py -> generated_core.launch. This way the params from base.yaml are not duplicated and hopefully makes the whole process more clear.

Fixes #172
Fixes #169

on the rpi that runs noetic test with
python3 ~/catkin_ws/src/magni_robot/magni_bringup/scripts/launch_core.py --debug

when reviewing:

  • go over the code to see if there are any stupid mistakes, typos
  • play with /etc/ubiquity/robot.yaml
  • add new test extrinsics to as ~/.ros/extrinsics/extrinsics.yaml
  • also do python3 ~/catkin_ws/src/magni_robot/magni_bringup/scripts/launch_core.py which actually launches the generated_core.launch to see if everythig starts up as expected - try to move the robot around and stuff.
  • in yaml files do a typo test to see if the launch_core.py handels it.
  • try to break this in other ways.

@JanezCim JanezCim requested a review from rohbotics September 9, 2021 13:22
@rohbotics
Copy link
Member

Hey @JanezCim Can you separate out the param changes from the other changes here? I think the flat parameters need more discussion, but the rest of this is pretty good.

@JanezCim
Copy link
Contributor Author

JanezCim commented Sep 21, 2021

Hmm ok, I think it would be best that we continue discussion about the flat parameters here and I make a separate PR fixing the install rules.

Why I made the flat params:

  • its way easier to make per-param replacement with flat params (you dont have to loop within the sub dictionaries that non-flat params had)
  • it makes the params more logical (especially true for lidar and camera locations) (why have raspicam: {'camera_installed' : 'True', 'position' : 'forward'} when you can simply have raspicam_position: 'forward' - the camera installed is a bit redundant i think
  • Since this is noetic, we dont have to worry about backwards compatibility

Bad things:

  • old params will not work here (instead the script will do warning and launch with default params) - do we need that robot.yaml from kinetic also works in noetic?
  • motor_node params dont look exactly the same as before when they were ROS params - so that might be a point of confusion

Comments?

@JanezCim
Copy link
Contributor Author

JanezCim commented Oct 1, 2021

@rohbotics I implemented per-param correction and added launch checking (launch checking happenes only if --debug is added into command)

Can you re-review and test if it works for you :) Thanks!

Copy link
Contributor

@MoffKalast MoffKalast left a comment

Choose a reason for hiding this comment

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

From what I've tested it out both the --debug and regular runs work without issues, and it handles the old yamls as it should.

I've had a few misgivings about a few things, but after thinking them through I mostly agree on how it's set up.

There's just one minor thing:

sonars: None
# sonars: 'pi_sonar_v1' # Use this to enable sonars
    # We only support 1 version of the Sonars right now
    if conf["sonars"] == "pi_sonar_v1":
        conf["sonars"] = True
    else:
        conf["sonars"] = False
    <group if="$(arg sonars_installed)">
        <node pkg="pi_sonar" type="pi_sonar" name="pi_sonar"/>
    </group>

This setup is somewhat inconsistent for either having sonars as a simple toggle, or for supporting multiple types. Either we go all the way and have it boolean in the yaml as well:

sonars: False
# sonars:  True # Use this to enable sonars

Or we go the other way and support the string type in the launch file, so it's possible to add additional options without messing with the generation script:

    <group if="$(eval arg('sonars') == 'pi_sonar_v1')">
        <node pkg="pi_sonar" type="pi_sonar" name="pi_sonar"/>
    </group>

    <group if="$(eval arg('sonars') == 'pi_sonar_v2')">
        <node pkg="pi_sonar_v2" type="pi_sonar_v2" name="pi_sonar_v2"/>
    </group>

    etc.

I assume we should also get rid of the unused legacy param/base.yaml file with this change right? If we leave it there it's become a possible sink for changes that won't be reflected anywhere and may generate confusion.

@JanezCim
Copy link
Contributor Author

JanezCim commented Oct 6, 2021

@MoffKalast nice catch! Yeah thinking about it, since we arent super key on deversifying the sonar types i'd change it to bool, what do you think @rohbotics ?

We've decided not to get rid of base.yaml because its still kept for non-user editable "parameters" as mentioned in the design choices readme: https://github.com/UbiquityRobotics/magni_robot/tree/bugfix-oldrobotyaml/magni_bringup

But yeah maybe it would be good just to delete the parameters that have now been moved to robot.yaml so we dont have duplication and dont confuse people. Would that be a good alternative @MoffKalast ?

@JanezCim JanezCim requested a review from MoffKalast October 11, 2021 10:14

conf = get_yaml(conf_path, default_conf)
# print out the whole config if in debug mode
if arguments.debug == True:

Choose a reason for hiding this comment

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

Just a small thing - I don't understand why would you do this instead of if arguments.debug:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do this so its a smidge easier to read for humans

@MoffKalast MoffKalast requested a review from mjstn October 11, 2021 19:48
@JanezCim JanezCim requested a review from JanLipovsek October 15, 2021 12:33
@JanezCim JanezCim requested review from MoffKalast, MatjazBostic, mjstn and rohbotics and removed request for rohbotics November 29, 2021 19:58
Copy link
Contributor

@MoffKalast MoffKalast left a comment

Choose a reason for hiding this comment

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

Seems good as it is right now, nothing really jumps out at me that I'd comment on, at least in a conceptual sense. We've discussed most parts already anyway. Now it just needs to be used by somebody for a bit to see if anything's amiss.

Copy link

@MatjazBostic MatjazBostic left a comment

Choose a reason for hiding this comment

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

I don't really understand what all new parameters are for, but looks good to me.

pid_control: 0
drive_type: "standard"
wheel_type: "standard"
wheel_gear_ratio: 4.294
Copy link
Contributor

@mjstn mjstn Dec 14, 2021

Choose a reason for hiding this comment

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

Very pleased that we have all of the following in here: pid_velocity as 0, drive_type as standard, wheel_gear_ratio as 4.294 AND even pid_control as 0! Thanks!

@mjstn
Copy link
Contributor

mjstn commented Dec 14, 2021

I feel strongly due to massive history we have with base.yaml that we should keep magni_bringup/param/base.yaml

The file remains but only holds a comment that says 'All parameters have been moved to /etc/robot.yaml'

I state this because we have COUNTLESS entries in forum, on learn pages and email threads and customers themselves holding notes that ALL discuss making changes to base.yaml file.

If we keep base.yaml I guarentee you we save MASSIVE numbers of waste of time queries to us about confusion on base.yaml.

@MoffKalast
Copy link
Contributor

The file remains but only holds a comment that says 'All parameters have been moved to /etc/robot.yaml'

I can agree with that. As long as there aren't any actual params left in it that would make it appear as an actual config file.

@mjstn
Copy link
Contributor

mjstn commented Dec 15, 2021

That is correct. Absolutely no parameters in it, commented out or not.
JUST a comment to help the poor slob (I mean customer)

@JanezCim
Copy link
Contributor Author

The file remains but only holds a comment that says 'All parameters have been moved to /etc/robot.yaml'

Yes that is a smart and easy thing to do. And then we can remove it sometime in the future

@JanezCim
Copy link
Contributor Author

JanezCim commented Dec 15, 2021

I've added the follwing text:

# All parameters have been moved to /etc/ubiquity/robot.yaml and `magni_bringup/config/default_robot.yaml` 
# How it works: if there are some parameters missing in `/etc/ubiquity/robot.yaml` they are taken individually from `magni_bringup/param/default_robot.yaml`. 
# To get to know the details and explanations about this see the `magni_bringup/README.md`

@mjstn
Copy link
Contributor

mjstn commented Dec 15, 2021

Thank you for understanding the practical need for this file to help customers out of certain confusion for the customers who are following current docs. This leaving base.yaml is such an easy way to avoid I suspect a great many hours spent here and there over time to first realize what was wrong then tell them EXACTLY what would be great to state simply in that file. This is PURELY support. Sometimes the ideal 'keep it all clean' conflicts with backward compatible suportability, this is that case. Thanks

- We decided to move many motor controller and other key operating mode parameters from base.yaml to robot.yaml. A lot of work was done to do this by Rohan but the issue has been only creeping along and needs closure so that it will finally be safe to use magni_robot repository along with ubiquity_motor and our main codeline will then be more supportable again.
Copy link
Contributor

Choose a reason for hiding this comment

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

This may likely be the MOST important fix of the entire change! ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very important indeed :D

pid_proportional: 5000
pid_integral: 7
pid_integral: 5
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpik: This 'could' be as low as 3 but lets just go with this to not slow down this extremely long awaited change. I checked kinetic-devel and noetic-devel and this is a mess so just leave this and we will do more evaluation and other things later. Never hack some number at the 11th hour, it breaks stuff. We ship only what we have tested.

"max_velocity": str(vc_ang["max_velocity"]),
"has_acceleration_limits": str(vc_ang["has_acceleration_limits"]),
"max_acceleration": str(vc_ang["max_acceleration"]),

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting use of this 'mot_cont' to make the reading here easier. Nice. I think that was pre-existing so I assume it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would also be extremely nice if someone told me they have tested this on their actual robots and it works. I have tested on mine, but you never know.

conf["sonars"] = False
# print out the whole config if in debug mode
if arguments.debug == True:
print("DEUBG: Full content of the applied config:")
Copy link
Contributor

Choose a reason for hiding this comment

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

Cleanup: Is this really needed? This may be a debug artifact

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, "debug" is parameter you can run the launch_core.py with to get some usefull info out of it. Usefull in the future

# get camera extrinsics
path1 = (
"~/.ros/extrinsics/camera_extrinsics_%s.yaml" % conf["raspicam"]["position"]
"~/.ros/extrinsics/camera_extrinsics_%s.yaml" % conf["raspicam_position"]
Copy link
Contributor

Choose a reason for hiding this comment

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

has somebody thought through this 'symantic' change? It only 'slightly' makes my 'spidy sense' thing that there is room for generation of a bug in this sort of synantic change.

This change MUST be tested by our test group. Please include a test in the test plan.

Copy link
Contributor Author

@JanezCim JanezCim Dec 15, 2021

Choose a reason for hiding this comment

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

Not tested with our test group yet.

If the user sets (kinetic way)

raspicam: {"position" : "forward"}

instead of (noetic way)

raspicam_position: 'forward'

The raspicam_position forward will be taken from src/magni_robot/magni_bringup/config/default_robot.yaml thus making the robot not chrash, just the cam position will not be what user has set.

Maybe also here i could add a comment in /etc/ubiquity/robot.yaml that the param has changed from raspicam: {"position" : "forward"} to raspicam_position: 'forward'. Same thing then needs to be done for lidar

@mjstn
Copy link
Contributor

mjstn commented Dec 15, 2021

I do not see myself as an official 'reviewer' but in this light, 'I Approve'. Thanks all

@JanezCim JanezCim requested a review from GreTimotej December 15, 2021 09:30
@mjstn
Copy link
Contributor

mjstn commented Dec 15, 2021

IMPORTANT but SIMPLE: I think there are already a couple things such as raspicam position and so on that remind me that we really need at the very start of the default_robot.yaml file to have a comment line like this:

File format 2.0

If this is present we then can modify douments like the raspicam setup learn page and so on and say that if they see top of the file that the format is 2.0 or greater use these lines, else use older format lines.

This is rather important frankly. Lets lower the impact of this change by outguessing obvious issues of the future. Thanks

@GreTimotej
Copy link

After todays test it seemed good to me.

@JanezCim
Copy link
Contributor Author

JanezCim commented Dec 16, 2021

If this is present we then can modify douments like the raspicam setup learn page and so on and say that if they see top of the file that the format is 2.0 or greater use these lines, else use older format lines.

@mjstn i can do that, but long term id say that the way to go with these things would be that we have a documentation system that suppors the box through which the user can choose a version/distro of the documentation they would like to see. Eg. from readthedocs for ROS2:
image

This would super simplify our documentations and make it a bit more future proof IMO - since you cant be forever adding cases for each new version to the same .md file

@rohbotics
Copy link
Member

I think this is ok for now, we will do a further iteration with more generic sensor handling.

@JanezCim JanezCim merged commit 24f8a47 into noetic-devel Dec 24, 2021
@JanezCim JanezCim deleted the bugfix-oldrobotyaml branch February 1, 2022 15:50
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.

New launch_core doesn't work with old robot.yaml Automated test for launch_core
6 participants