5.VREP常见问题2

7.关节力矩设置

1.在设置关节力矩时,力矩应当设置一个下限值,否则力矩太小,系统会失去控制。

图24  力矩设置演示对象

 

 

2.力矩函数调用的顺序

     如果直接调用sim.simxSetJointForce,而且规划出的力矩有过零点或者最终会变为零,那么关节系统也会因力矩为零失去控制。

     改善这一情形方法可以限定力矩范围。给出最小力矩和最大力矩的限定,可以让关节达到执行效果而且不会出现上述情形。

图25  关节力矩曲线图-1

 

 

给出最小限定力矩,需要根据物体本身所需的最小力矩给出。

给出最大力矩,可以根据轨迹规划的情况给出。

图26  关节力矩曲线图-2

 

 

如果是实际情形,必须考虑动力源的最大力矩。

力矩曲线

 图27  关节力矩曲线图-3

 

 

图28  关节力矩曲线图-4

 

 

图29  最终运动效果图

 

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.checkVisionSensorsim.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.getVisionSensorImagesim.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.
图30  URDF导入窗口

 

 

 

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。

图31  Import导入窗口-1

 

 

图32  Import导入窗口-2

 

图33  Import导入窗口-3

 

上图中的相关参数可以不设置,等到导入之后再根据实际需求进行调整。

posted @ 2020-12-19 16:28  秋风不识春  阅读(1244)  评论(0编辑  收藏  举报