Skip to content

Add simple transmission class#245

Merged
bmagyar merged 9 commits intoros-controls:masterfrom
bmagyar:add_simple_transmission
Jan 8, 2021
Merged

Add simple transmission class#245
bmagyar merged 9 commits intoros-controls:masterfrom
bmagyar:add_simple_transmission

Conversation

@bmagyar
Copy link
Copy Markdown
Member

@bmagyar bmagyar commented Nov 19, 2020

This is me porting over SimpleTransmission from ROS1.
I haven't updated the documentation but it should be mostly relevant.
Updates licenses to Apache2 from original.

Question:
Should I add a JointInterface and an ActuatorInterface class to transmission_interface which transmissions can be used with?

  • I added them

Should communicate clearly what "handle" is intended to be used where. If you have other suggestions, fire away.

@bmagyar bmagyar requested a review from Karsten1987 November 19, 2020 20:57
@bmagyar
Copy link
Copy Markdown
Member Author

bmagyar commented Nov 23, 2020

@Karsten1987 @destogl this should fix one half of the failures we are getting from #236 , please let me know your feeling about this updated version.

@bmagyar bmagyar requested a review from destogl November 23, 2020 09:07
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.

It doesn`t look bad. I am not happy with the used nomenclature, but I also do not have any better ideas.

I will check tests to be finished to approve it.

Copy link
Copy Markdown
Contributor

@Karsten1987 Karsten1987 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 see any changes here.

target_include_directories(transmission_parser PUBLIC include)
ament_target_dependencies(transmission_parser hardware_interface tinyxml2_vendor TinyXML2)
ament_export_dependencies(hardware_interface tinyxml2_vendor TinyXML2)
ament_export_dependencies(transmission_parser tinyxml2_vendor TinyXML2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

consider moving this further down next to ament_export_include_directories

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

moved

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.

I belive @Karsten1987 meant to move ament_export_dependencies to the end of the file

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +25 to +32
#add_library(transmission_plugins SHARED
# include/transmission_interfrace/simple_transmission.h
#)
#target_include_directories(transmission_plugins PUBLIC include)
#ament_target_dependencies(transmission_plugins hardware_interface tinyxml2_vendor TinyXML2)
#ament_export_dependencies(transmission_plugins hardware_interface tinyxml2_vendor TinyXML2)
#target_compile_definitions(transmission_plugins PRIVATE "TRANSMISSION_INTERFACE_BUILDING_DLL")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be deleted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yup, gone

EXPECT_EQ(-1.0, trans.get_joint_offset());
}

// #ifndef NDEBUG
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's up with these tests?

@bmagyar bmagyar force-pushed the add_simple_transmission branch from 5d49a43 to 1931f10 Compare November 23, 2020 20:00

ActuatorHandle actuator_position = {"", "", nullptr};
ActuatorHandle actuator_velocity = {"", "", nullptr};
ActuatorHandle actuator_effort = {"", "", nullptr};
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.

Please end your member variables with a "_".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

const std::vector<ActuatorHandle> & actuator_handles)
{
// check that joint / act names are identical
// check that joint interfaces and actuator interfaces match
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.

Also check the actual handle is valid: handle name and interface are not empty.

}

// *jnt_data.absolute_position[0] = *act_data.absolute_position[0] / reduction_ + jnt_offset_;
// *jnt_data.torque_sensor[0] = *act_data.torque_sensor[0] * reduction_;
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.

Leftover comments?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

wasn't sure what to do with these

inline void SimpleTransmission::joint_to_actuator()
{
if (joint_effort && actuator_effort) {
actuator_effort.set_value(joint_effort.get_value() / reduction_);
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.

I know this was present in the original implementation, but I'm wondering in which cases should the reduction be applied to the effort interface. E.g., it does not make sense if you are using current as effort.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What should we do here instead? Acceleration? Torque? same handling for both?

@bmagyar bmagyar force-pushed the add_simple_transmission branch from 1931f10 to 4640a8e Compare December 26, 2020 22:10
@bmagyar bmagyar force-pushed the add_simple_transmission branch from 4640a8e to 9b348db Compare December 26, 2020 22:23
@bmagyar bmagyar force-pushed the add_simple_transmission branch from 9b348db to baf4d1e Compare January 1, 2021 18:40
@bmagyar bmagyar force-pushed the add_simple_transmission branch from baf4d1e to 5135346 Compare January 1, 2021 18:41
Comment on lines +97 to +113
/**
* \brief Transform \e effort variables from actuator to joint space.
* \param[in] act_data Actuator-space variables.
* \param[out] jnt_data Joint-space variables.
* \pre Actuator and joint effort vectors must have size 1 and point to valid data.
* To call this method it is not required that all other data vectors contain valid data, and can even remain empty.
*/
void actuator_to_joint() override;

/**
* \brief Transform \e effort variables from joint to actuator space.
* \param[in] jnt_data Joint-space variables.
* \param[out] act_data Actuator-space variables.
* \pre Actuator and joint effort vectors must have size 1 and point to valid data.
* To call this method it is not required that all other data vectors contain valid data, and can even remain empty.
*/
void joint_to_actuator() override;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is a bit confusing that these methods have documented param[in] and param[out] args, but they have no params, I have to assume that they operate on the handles provided in the configure, maybe we should mention this explicitely.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good spotting, thanks!

Comment on lines +93 to +95
void configure(
const std::vector<JointHandle> & joint_handles,
const std::vector<ActuatorHandle> & actuator_handles) override;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should document that it is expected that you can provide multiple Handles but only of different interfaces of the same joint. I did not understand it until I got to the implementation of this method.

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.

Can we check this somehow to protect users from making errors?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@destogl it is checked and exceptions are thrown accurately reporting the issue. I'll add docs to reinforce

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.

Sorr to be very picky. It seems there are some obsolete comments.

target_include_directories(transmission_parser PUBLIC include)
ament_target_dependencies(transmission_parser hardware_interface tinyxml2_vendor TinyXML2)
ament_export_dependencies(hardware_interface tinyxml2_vendor TinyXML2)
ament_export_dependencies(transmission_parser tinyxml2_vendor TinyXML2)
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.

I belive @Karsten1987 meant to move ament_export_dependencies to the end of the file

Comment on lines +93 to +95
void configure(
const std::vector<JointHandle> & joint_handles,
const std::vector<ActuatorHandle> & actuator_handles) override;
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.

Can we check this somehow to protect users from making errors?

* \pre Nonzero reduction value.
*/
SimpleTransmission(
const double reduction,
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.

Disclaimer: I am not a transmission expert, but...

What does "Reduction ratio" means? Is this ratio "actuator/joint" or "joint/actuator". this should be at least documented.

I think a better variable name would be (if correct):

Suggested change
const double reduction,
const double actuator_to_joint_ratio,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is plenty of this on the class documentation but I also renamed the argument. For brevity, the member variable name didn't change.

Comment on lines +99 to +100
* \param[in] act_data Actuator-space variables.
* \param[out] jnt_data Joint-space variables.
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.

Where are those parameters?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nowhere, removed the offending doc

: reduction_(reduction),
jnt_offset_(joint_offset)
{
if (0.0 == reduction_) {
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.

This is rather an unusual syntax.

Suggested change
if (0.0 == reduction_) {
if (reduction_ == 0.0) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

indeed, flipped

Comment on lines +59 to +60
* \param[in] act_data Actuator-space variables.
* \param[out] jnt_data Joint-space variables.
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.

this is probably copied from earlier code?

Suggested change
* \param[in] act_data Actuator-space variables.
* \param[out] jnt_data Joint-space variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

genau

Comment on lines +69 to +70
* \param[in] jnt_data Joint-space variables.
* \param[out] act_data Actuator-space variables.
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.

this is probably copied from earlier code?

Suggested change
* \param[in] jnt_data Joint-space variables.
* \param[out] act_data Actuator-space variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@bmagyar
Copy link
Copy Markdown
Member Author

bmagyar commented Jan 8, 2021

Thanks guys for the comments, I believe I should have addressed them all now. Let me know if there's anything else.

@bmagyar bmagyar requested review from destogl and v-lopez January 8, 2021 08:32
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.

It looks good now.

@bmagyar bmagyar merged commit 5bbd16c into ros-controls:master Jan 8, 2021
destogl added a commit to b-robotized-forks/ros2_control that referenced this pull request Aug 11, 2022
* Remove compile warnings.

* correct formatting.
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.

5 participants