在虛擬裝配應用中,用數(shù)據(jù)手套實現(xiàn)擰螺絲動作
2019/6/16??????點擊:
遇到有客戶在使用Wiseglove數(shù)據(jù)手套開發(fā)機械裝配相關(guān)應用時,要實現(xiàn)數(shù)據(jù)手套擰螺絲的動作,客戶認為wiseglove7s+手套擰了一個角度,但是螺絲并沒有按照預想的方向旋轉(zhuǎn)。我們經(jīng)過研究后,認為實現(xiàn)該功能需要具備以下條件:
1. 手模型與螺絲有碰撞觸發(fā)
2. 數(shù)據(jù)手套有抓取動作
3.數(shù)據(jù)手套有釋放動作
使用了Unity3d的觸發(fā)器檢測手與物體的碰撞狀態(tài)。
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;
}
當然如果需要螺絲沿著平面的法向隨著旋轉(zhuǎn)有位移,似乎也不難~~
這里主要的技巧就是: Vector3.ProjectOnPlane( Vector3 vector,Vector3 planeNormal) 得到投影向量 為vector到以planeNormal為法向量的平面上。求的是一向量與一平面的夾角。這也是讓物體沿著指定軸旋轉(zhuǎn)的關(guān)鍵所在。
怎么樣,小伙伴們會了嗎? 感謝關(guān)注Wiseglove, 我們將一如既往地把我們?yōu)榭蛻艚鉀Q的技術(shù)問題發(fā)布到我們的官網(wǎng),來分享關(guān)于數(shù)據(jù)手套的技術(shù)和心得。
- 上一篇:Intel RealSense D435i深度相機開發(fā)基礎(chǔ) 2019/7/2
- 下一篇:UNITY3D 相機特寫鏡頭的方位設(shè)置 2019/6/13
