Balancing ball PID

Typically: "How do I... ", "How can I... " questions
Post Reply
mariobros231
Posts: 2
Joined: 25 Nov 2019, 21:30

Balancing ball PID

Post by mariobros231 » 27 Nov 2019, 11:52

Hello! I have a problem with my project. How properly adjust a revolute joint which is attach to a frame/plate and ball is running on it? I want to control the ball with PID, so e.g. ball a lilttle bit on the right sight and revolute joint(as a motor) rotate -> ball returns in the middle of plate. Shall I use joint callback function for speed up simulation a lil bit?

Thanks in advance, Michał

coppelia
Site Admin
Posts: 7450
Joined: 14 Dec 2012, 00:25

Re: Balancing ball PID

Post by coppelia » 27 Nov 2019, 19:58

Hello Michal,

so you basically want to control the inclination of a plate in two directions, so as to control the position in X/Y of a ball on the plate?
For that, use something like:

Code: Select all

baseObject(static) --> revoluteJoint1 --> auxiliaryShape(dynamic) --> revoluteJoint2 --> plate(dynamic)
Make sure your joints are in force/torque mode, motor enabled, and controller enabled. A simple default PID controller should be enough. Then, use for instance a vision sensor above the plate, to identify the location of the ball on the plate (e.g. use a blob detection filter, that will return the x/y position of the blobs). You can also simply query its position via sim.getObjectPosition instead. Then use that position to adjust the target angular positions of your joints, via sim.setJointTargetPosition.

Cheers

mariobros231
Posts: 2
Joined: 25 Nov 2019, 21:30

Re: Balancing ball PID

Post by mariobros231 » 03 Dec 2019, 21:41

Thanks a lot for the answer!

According to your solution I have couple questions.

1. How to properly adjust the angular postion of revolute joint? Recieve data from sim.getObjectPosition(
position: table of 3 values (x, y and z)) and how pass it into sim.setJointTargetPosition?

2. And what is the best way to provide possibility to change position by user? E.g. move ball a lil bit to one of directions and then PID moves ball back into the center?

Thanks in advance, Michał

coppelia
Site Admin
Posts: 7450
Joined: 14 Dec 2012, 00:25

Re: Balancing ball PID

Post by coppelia » 05 Dec 2019, 14:14

Well, there you have plenty of possibilities. That's basically what your controller will have to do. There are many types of controllers you could implement for that task. The simplest is always a PID- (or even a simple P-) controller, maybe with an upper threshold.

To change the position of the ball by the user (i.e. instead of always keeping the ball centered on the plate), then you can simply introduce an offset to the ball position.

Cheers

Post Reply