• 您的位置(zhì):首頁 > 新聞動態 > Unity3D

    在虛擬裝配應用中,用數據手套實現擰(nǐng)螺絲(sī)動作

    2019/6/16      點擊:

    遇到有客戶在使用Wiseglove數據手套開發機械裝配相(xiàng)關應用時,要(yào)實現數(shù)據手套擰(nǐng)螺絲的動作,客戶認為wiseglove7s+手套擰了一個角度,但是螺絲(sī)並(bìng)沒有按照預想的方向旋轉。我們經過研究後,認(rèn)為實現該功能需要具備以下條件:

    1. 手模型與螺絲有碰撞觸(chù)發(fā)

    2. 數據手套有抓取動作

    3.數據手套有釋放動作

    使用了Unity3d的觸發器檢測手與物體的碰撞狀態。

    private void OnTriggerEnter(Collider other)
    {
      print("Enter trigger");
      Oldpos = Leftobject.transform.position;
    }
    private void OnTriggerStay(Collider other)
    {
    //手套抓取
    if(wiseglove.grasp)
    {
      print("grasp");
      float yAixsval = Vector3.Angle(Vector3.ProjectOnPlane(Leftobject.transform.position, Vector3.up),Vector3.right) - Vector3.Angle(Vector3.ProjectOnPlane(Oldpos,Vector3.up),Vector3.right);
      Vector3 deltaAngles = new Vector3(0,uAxisval,0);
      transform.eulerAngles +=deltaAngle;
      Oldpos = Leftobject.transform.position;
    }
    else {
      print("open hand");
      Oldpos = Leftobject.transform.position;
    }
    }
    private void OnTriggerExit(Colloder other)
    {
      print("Exit");
      Oldpos = Leftobject.transform.position;
    }

    當然如果需(xū)要螺絲(sī)沿著平麵的法向隨(suí)著旋(xuán)轉有位移,似乎也不難~~

    這裏主要的技巧就是: Vector3.ProjectOnPlane( Vector3 vectorVector3 planeNormal) 得到投(tóu)影向量 為(wéi)vector到以planeNormal為法向量的平麵上。求的是一向(xiàng)量與(yǔ)一(yī)平麵的夾角。這也是讓物體沿著指定軸旋(xuán)轉的關鍵所在。

    怎麽樣,小夥伴們(men)會了嗎? 感謝關注Wiseglove, 我們將(jiāng)一如既往(wǎng)地把我們為客戶解決的技術問(wèn)題發(fā)布到我們(men)的官(guān)網,來分享關於數據手套的技術和心(xīn)得。

    91影视免费版下载-91麻豆国产福利精品-91麻豆精品一二三区在线-国产91系列视频在线观看