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

Port four bar linkage and differential transmission loaders from ROS1 #656

Merged
merged 6 commits into from
Apr 14, 2022

Conversation

VX792
Copy link
Contributor

@VX792 VX792 commented Mar 1, 2022

Plus minor changes to parsing
Should I create test cases with invalid roles, since they were present in the ROS1 version?

Issue: #599

@VX792 VX792 force-pushed the port-four-bar-linkage branch from ea4a878 to f2a508b Compare March 2, 2022 12:18
@VX792 VX792 changed the title Port four bar linkage transmission loader from ROS1 Port four bar linkage and differential transmission loaders from ROS1 Mar 2, 2022
Copy link
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.

First set of comments.

std::shared_ptr<transmission_interface::Transmission> transmission;
const hardware_interface::TransmissionInfo & info = infos[0].transmissions[0];
transmission = transmission_loader->load(info);
ASSERT_TRUE(nullptr != transmission);
Copy link
Member

Choose a reason for hiding this comment

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

Please check best practices comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The best practices comment says that either the comparison ASSERT_TRUE(nullptr != transmission) is redundant, or there is possible null pointer dereference. I don't think there's a case where the transmission_loader would be a nullptr, so should I just leave out these comparisons?


std::shared_ptr<transmission_interface::Transmission> transmission = nullptr;
const hardware_interface::TransmissionInfo & info = infos[0].transmissions[0];
transmission = transmission_loader->load(info);
Copy link
Member

Choose a reason for hiding this comment

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

Aren't we throwing an exception here in SimpleTransmission? If so we should do the same.

{jnt_offset1, jnt_offset2}));
return transmission;
}
catch (const Exception & ex)
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't capture the exception from .at(), do the tests exercise anything that'd produce that? can we even end up with a situation like that ATM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, for example if we have one actuator and 2 joints in our urdf. I've just tested it and the test case fails with
C++ exception with description "vector::_M_range_check: __n (which is 1) >= this->size() (which is 1)" thrown in the test body.

The initial SizeIs checks passes, and in the load function we try to access the nonexistent
transmission_info.actuators.at(1).mechanical_reduction; variable. Is it okay if I catch an std::exception type here?

Comment on lines +50 to +52
RCLCPP_ERROR(
rclcpp::get_logger("differential_transmission_loader"),
"Failed to construct transmission '%s'", ex.what());
Copy link
Member

@bmagyar bmagyar Mar 23, 2022

Choose a reason for hiding this comment

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

do we want RLCPP_ERROR or std::cerr here like the other classes? I believe std::cerr was used to stop a crash, why is this not causing a crash in the test?

@bmagyar bmagyar force-pushed the port-four-bar-linkage branch from 844c78f to 9483385 Compare April 12, 2022 20:12
@bmagyar bmagyar merged commit 2cf6b5d into ros-controls:master Apr 14, 2022
pac48 pushed a commit to pac48/ros2_control that referenced this pull request Jan 26, 2024
* Add missing backward_ros dependency and minor cmake cleanup
* Fix unused arg warning

(cherry picked from commit d96f662)

Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
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