V-REP 力傳感器配置 | Configuration of V-REP force sensor


V-REP
仿真中用到的文件資源請訪問Github:

https://github.com/zanebin/V-REP_Demo

力傳感器簡介

image-20190805112150509

一個力傳感器可以同時測出三個方向的力和力矩, VREP中力傳感器的一大用處就是用來測量機器人與外界環境交互時的接觸力,比如檢測機械手爪的夾持力或是機器人腳底的壓力分佈等信息。通常需要將力傳感器添加在末端(手指或腳底板上)然後再連接一個接觸體。

UR5模型中自帶一個名爲UR5_connection的ForceSensor

力傳感器參數設置

這裏模型的參數已經配置好,沒有其他需求的情況下暫時不需要修改。

參數設置如下:

Filter: when force or torque data is acquired by the force sensor, then it is accumulated and can be filtered in order to obtain less jittery values.

Sample size: the number of values that should be used for the filter. 1 will not filter values (raw output).

Average value: if selected, then the force sensor will deliver average values (average of sample size values).

Median value: if selected, then the force sensor will deliver median values (median of sample sizevalues).

Breaking settings: this section allows to set-up some automatic breaking conditions and behavior for a force sensor. Alternatively, the user can programmatically handle breaking conditions and behavior by accessing the appropriate functions.

Force threshold: the amplitude of the force vector that triggers a threshold violation.

Torque threshold: the amplitude of the torque vector that triggers a threshold violation

Consecutive threshold violations for breaking: the number of consecutive times the sensor is allowed to violate a threshold before breaking.

Object size: size of the sensor’s 3D representation. This has no functional effect.

Adjust color A / B: allows adjusting the two colors of a force sensor.

Graph輸出配置

1.添加Graph

打開scene——UR5PegInHole.ttt

仿真界面右鍵,Add-graph

2.參數設置

一個Graph可以選擇多個變量輸出

Python參數讀取

用simxReadForceSensor讀取
API定義如下:
image-20190731132103727

#!/usr/bin/env python
# encoding: utf-8

"""
The program is used to get the force sensor's force and torque.
Use the scene:UR5PegInHole2.ttt

@Author: Zane
@Contact: [email protected]
@File: forceSensor.py   
@Time: 2019-07-31 15:55
"""
import vrep
import sys
import numpy as np
import math
import matplotlib.pyplot as mpl
import time

##### Python connect to the V-REP client

print('Program started')
# Close potential connections
vrep.simxFinish(-1)

clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
print("Connection success")

# Start simulation
vrep.simxStartSimulation(clientID, vrep.simx_opmode_blocking)
print("Simulation start")

##### Definition of parameters
sensorName = 'UR5_connection'

##### Obtain the handle
errorCode, returnHandle = vrep.simxGetObjectHandle(clientID, sensorName, vrep.simx_opmode_blocking)
forceSensorHandle = returnHandle

print('Handles available!') 


##### Get the force sensor's force and torque
while vrep.simxGetConnectionId(clientID) != -1:
    # simx_opmode_streaming initialization, no values are read at this time
    errorCode,state,forceVector,torqueVector=vrep.simxReadForceSensor(clientID,forceSensorHandle,vrep.simx_opmode_streaming)
    # Can't read twice at the same time, otherwise you can't read the value.
    time.sleep(1)
    # simx_opmode_buffer to obtain forceVector and torqueVector
    errorCode,state,forceVector,torqueVector=vrep.simxReadForceSensor(clientID,forceSensorHandle,vrep.simx_opmode_buffer)
    # Output the force of XYZ
    print(forceVector)
    # Output the torque of XYZ
    print(torqueVector)

測試結果

image-20190731131933901

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章