pddlstream icon indicating copy to clipboard operation
pddlstream copied to clipboard

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

Open taylorlulu opened this issue 1 year ago • 1 comments

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.

taylorlulu avatar Nov 09 '23 04:11 taylorlulu

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

kiwiwan avatar Dec 20 '23 06:12 kiwiwan