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

TypeError: unsupported operand type(s) for -: 'tuple' and 'float' #44

Open
taylorlulu opened this issue Nov 9, 2023 · 1 comment
Open

Comments

@taylorlulu
Copy link

taylorlulu commented Nov 9, 2023

I encountered this issue when I tried to run the command python -m examples.pybullet.tamp.run.
File "/home/lu/Desktop/Code/pddlstream/examples/pybullet/utils/pybullet_tools/utils.py", line 3728, in <genexpr> return tuple(circular_difference(value2, value1) if circular else (value2 - value1) TypeError: unsupported operand type(s) for -: 'tuple' and 'float'
After debugging I found the problem was caused by the apply function in pr2_primitives.py.

    def apply(self, state, **kwargs):
        joints = get_gripper_joints(self.robot, self.arm)
        start_conf = get_joint_positions(self.robot, joints)
        end_conf = [self.position] * len(joints)
        if self.teleport:
            path = [start_conf, end_conf]
        else:
            extend_fn = get_extend_fn(self.robot, joints)
            path = [start_conf] + list(extend_fn(start_conf, end_conf))
        for positions in path:
            set_joint_positions(self.robot, joints, positions)
            yield positions

The type of start_conf is tuple with value (0.548, 0.548, 0.548, 0.548),
however the end_conf is list with value [(0.4298039215686276, 0.4298039215686276, 0.4298039215686276, 0.4298039215686276), (0.4298039215686276, 0.4298039215686276, 0.4298039215686276, 0.4298039215686276), (0.4298039215686276, 0.4298039215686276, 0.4298039215686276, 0.4298039215686276), (0.4298039215686276, 0.4298039215686276, 0.4298039215686276, 0.4298039215686276)].

In joint_from_name functions, there're four joints which are l_gripper_l_finger_joint, l_gripper_r_finger_joint, l_gripper_l_finger_tip_joint and l_gripper_r_finger_tip_joint.

I guess the problem was caused by the difference with the dimension of start_conf and end_conf. As it will call the get_extend_fn which will recursively call the get_difference_fn function and finally will lead to the program crash at line 3728.
I would appreciate if anyone could offer any advice.

@kiwiwan
Copy link

kiwiwan commented Dec 20, 2023

In pr2_primitives.py, I fixed this by the following:
image

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

No branches or pull requests

2 participants