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

Errors for velocity/torque control #7

Open
cr139139 opened this issue Jan 13, 2023 · 3 comments
Open

Errors for velocity/torque control #7

cr139139 opened this issue Jan 13, 2023 · 3 comments

Comments

@cr139139
Copy link

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!")
@anubhav-dogra
Copy link

Thanks for the edit suggestions. It worked !

I am trying to perform TORQUE_CONTROL mode on a serial manipulator, added through ros_description. However, Im facing problem in this mode. It seems like effort commands are never applied on the robot, as the robot keep falling on the ground on the start of simulation. No matter how large torque value is given.
Do I need to apply torques through force = [value] under the hood of velocity control ? rather than sending effort commands in torque control mode?

Can you please clarify?

Things are working well in POSITION/VELOCITY control mode by sending position/velocity commands.

Thanks :)

@secilmiskisi
Copy link

Hi, I am having the same issue, even after doing the fix mentioned here. I am sure I am giving correct inputs to the setJointMotorControlArray. I can even see the topic being published at joint_states/target. But when I echo joint_states topic, I see no effort and the robot keeps falling down as if there is no torque being applied to the joints.

Any help on the topic would be appreciated.

@secilmiskisi
Copy link

secilmiskisi commented Oct 2, 2024

I have solved the problem. It is related to the method of controlling torques. Bullet sees torque control commands as external forces. When I looked deeply into the pybullet documentation, it is written:

**
Note that this method will only work when explicitly stepping the simulation using stepSimulation, in other words: setRealTimeSimulation(0). After each simulation step, the external forces are cleared to zero. If you are using 'setRealTimeSimulation(1), applyExternalForce/Torque will have undefined behavior (either 0, 1 or multiple force/torque applications).
**

So when I set step_pybullet_manually: True , the issue was solved.

Hope this helps others.

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

3 participants