Skip to content

Errors for velocity/torque control #7

Open
@cr139139

Description

@cr139139

Hi. I was testing your interface and found some errors. I hope this helps someone who is having trouble with velocity or torque control.

  1. Typo in "pybullet_robot_joints.py" : You have to change 'targetVelocity' to 'targetVelocities' in the "set target" function for the "Joints" class to make the velocity control work.
  2. Unlock motors for torque control : You first have to unlock the joint motors with position/velocity control before force control. Unless, it will not move. You can see this issue at this link. I know this is not a good way, but I used an additional flag and changed the code like below just for fast testing.
    def set_target(self, joint_state_msg):

        # Set target
        if self.control_mode == self.pb_obj.pb.POSITION_CONTROL:
            target = {'targetPositions': joint_state_msg.position}            
        elif self.control_mode == self.pb_obj.pb.VELOCITY_CONTROL:
            target = {'targetVelocities': joint_state_msg.velocity}
        elif self.control_mode == self.pb_obj.pb.TORQUE_CONTROL:
            target = {'forces': joint_state_msg.effort}
            if self.init_flag:
                self.pb_obj.pb.setJointMotorControlArray(
                    self.pb_obj.body_unique_id,
                    [i for i in range(self.num_joints)],
                    self.pb_obj.pb.VELOCITY_CONTROL,
                    forces=[0]*self.num_joints
                )
                self.init_flag = False
        else:
            raise ValueError("did not recognize control mode!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions