Skip to content

added dt to controller interface and controller manager #438#520

Merged
bmagyar merged 10 commits intoros-controls:masterfrom
dignakov:controller-interface-add-dt
Sep 20, 2021
Merged

added dt to controller interface and controller manager #438#520
bmagyar merged 10 commits intoros-controls:masterfrom
dignakov:controller-interface-add-dt

Conversation

@dignakov
Copy link
Copy Markdown
Contributor

@dignakov dignakov commented Sep 7, 2021

I took a stab at adding #438. This is by no means complete, but if no one has started work on this, I'd like to get some feedback and I can keep working on it.

Copy link
Copy Markdown
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

This looks good. The only question I have is how do we want to proceed. Should we provide dt or absolute current time? Anyway, IMO, we should provide read measured time since the last update call and not theoretical one. What do you think?

@dignakov
Copy link
Copy Markdown
Contributor Author

dignakov commented Sep 7, 2021

Should we provide dt or absolute current time

I didn't see the discussion when I started, so I went with dt, but I can see why time would make sense, especially if there's a plan to have different controllers execute at different rates.

What I'm not sure about is what would be the source of the absolute time, would it come from ros, or something like steady_clock, or something else? (system_clock is used in the ros2_control_node, so just reuse that?)

Either way, I'm happy to try and implement the change if you'd like to proceed with absolute current time.

Anyway, IMO, we should provide read measured time since the last update call and not theoretical one.

I agree. But I wasn't sure about the right source of time to use, so I just used the theoretical update rate.

Also, what would we provide on the very first iteration?

I think also that the following is possible: (it would make more sense and less "0")

Yup, agreed. I'll change that too depending on what you'd like to do about point 1.

I went ahead and implemented the above two for now.

Please let me know if it's better to go with absolute current time instead.

@dignakov
Copy link
Copy Markdown
Contributor Author

dignakov commented Sep 8, 2021

update functions in controller_interface and controller_manager now accept both time and period:
update(const rclcpp::Time& time, const rclcpp::Duration& period)

@dignakov dignakov requested a review from destogl September 11, 2021 16:37
Copy link
Copy Markdown
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Generally I agree, just few points to discuss.

Also, do we need a test for this functionality? A simple one testing parameter propagation?

void ControllerManager::read() { resource_manager_->read(); }

controller_interface::return_type ControllerManager::update()
controller_interface::return_type ControllerManager::update(const rclcpp::Time& time, const rclcpp::Duration& period)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should provide only time in this method and period is calculated just before controller-update is called. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would that still work with node->now() from your comment below to get a good dt or do you think it's ok to add a couple of variables there to track dt using steady_clock?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@destogl the purpose of this API is to provide both as both should be available from the CM time without having to re-compute the same stuff all the time.

@bmagyar
Copy link
Copy Markdown
Member

bmagyar commented Sep 15, 2021

@destogl in terms of a test for this... I don't think we need one at this point. The main point of this PR is to extend the API which was achieved. Testing that is testing that C++ can propagate arguments to a function :D I don't think we need that

Copy link
Copy Markdown
Member

@destogl destogl 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 the work and follow-up to getting this PR straight! 🤖

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.

4 participants