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

Add MoveThroughJointPositions to Arm component #324

Merged
merged 14 commits into from
Nov 18, 2024

Conversation

raybjork
Copy link
Member

I took a first pass at adding this new function to the sdk but don't completely understand everything that is required in doing this, so I'm hoping this can be a launching point to learn more about coding practices in this environment

@lia-viam lia-viam marked this pull request as ready for review November 14, 2024 22:03
@lia-viam lia-viam requested a review from a team as a code owner November 14, 2024 22:03
@lia-viam lia-viam requested review from njooma and removed request for a team November 14, 2024 22:03
Copy link
Member

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

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

I was just taking a look out of general interest

@@ -103,6 +109,20 @@ class Arm : public Component, public Stoppable {
virtual void move_to_joint_positions(const std::vector<double>& positions,
const ProtoStruct& extra) = 0;

/// @brief Move each joint on the arm through the positions specified in @param positions
/// @param options optional specifications to be obeyed during the motion.
inline void move_through_joint_positions(const std::vector<std::vector<double>>& positions,
Copy link
Member

Choose a reason for hiding this comment

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

Elsewhere in the SDK, we use xtensor to represent multi-dimensional arrays. It might be worth considering doing that here, as vector<vector isn't the easiest type to work with (for instance, there is no assurance that the inner vectors are all the same length, if that constraint applies here).

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this because I'm new to C++ and thought this would be an easy solution. Tensors sound much better I think

Copy link
Member

Choose a reason for hiding this comment

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

Have a look at what the mlmodel stuff does with xtensor. Don't be alarmed it if looks a little intense, beausec it is doing something much more complex than what you need since the dimensionality and datatypes can all vary there.

Copy link
Contributor

Choose a reason for hiding this comment

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

made the other changes but I'm going to save this one for later as a TODO in the interest of unblocking development on this module for now so it can land in this week's release

@raybjork for posterity, is it the case that that all the inner vectors are the same length? and is that something we potentially know in advance for either this UR arm or for a particular arm device?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think technically a user would be able to send an array of arrays of different lengths, but doing so would be incorrect and should cause an error to be thrown imo. So I think using tensors here does make sense.

You could maybe derive the size of the inner vector by looking at the kinematics file but doing this is outside the scope of the SDK functions and enforcing the correct length should be left to the driver instead.

*options.max_acc_degs_per_sec2);
}

for (const std::vector<double>& pos : positions) {
Copy link
Member

Choose a reason for hiding this comment

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

You can say const auto& pos here, if you like.


positions.reserve(request->positions_size());
for (const auto& values : request->positions()) {
positions.push_back({values.values().begin(), values.values().end()});
Copy link
Member

Choose a reason for hiding this comment

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

This can possibly be written positions.emplace_back(values.values().begin(), values.values().end) which will avoid a move and construct the vector in place.

@lia-viam
Copy link
Contributor

going to try to close and reopen because the license/cla task is pending

@lia-viam lia-viam closed this Nov 18, 2024
@lia-viam lia-viam reopened this Nov 18, 2024
@raybjork raybjork closed this Nov 18, 2024
@raybjork raybjork reopened this Nov 18, 2024
@lia-viam lia-viam merged commit 7a55dd4 into viamrobotics:main Nov 18, 2024
4 checks passed
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.

3 participants