cd2021 - 40823109

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • Stage1
    • W1
      • SSH setup
      • set website
    • W2
      • 草圖繪製
      • 3D圖繪製
    • W3
      • 3D爆炸圖與工作圖
      • 傳動設計修改
    • W4
  • stage2
    • W5
    • W6
    • W7
    • W8
    • W9
  • stage3
    • W10
      • task1
      • task2
    • W11
      • task 3
    • W13
    • W15
      • using geometry
      • using algebra
    • W16
      • 1. Onshape 零組件繪製
      • 2.建立 CoppeliaSim 4.1.0 MTB robot 場景
      • 3.手臂末端加入吸盤
      • 4.逆向運動學函式
      • 5.Python remote API 逆向運動學函式
    • 專案成果
  • w18
    • 期末報告影片
  • Questions and answers
    • ValueError
    • pip無法使用
    • leo 無法使用
stage2 << Previous Next >> W6

W5

Stage2 開始執行,討論後決定以第一組的專題主題繼續進行下去。

組別 : stage2-ag1

組員 : 40823145、40823108、40823112、40823109

為了讓模型能夠按照我們的意思做動,嘗試著編寫Lua程式並以方向鍵進行控制。

下方為第一次測試的程式

Lua程式:

threadFunction=function()
    -- put your actuation code here
 while sim.getSimulationState()~=sim.simulation_advancing_abouttostop do
    -- Read the keyboard messages (make sure the focus is on the main window, scene view):
        message,auxiliaryData=sim.getSimulatorMessage()
        while message~=-1 do
            if (message==sim.message_keypress) then
if (auxiliaryData[1]==2007) then
                -- up key
                velocity=1000
                torque=10000
                Shape4 = 1000
                Shape7 = 1000
            end
            if (auxiliaryData[1]==2008) then
                -- down key
                velocity=1000
                torque=10000
                Shape4 = 1000
                Shape7 = 1000
            end
            if (auxiliaryData[1]==2009) then
                -- left key
                velocity=1000
                torque=10000
                Shape4 = 1000
                Shape7 = 1000
            end
            if (auxiliaryData[1]==2010) then
                -- right key
                velocity=1000
                torque=10000
                Shape4 = 1000
                Shape7 = 1000
            end
        end
        message,auxiliaryData=sim.getSimulatorMessage()
    end
    if Shape4 == 1
        then sim.setJointPosition(joint_1, 1000, orientation)
    if Shape7 == 1
        then sim.setJointPosition(joint_2, 1000, orientation)
    end
        sim.setJointTargetVelocity(joint,velocity)
    end
        joint_1=sim.getObjectHandle('joint_1')
        joint_2=sim.getObjectHandle('joint_2')
        Shape4=sim.getObjectHandle('Shape4')
        Shape7=sim.getObjectHandle('Shape7')
        velocity=0
        torque=0
        Shape4 = 0
        Shape7 = 0
end

因部分語法有誤,日後待除錯。


stage2 << Previous Next >> W6

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