40823148cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • stage1
    • stage1工作內容
    • stage1後記
  • stage2
    • stage2工作內容
    • stage2後記
  • stage3
    • stage3工作內容
    • stage3後記
  • 個人作業
    • SSH
    • 機械手臂控制
      • Lua程式控制
      • Lua鍵盤控制
      • python remote api
    • stage1四驅車延伸
      • 鍵盤控制
      • python remote api 控制
  • 使用軟體
stage3 << Previous Next >> stage3後記

stage3工作內容

本次作業目標為讓四腳獸站立並用鍵盤控制。

此專案分為多個版本 如下

第一版(原版)

此版沿用上次專案之模型場景,並試著將設定更改嘗試讓它直線行走。

多方嘗試後發現,四足在站立上極限,行走上支撐度不足,故研究多足排列組合嘗試。

3D圖▼

coppliasim組合圖▼

第一版模擬影片▼

第二版(六足排列)

此版改為六足橫向排列,以增加腳觸地時的支撐點。

此版前後依舊維持兩連動腳,前後容易造成翻滾,故改變其排列組合。

3D圖▼

coppliasim組合圖▼

第二版模擬影片▼

第三版(前後四足八腳)

此版改為前後八腳板,此版利用兩連動腳組成一組,排列成四方四足。

此版模擬時發現關節連接處並未依照預期情況支撐住,故思考是否為零件立體化設計問題。

3D圖▼

coppliasim組合圖▼

第三版模擬影片▼

老師範例模擬影片▼

鍵盤控制研究

為達到鍵盤控制目的,故開始研究鍵盤控制程式。

下列使用簡易機構研究。

簡易圖▼

程式碼▼

function sysCall_init() 
    left_front_handle= sim.getObjectHandle('left_m')
    left_back_handle= sim.getObjectHandle('left_m')
    right_back_handle= sim.getObjectHandle('right_m')
    right_front_handle= sim.getObjectHandle('right_m')
    MaxVel=20
    leftvelocity=0
    rightvelocity=0
    dVel=5;
    --sim.setJointTargetVelocity(left_front_handle,leftvelocity)
    sim.setJointTargetVelocity(left_back_handle,leftvelocity)
    sim.setJointTargetVelocity(right_back_handle,rightvelocity)
    --sim.setJointTargetVelocity(right_front_handle,rightvelocity)
end

function sysCall_actuation() 
    message,auxiliaryData=sim.getSimulatorMessage()
    while message~=-1 do
        if (message==sim.message_keypress) then
            if (auxiliaryData[1]==32) then
                -- right key
                leftvelocity=0
                rightvelocity=0
                sim.setJointForce(left_front_handle, 0)
                sim.setJointForce(left_back_handle, 0)
                sim.setJointForce(right_back_handle, 0)
                sim.setJointForce(right_front_handle, 0)
                break
            else
                --sim.setJointForce(left_front_handle, 10000)
                sim.setJointForce(left_back_handle, 10000)
                sim.setJointForce(right_back_handle, 10000)
                --sim.setJointForce(right_front_handle, 10000)
            end
            if (auxiliaryData[1]==2008) then
                -- up key
                leftvelocity=(leftvelocity+rightvelocity)/2
                rightvelocity=leftvelocity
                leftvelocity=leftvelocity+dVel
                rightvelocity=rightvelocity+dVel
            end
            if (auxiliaryData[1]==2007) then
                -- down key
                leftvelocity=(leftvelocity+rightvelocity)/2
                rightvelocity=leftvelocity
                leftvelocity=leftvelocity-dVel
                rightvelocity=rightvelocity-dVel
            end
            if (auxiliaryData[1]==2009) then
                -- left key
                leftvelocity=leftvelocity-dVel
                rightvelocity=rightvelocity+dVel
            end
            if (auxiliaryData[1]==2010) then
                -- right key
                leftvelocity=leftvelocity+dVel
                rightvelocity=rightvelocity-dVel
            end
        end
        message,auxiliaryData=sim.getSimulatorMessage()
    end
    
    if leftvelocity>MaxVel then
        leftvelocity=MaxVel
    end
    if leftvelocity<-MaxVel then
        leftvelocity=-MaxVel
    end
    
    if rightvelocity>MaxVel then
                rightvelocity=MaxVel
    end
    if rightvelocity<-MaxVel then
                rightvelocity=-MaxVel
    end
    
    --sim.setJointTargetVelocity(left_front_handle,leftvelocity)
    sim.setJointTargetVelocity(left_back_handle,leftvelocity)
    sim.setJointTargetVelocity(right_back_handle,rightvelocity)
    --sim.setJointTargetVelocity(right_front_handle,rightvelocity)
    
end 

 

鍵盤控制模擬影片▼

成果影片▼


stage3 << Previous Next >> stage3後記

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