7.關節力矩設置
1.在設置關節力矩時,力矩應當設置一個下限值,否則力矩太小,系統會失去控制。

2.力矩函數調用的順序
如果直接調用sim.simxSetJointForce,而且規划出的力矩有過零點或者最終會變為零,那么關節系統也會因力矩為零失去控制。
改善這一情形方法可以限定力矩范圍。給出最小力矩和最大力矩的限定,可以讓關節達到執行效果而且不會出現上述情形。

給出最小限定力矩,需要根據物體本身所需的最小力矩給出。
給出最大力矩,可以根據軌跡規划的情況給出。

如果是實際情形,必須考慮動力源的最大力矩。
力矩曲線



8.VREP 視覺傳感器
調用simReadVisionSensor來獲取連通域信息,Packet2中將包含如下數據:
Packet2 = {blob count, dataSizePerBlob, blob1 size, blob1 orientation, blob1 position x, blob1 position y, blob1 width, blob1 height, blob2 size,blob2 orientation, blob2 position x, blob2 position y, blob2 width, blob2 height,...}
simReadVisionSensor / sim.readVisionSensor
Description |
Reads the state of a vision sensor. This function doesn't perform detection, it merely reads the result from a previous call to sim.handleVisionSensor (sim.handleVisionSensor is called in the default main script). See also sim.checkVisionSensor, sim.checkVisionSensorEx and sim.resetVisionSensor. |
C synopsis |
simInt simReadVisionSensor(simInt visionSensorHandle,simFloat** auxValues,simInt** auxValuesCount) |
C parameters |
visionSensorHandle: handle of a vision sensor object auxValues: by default CoppeliaSim returns one packet of 15 auxiliary values:the minimum of {intensity, red, green, blue, depth value}, the maximum of {intensity, red, green, blue, depth value}, and the average of {intensity, red, green, blue, depth value}. Additional packets can be appended in the vision callback function. AuxValues can be NULL. The user is in charge of releasing the auxValues buffer with simReleaseBuffer(*auxValues). auxValuesCount: contains information about the number of auxiliary value packets and packet sizes returned in auxValues. The first value is the number of packets, the second is the size of packet1, the third is the size of packet2, etc. Can be NULL if auxValues is also NULL. The user is in charge of releasing the auxValuesCount buffer with simReleaseBuffer(*auxValuesCount).
See simHandleVisionSensor for a usage example |
C return value |
detection state (0 or 1), or -1 in case of an error, or if simHandleVisionSensor was never called, or if simResetVisionSensor was previously called. |
Lua synopsis |
number result,table auxiliaryValuePacket1,table auxiliaryValuePacket2, etc.=sim.readVisionSensor(number visionSensorHandle) |
Lua parameters |
visionSensorHandle: handle of a vision sensor object |
Lua return values |
result: detection state (0 or 1), or -1 in case of an error, or if sim.handleVisionSensor was never called, or if sim.resetVisionSensor was previously called. auxiliaryValuePacket1: default auxiliary value packet (same as for the C-function) auxiliaryValuePacket2: additional auxiliary value packet (e.g. from an image processing component) auxiliaryValuePacket3: etc. (the function returns as many tables as there are auxiliary value packets) |
Remote API equiv.
|
B0-based remote API: simxReadVisionSensor Legacy remote API: simxReadVisionSensor |
simGetVisionSensorCharImage / sim.getVisionSensorCharImage
Description |
Retrieves the rgb-image (or rgba, or a portion of it) of a vision sensor. The returned data doesn't make sense if sim.handleVisionSensor wasn't called previously (sim.handleVisionSensor is called by default in the main script if the vision sensor is not tagged as explicit handling). See also sim.getVisionSensorImage, sim.setVisionSensorCharImage and sim.saveImage. |
C synopsis |
simUChar* simGetVisionSensorCharImage(simInt sensorHandle,simInt* resolutionX,simInt* resolutionY) |
C parameters |
sensorHandle: handle of the vision sensor. Can be combined with sim_handleflag_greyscale (simply add sim_handleflag_greyscale to sensorHandle), if you wish to retrieve the grey scale equivalent. resolutionX/resolutionY: the returned vision sensor resolution |
C return value |
image buffer (buffer size is resolutionX*resolution*3 or resolutionX*resolutionY in case of a grey scale image retrieval) or NULL in case of an error. The user is in charge of releasing the returned buffer with simReleaseBuffer. Returned values are in the range of 0-255 (0=min. intensity, 255=max. intensity) |
Lua synopsis |
string imageBuffer,number resolutionX,number resolutionY=sim.getVisionSensorCharImage(number sensorHandle,number posX=0,number posY=0,number sizeX=0,number sizeY=0,number rgbaCutOff=0) |
Lua parameters |
sensorHandle: handle of the vision sensor. Can be combined with sim.handleflag_greyscale (simply add sim.handleflag_greyscale to sensorHandle), if you wish to retrieve the grey scale equivalent. posX / posY: position of the image portion to retrieve. Zero by default. sizeX / sizeY: size of the image portion to retrieve. Zero by default, which means that the full image should be retrieved rgbaCutOff: when different from zero, then an RGBA image is returned, where the alpha component will be 255 for all depth values below rgbaCutOff, and 0 for all depth values above rgbaCutOff. 0 corresponds to the near clipping plane, 1 to the far clipping plane. Zero by default. |
Lua return values |
imageBuffer: nil in case of an error. Otherwise a string containing rgb (or rgba) values (table size is sizeX*sizeY*3 (or sizeX*sizeY*4 in case of rgba), rgb(a) values in the range 0-255). In case of a grey scale image retrieval, the image buffer will contain grey values or grey+alpha values in the range 0-255. |
Remote API equiv. |
B0-based remote API: simxGetVisionSensorImage Legacy remote API: simxGetVisionSensorImage |
9.VREP導入URDF問題
導入路徑不要有中文。否則會報錯。
導入步驟:
一、SW模型導出為URDF文件
URDF是機器人數據插件,SW默認沒有。需要下載URDF,
http://wiki.ros.org/sw_urdf_exporter
然后安裝,再進入SW插件設置,打開URDF插件。
SW加載好URDF插件之后,在設計---文件下找到。
點擊導出,構建導出關節文件,即可。
注意設置合理的joint坐標系和joint軸。
二、VREP導入URDF文件
VREP下,點擊插件,找到URDF,即可導入。
URDF importer plugin
The URDF file format (*.urdf) is supported for import operations via a plugin coutesy of Ignacio Tartavull: simExtUrdf. If the URDF plugin was correctly loaded, you can access the plugin dialog via [Menu bar --> Plugins --> URDF import...]:
[URDF plugin dialog]
- Assign collision links to layer 9: hides collision links in layer 9 (layer 9 is off by default).
- Assign joints to layer 10: hides joints in layer 10 (layer 10 is off by default).
- Convex decompose non-convex collision links: decomposes non-convex respondable shapes into convex shapes. This item should always be checked, since convex shapes perform faster and are more stable during dynamic collision response calculations.
- Show convex decomposition dialog: allows to adjust the way how the convex decomposition operates.
- Create visual links if none: creates an artificial visual element if the link doesn't define one.
- Center model above ground: centers the imported model above the ground.
- Prepare model definition if feasable: tags the root object as "model base" and adapts the other objects accordingly (e.g. clicking an object in the model will select the whole model instead of an individual object).
- Alternate local respondable masks: when checked, alternates the local collision masks so that adjacent respondable shapes won't react to collision. If unckecked, then all respondable shapes will only react to collision with objects outside of the model.
- Enable position control for revolute and prismatic joints: if checked, then revolute and prismatic joints will be in position control mode. Joint force/torque and upper regulation velocity are taken from the URDF file.
- Import: triggers an import operation.

Assign collision links to layer 9 |
|
Assign joints to layer 10 |
|
Convex decompose non-convex collision links |
|
Show convex decomposition dialog |
|
Create visual links if none |
|
Center model above ground |
|
Prepare model definition if feasable |
|
Alternate local respondable masks |
|
Enable position control for revolute and prismatic joints |
|
Import |
|
10.VREP導入STL文件
將准備好的STL文件放置於無中文字符的路徑下。點擊VREP中的file。按圖選擇,之后點擊選擇文件,之后有出現shape的屬性設置問題。Mesh files支持obj、dxf、ply、stl、dae。



上圖中的相關參數可以不設置,等到導入之后再根據實際需求進行調整。