Ebooks <<
Previous Next >> CMSiMDE
Feedback
針對 CoppeliaSim 中 Python Remote API 不提供的功能, 可以透過 Lua 製作, 然後再以 https://www.coppeliarobotics.com/helpFiles/en/remoteApiFunctionsPython.htm#simxCallScriptFunction 呼叫. 相關討論請參考 https://forum.coppeliarobotics.com/viewtopic.php?t=7699
以下的 Inverted Pedulum 控制模擬可以視為專題 Task 之一:
https://github.com/mdecourse/vrep_inverted_pendulum 採用舊版的 Python2 以及舊版的 V-rep 製作, 可以嘗試改為 Python3 以及 CoppeliaSim 4.1.0 rev1 版本相容.
Webots Inverted Pendulum:
https://robotbenchmark.net/benchmark/inverted_pendulum/
https://github.com/mdecourse/vrep-stuff
inverted pendulum system modeling
simulation of the inverted pendulum.pdf
solve the inverted pendulum problem using DQN algorithm
https://in.mathworks.com/help/control/ug/control-of-an-inverted-pendulum-on-a-cart.html
磁浮控制系統:
Magnetic levitation control.pdf
Controller Design for a Magnetic Levitation Kit usingOpenModelica’s Integration with the Julia Language.pdf
CoppeliaSim Lua feedback PID Control:
function saturate(x,thr)
if x>thr then return thr end
if x<-thr then return -thr end
return x
end
function PID_create(Kp,Ki,Kd)
pid={}
pid.pre_error=0.0
pid.integral=0.0
pid.Kp=Kp
pid.Ki=Ki
pid.Kd=Kd
return pid
end
function PID(pid, setpoint, actual_position, dt)
error=setpoint-actual_position
if pid.Ki>0.0 then
pid.integral=pid.integral+error*dt
end
derivative=(error-pid.pre_error)/dt
output=pid.Kp*error+saturate(pid.Ki*pid.integral,1000)+pid.Kd*derivative
output=saturate(output,2000)
pid.pre_error=error
return output
end
if (sim_call_type==sim.syscb_init) then
--graph=sim.getObjectHandle('Graph')
pjoint=sim.getObjectHandle('pjoint')
rjoint1=sim.getObjectHandle('rjoint1')
pad=sim.getObjectHandle('pad')
pidRot=PID_create(64.05,34.65,0.709)
pidPos=PID_create(54,0,0.629)
sim.addStatusbarMessage('angle controller = { P='..pidRot.Kp..' I='..pidRot.Ki..' D='..pidRot.Kd..' } horizontal controller = { P='..pidPos.Kp..' I='..pidPos.Ki..' D='..pidPos.Kd..' }')
end
if (sim_call_type==sim.syscb_actuation) then
dt=sim.getSimulationTimeStep()
u_angle=PID(pidRot, 0, sim.getJointPosition(rjoint1), dt)
u_pos=PID(pidPos, 0, sim.getJointPosition(pjoint), dt)
-- sim.setGraphUserData(graph,'e_ang',pid1.pre_error)
-- sim.setGraphUserData(graph,'e_pos',pid2.pre_error)
u=u_angle-u_pos
sim.setJointTargetVelocity(pjoint,u)
end
Ebooks <<
Previous Next >> CMSiMDE