-
Notifications
You must be signed in to change notification settings - Fork 0
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
Introduce JointArray::{map, zip}
#50
Conversation
My €0,02: I think the I think the primary use case was being able to easily zip two pub fn map<F, U>(self, mut f: F) -> JointArray<U>
where
F: FnMut(T) -> U,
{
JointArray {
head_yaw: f(self.head_yaw),
head_pitch: f(self.head_pitch),
left_shoulder_pitch: f(self.left_shoulder_pitch),
left_shoulder_roll: f(self.left_shoulder_roll),
left_elbow_yaw: f(self.left_elbow_yaw),
left_elbow_roll: f(self.left_elbow_roll),
left_wrist_yaw: f(self.left_wrist_yaw),
left_hip_yaw_pitch: f(self.left_hip_yaw_pitch),
left_hip_roll: f(self.left_hip_roll),
left_hip_pitch: f(self.left_hip_pitch),
left_knee_pitch: f(self.left_knee_pitch),
left_ankle_pitch: f(self.left_ankle_pitch),
left_ankle_roll: f(self.left_ankle_roll),
right_shoulder_pitch: f(self.right_shoulder_pitch),
right_shoulder_roll: f(self.right_shoulder_roll),
right_elbow_yaw: f(self.right_elbow_yaw),
right_elbow_roll: f(self.right_elbow_roll),
right_wrist_yaw: f(self.right_wrist_yaw),
right_hip_roll: f(self.right_hip_roll),
right_hip_pitch: f(self.right_hip_pitch),
right_knee_pitch: f(self.right_knee_pitch),
right_ankle_pitch: f(self.right_ankle_pitch),
right_ankle_roll: f(self.right_ankle_roll),
left_hand: f(self.left_hand),
right_hand: f(self.right_hand),
}
} and similarly for pub fn zip<U>(self, other: JointArray<U>) -> JointArray<(T, U)> { ... } This way we can modify Would be glad to hear your opinions @Redjeepkaiser @Aemulation |
If But I am wondering, what is the reason we need a |
pos1
.zip(pos2)
.map(|(p1, p2)| 0.5 * p1 + 0.5 * p2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me!
Suggested commit message:
Introduce `JointArray::{map, zip}`
JointArray::{zip, map}
JointArray::{map, zip}
Implemented necessary traits.