NFU-MDE-40823108-KAO,YU-CHE-cd2021

  • Home
    • Site Map
    • reveal
    • blog
  • Introduction
  • KMOLab basis
    • Cmsimde create
    • Python program
    • SSH key produce
    • SSH putty settings
    • Leo Edit Blog
    • Leo Edit Reveal
    • Synergy
  • Coppeliasim basic
    • Import objects
    • Divide object
    • Appearance setting
    • Joint settings
    • Orchestration objects
    • Proximity sensor
  • Midterm
    • W1
    • W2
    • W3
      • work
    • W4
    • W5
    • W6
    • W7
    • W8
    • W9
  • Final
    • W10-task1
    • W11-task2
    • W12-task3
    • W13
    • W14
    • W15
    • W16
    • W17
    • W18
  • Stage1-ag1
  • Stage2-ag1
  • Stage3-ag1
  • phone webcam
    • ios for Webcam
    • Android for Webcam
  • Github sever issue
W5 << Previous Next >> W7

W6

經過一週的時間,我們將程式進行了修改,但還是有錯誤,無法讓機構以上下左右鍵的方式進行控制。

下方為模擬圖:

第二次Lua程式測試:

function sysCall_init()
    -- do some initialization here
    left_front_handle= sim.getObjectHandle('left_front')
    left_back_handle= sim.getObjectHandle('left_back')
    right_back_handle= sim.getObjectHandle('right_back')
    right_front_handle= sim.getObjectHandle('right_front')
    
    joint_1_handle= sim.getObjectHandle('joint_1')
    
    joint_2_handle= sim.getObjectHandle('joint_2')
    MaxVel=10
    leftvelocity=0
    rightvelocity=0
    dVel=0.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()
    -- put your actuation code here
    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)
                
                
                sim.setJointForce(joint_1_handle, 1000)
                
                sim.setJointForce(joint_2_handle, 1000)
                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)
            
            sim.setJointForce(joint_1_handle, 0)
            
            sim.setJointForce(joint_2_handle, 0)
            end
            if (auxiliaryData[1]==2007) then
                -- up key
                leftvelocity=(leftvelocity+rightvelocity)/2
                rightvelocity=leftvelocity
                leftvelocity=leftvelocity+dVel
                rightvelocity=rightvelocity+dVel
            end
            if (auxiliaryData[1]==2008) 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

function sysCall_sensing()
    -- put your sensing code here
end

function sysCall_cleanup()
    -- do some clean-up here
end

-- See the user manual or the available code snippets for additional callback functions and details

第二次程式失敗,日後將持續進除錯。


W5 << Previous Next >> W7

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