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

Why is joint_index_ signed in JointModel? #944

Closed
tylerjw opened this issue Dec 29, 2021 · 0 comments
Closed

Why is joint_index_ signed in JointModel? #944

tylerjw opened this issue Dec 29, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@tylerjw
Copy link
Member

tylerjw commented Dec 29, 2021

Description

Why is the joint_index_ in JointModel a signed integer?

Here is where you get it: https://github.com/ros-planning/moveit2/blob/52ffbfdbd4ffee3267371ab8d43d14a30082f547/moveit_core/robot_model/include/moveit/robot_model/joint_model.h#L215

Here is one of many examples of it being used to index into an array: https://github.com/ros-planning/moveit2/blob/52ffbfdbd4ffee3267371ab8d43d14a30082f547/moveit_core/robot_model/src/robot_model.cpp#L184

I can't find an example of it being set to a negative value even though the interface would permit that. And if you did set it to a negative value it would cause all these operator[] calls that use it to access memory from before the array.

It is initialized to -1 here: https://github.com/ros-planning/moveit2/blob/52ffbfdbd4ffee3267371ab8d43d14a30082f547/moveit_core/robot_model/src/joint_model.cpp#L58

Would it hurt anything if I made it an unsigned value and initialized it to 0? Am I misunderstanding something about the interface here? Is there an implicit contract that this value will be initialized (correctly) before it is used and is therefore safe?

@tylerjw tylerjw added the bug Something isn't working label Dec 29, 2021
@tylerjw tylerjw closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant