-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add reference timeout parameter to controllers templates #111
base: master
Are you sure you want to change the base?
Add reference timeout parameter to controllers templates #111
Conversation
@@ -139,6 +143,30 @@ controller_interface::CallbackReturn DummyClassName::on_configure( | |||
return controller_interface::CallbackReturn::SUCCESS; | |||
} | |||
|
|||
void DummyClassName::reference_callback(const std::shared_ptr<ControllerReferenceMsg> msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw that ref_callback is called in different order in standard and chainable controller, hence adjusting it to be consistent with standard controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the chainable controller,
this callback is not used at all. I mean, you can call it, but nothing will happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the confusion i should have written "ref_callback is defined in different order in standard and chain-able controller classes, hence adjusting it to be consistent with standard controller"
its trivial change, just changed the order
// Reference Subscriber | ||
ref_subscriber_ = get_node()->create_subscription<ControllerReferenceMsg>( | ||
"~/reference", subscribers_qos, | ||
"~/commands", subscribers_qos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw that usage of "/reference" is inconsistent in the current master version changed to "/reference" completely in a different PR
#106
@@ -192,7 +195,7 @@ TEST_F(DummyClassNameTest, test_update_logic_fast) | |||
|
|||
EXPECT_EQ(*(controller_->control_mode_.readFromRT()), control_mode_type::FAST); | |||
EXPECT_EQ(joint_command_values_[STATE_MY_ITFS], TEST_DISPLACEMENT); | |||
EXPECT_TRUE(std::isnan((*(controller_->input_ref_.readFromRT()))->displacements[0])); | |||
EXPECT_EQ((*(controller_->input_ref_.readFromRT()))->displacements[0], TEST_DISPLACEMENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just adjusted this to work here, but wanted to get confirmation from you. I see that in mecanum we set reference msg to nan when ref_timeout = 0 and for too old msg (age_of_last_command > ref_timeout_)
in this particular test we have testing update fast logic where age_of_last_command <= ref_timeout_
and more over this test will be over written in the PR #106
with a different name with similar logic test
@@ -366,6 +372,166 @@ TEST_F(DummyClassNameTest, receive_message_and_publish_updated_status) | |||
ASSERT_EQ(msg.set_point, 0.45); | |||
} | |||
|
|||
// when too old msg is sent expect reference msg reset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added ref_timeout related tests with agreed naming convention
// Reference Subscriber | ||
ref_subscriber_ = get_node()->create_subscription<ControllerReferenceMsg>( | ||
"~/reference", subscribers_qos, | ||
"~/commands", subscribers_qos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"~/commands", subscribers_qos, | |
"~/reference", subscribers_qos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok change ing it to /reference everywhere
@@ -139,6 +143,30 @@ controller_interface::CallbackReturn DummyClassName::on_configure( | |||
return controller_interface::CallbackReturn::SUCCESS; | |||
} | |||
|
|||
void DummyClassName::reference_callback(const std::shared_ptr<ControllerReferenceMsg> msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the chainable controller,
this callback is not used at all. I mean, you can call it, but nothing will happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please use
reference
instead ofcommand
. - One test is not fully implemented when testing only a single call.
- Why is there repetition of the logic in both the update methods? Only method that gets things from callback should have the logic.
const auto age_of_last_command = get_node()->now() - msg->header.stamp; | ||
if (msg->joint_names.size() == params_.joints.size()) { | ||
if (ref_timeout_ == rclcpp::Duration::from_seconds(0) || age_of_last_command <= ref_timeout_) { | ||
input_ref_.writeFromNonRT(msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not have here default value of the header is timestamp is "0"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are referring to this handling of case if header.stamp ==0 right?
this is included in the improvements from mecanum PR, you can see the line in the below link, should i also implement this in this ref_timeout PR?
auto current_ref = input_ref_.readFromRT(); | ||
const auto age_of_last_command = get_node()->now() - (*current_ref)->header.stamp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this here? This should be in the update reference from subscribers only. Please adjust
// send message only if there is no timeout | ||
if (age_of_last_command <= ref_timeout_ || ref_timeout_ == rclcpp::Duration::from_seconds(0)) { | ||
if (!std::isnan(reference_interfaces_[i])) { | ||
if (*(control_mode_.readFromRT()) == control_mode_type::SLOW) { | ||
reference_interfaces_[i] /= 2; | ||
} | ||
command_interfaces_[i].set_value(reference_interfaces_[i]); | ||
if (ref_timeout_ == rclcpp::Duration::from_seconds(0)) { | ||
reference_interfaces_[i] = std::numeric_limits<double>::quiet_NaN(); | ||
} | ||
} | ||
command_interfaces_[i].set_value(reference_interfaces_[i]); | ||
|
||
reference_interfaces_[i] = std::numeric_limits<double>::quiet_NaN(); | ||
} else { | ||
command_interfaces_[i].set_value(0.0); | ||
(*current_ref)->displacements[i] = std::numeric_limits<double>::quiet_NaN(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the code here repeated?
// Reference Subscriber | ||
ref_subscriber_ = get_node()->create_subscription<ControllerReferenceMsg>( | ||
"~/reference", subscribers_qos, | ||
"~/commands", subscribers_qos, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"~/commands", subscribers_qos, | |
"~/reference", subscribers_qos, |
command_interfaces_[i].set_value((*current_ref)->displacements[i]); | ||
|
||
} else { | ||
command_interfaces_[i].set_value(0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here under is missing resetting of refrence interfaces...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is standard controller and in my understanding we dont have reference_interfaces in standard controller. Please correct me if i am wrong
EXPECT_FALSE(std::isnan((*(controller_->input_ref_.readFromNonRT()))->duration)); | ||
EXPECT_EQ((*(controller_->input_ref_.readFromNonRT()))->displacements[0], 0.45); | ||
EXPECT_EQ((*(controller_->input_ref_.readFromNonRT()))->velocities[0], 0.0); | ||
EXPECT_EQ((*(controller_->input_ref_.readFromNonRT()))->duration, 1.25); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should call this also a second time to be sure that this works only once - not you can not confirm that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extended the test here like this but have question,
it works when setting the ref_msg to nan like done here
but instead of individually setting them like that i wanted to just call
reset_controller_reference_msg(*(input_ref_.readFromRT()), state_joints_, get_node());
but this is not working, also made sure that the fun is being called but the msg is not being reset. is the way i am inputing the ref_msg wrong? like this "*(input_ref_.readFromRT())".
…lback_expect_reference_msg_being_used_only_once and extending its relavant code in controllers
This pull request is in conflict. Could you fix it @Robotgir? |
4 similar comments
This pull request is in conflict. Could you fix it @Robotgir? |
This pull request is in conflict. Could you fix it @Robotgir? |
This pull request is in conflict. Could you fix it @Robotgir? |
This pull request is in conflict. Could you fix it @Robotgir? |
shall include all changes related to reference timeout