Add reference timeout parameter to controllers templates#111
Add reference timeout parameter to controllers templates#111
Conversation
| return controller_interface::CallbackReturn::SUCCESS; | ||
| } | ||
|
|
||
| void DummyClassName::reference_callback(const std::shared_ptr<ControllerReferenceMsg> msg) |
There was a problem hiding this comment.
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.
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.
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.
saw that usage of "/reference" is inconsistent in the current master version changed to "/reference" completely in a different PR
#106
| 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.
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
| ASSERT_EQ(msg.set_point, 0.45); | ||
| } | ||
|
|
||
| // when too old msg is sent expect reference msg reset |
There was a problem hiding this comment.
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.
| "~/commands", subscribers_qos, | |
| "~/reference", subscribers_qos, |
There was a problem hiding this comment.
ok change ing it to /reference everywhere
| return controller_interface::CallbackReturn::SUCCESS; | ||
| } | ||
|
|
||
| void DummyClassName::reference_callback(const std::shared_ptr<ControllerReferenceMsg> msg) |
There was a problem hiding this comment.
in the chainable controller,
this callback is not used at all. I mean, you can call it, but nothing will happen.
| 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.
Should we not have here default value of the header is timestamp is "0"?
There was a problem hiding this comment.
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.
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(); |
| // Reference Subscriber | ||
| ref_subscriber_ = get_node()->create_subscription<ControllerReferenceMsg>( | ||
| "~/reference", subscribers_qos, | ||
| "~/commands", subscribers_qos, |
There was a problem hiding this comment.
| "~/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.
here under is missing resetting of refrence interfaces...
There was a problem hiding this comment.
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.
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.
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? |
|
This pull request is in conflict. Could you fix it @Robotgir? |
shall include all changes related to reference timeout