## Ballbot and Controller

Typically: "How do I... ", "How can I... " questions
pedrophj
Posts: 3
Joined: 15 Feb 2018, 01:21

### Ballbot and Controller

Hello everyone,

I am studying the ballbot model in V-REP. Could someone help me understand it?

Code: Select all

``````
local l=math.sqrt(v*v+v*v+v*v)
local ls=l
local w=0.18

v=v*ls*w/l
v=v*ls*w/l
v=v*ls*w/l
``````
I understand that v=v*ls*w/l it is the same as v=v*w, because above the author did ls = l. Right ?

Code: Select all

``````  local m=simGetObjectMatrix(sens,-1)

local euler=simGetEulerAnglesFromMatrix(m)
euler=0
euler=0

local m2=simBuildMatrix({0,0,0},euler)
local m3=simGetInvertedMatrix(m2)

local vect={m,m,m}
vect=simMultiplyVector(m3,vect)
v=simMultiplyVector(m3,v)
velo=simMultiplyVector(m3,velo)
d=0.2
``````
I researched and the elements 3, 7, 11 are position.
What are the variables vect, velo, d and v ?

Which controller is being used ?

Thanks

coppelia
Posts: 7020
Joined: 14 Dec 2012, 00:25

### Re: Ballbot and Controller

Hello,

the controller is a very simple proportional controller, as far as I remember. It is meant as a simple example. You can (and should!) write a much better controller.

Cheers

pedrophj
Posts: 3
Joined: 15 Feb 2018, 01:21

### Re: Ballbot and Controller

Thanks for answering me.

So, the code that calculates the angular velocity of the actuator is this below (variable v).

The variable "velo" is the absolute velocity of the robot.

The gain of the controller is 200, but I did not understand the "dir" (direction) and also I do not know what "vect" is.

I need to understand well the measured variables to be able to implement a new controller.

Code: Select all

``````   vect=vect-v+velo*d
vect=vect-v+velo*d

local v=-math.sqrt(vect*vect+vect*vect)*200
local dir=math.atan2(vect,vect)+1*math.pi/2

setBallMotion(v,dir,0)
``````

coppelia
Posts: 7020
Joined: 14 Dec 2012, 00:25

### Re: Ballbot and Controller

From what I can tell, the controller looks at the Z-vector component of the Ballbot's reference frame (object BallRobot_sensorPosition) to determine the amount and direction of inclination.

Cheers

pedrophj
Posts: 3
Joined: 15 Feb 2018, 01:21

### Re: Ballbot and Controller

Thanks for helping me. Now I can design an LQR or PID controller.