40823112 cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • Introduction
  • Collaboration
  • Stage 1
    • W1
      • 利用SSH維護倉儲
      • 建立倉儲
      • 建立Leo編輯Palican
      • 協同倉儲
    • W2
      • Project production
      • 手繪草稿
      • 初步設計與討論
    • W3
      • 錯誤排解 齒輪方向與速度
      • 錯誤排解 傳動改正
      • 產品簡化
      • 完成品
    • W4
      • 2D工程圖
      • 3D爆炸圖
      • 產品設計報告與影片
  • Stage 2
    • W5
      • Stage2 Grouping
      • 進度規劃
    • W6
      • 討論
    • W7
      • Coppeliasim方向鍵操控模擬
      • 模擬問題與排解
    • W8
      • Coppeliasim避障自走車
      • 模擬問題和排解
    • W9
      • 產品報告與模擬影片
  • Stage 3
    • W10
      • Task 1
    • W11
      • task 2-1
      • task 2-2
    • W12
      • 上課直播
    • W13
      • 小組meeting直播
      • RobotDK
    • W14
      • MTB_Robot
    • W15
      • Geometry Translation
      • Algebra Translation
    • W18
    • Final Project
  • W16
  • Product Install
    • stage1-ag10
    • stage2-ag1
    • stage3-ag1
W8 << Previous Next >> 模擬問題和排解

Coppeliasim避障自走車

模擬影片

(🔽程式碼)

function sysCall_init()
     
     
end
 
function sysCall_actuation()
     
end
 
function sysCall_sensing()
     
end
 
function sysCall_cleanup()
     
end
 
 
 
function sysCall_afterDelete(inData)
    for key,value in pairs(inData.objectHandles) do
        print("Object with handle "..key.." was deleted")
    end
     
end
 
function sysCall_afterCreate(inData)
    for key,value in pairs(inData.objectHandles) do
        print("Object with handle "..value.." was created")
    end
end
--]]
function speedChange_callback(ui,id,newVal)
    speed=minMaxSpeed[1]+(minMaxSpeed[2]-minMaxSpeed[1])*newVal/100
end
 
function sysCall_init()
     
    bubbleRobBase=sim.getObjectAssociatedWithScript(sim.handle_self) 
    leftMotor=sim.getObjectHandle("bubbleRob_leftMotor") 
    rightMotor=sim.getObjectHandle("bubbleRob_rightMotor") 
    noseSensor=sim.getObjectHandle("bubbleRob_sensingNose") 
    minMaxSpeed={120*math.pi/180,300*math.pi/180} 
    backUntilTime=-1 
    
        xml = '<ui activate="false" closeable="false" resizeable="false" title="'..sim.getObjectName(bubbleRobBase)..' speed">'..[[
        <hslider id="1" maximum="100" minimum="0" onchange="speedChange_callback"></hslider>
        <label style="* {margin-left: 300px;" text=""></label>
        </ui>
        ]]
    ui=simUI.create(xml)
    speed=(minMaxSpeed[1]+minMaxSpeed[2])*1
    simUI.setSliderValue(ui,1,100*(speed-minMaxSpeed[1])/(minMaxSpeed[2]-minMaxSpeed[1]))
end
 
function sysCall_actuation()
    result=sim.readProximitySensor(noseSensor) 
     
    if (result>0) then backUntilTime=sim.getSimulationTime()+4 end 
 
    if (backUntilTime<sim.getSimulationTime()) then
         
        sim.setJointTargetVelocity(leftMotor,speed)
        sim.setJointTargetVelocity(rightMotor,speed)
    else
         
        sim.setJointTargetVelocity(leftMotor,-speed/5)
        sim.setJointTargetVelocity(rightMotor,-speed/200)
    end
end
 
function sysCall_cleanup()
    simUI.destroy(ui)
end




W8 << Previous Next >> 模擬問題和排解

Copyright © All rights reserved | This template is made with by Colorlib