Most people need draw trajectories of robots' motion as the results of research.
However, the default screenshoot tool in Coppeliasim will lose them. It is quite inconvenient.
I have to use other screenshoot software to record the scene, but it cannot get high-quality picture.
I suggest the coppeliasim can provide more convenient and good way to output picture of scene.
I suggest the Drawing Curve should be reversed when screenshooting.
Re: I suggest the Drawing Curve should be reversed when screenshooting.
You can replace drawing objects with shapes if you want to have them in 3D output.
Re: I suggest the Drawing Curve should be reversed when screenshooting.
There was a start to offer the same functionality via shapes... hopefully that will make it into the next release. Here the related code:
Cheers
Code: Select all
function sim.addDrawingObject(type, size, duplicateTolerance, parentHandle, maxItems, color)
if not _S.realDrawingObjects then
_S.realDrawingObjects = {}
_S.realDrawingObjects_nh = 1000000
end
local cyclic = (type & sim.drawing_cyclic) ~= 0
if cyclic then
type = type - sim.drawing_cyclic
end
local localCoord = (type & sim.drawing_local) ~= 0
if localCoord then
type = type - sim.drawing_local
end
local item = {objects = {}, cyclic = cyclic, localCoord = localCoord, type = type, size = size, tol = duplicateTolerance, parent = parentHandle, maxItems = maxItems, color = color}
local h = _S.realDrawingObjects_nh
_S.realDrawingObjects_nh = _S.realDrawingObjects_nh + 1
_S.realDrawingObjects[h] = item
return h
end
function sim.addDrawingObjectItem(handle, data)
if handle >= 1000000 and _S.realDrawingObjects then
local multiple = (handle & sim.handleflag_addmultiple) ~= 0
if multiple then
handle = handle - sim.handleflag_addmultiple
end
if (handle & sim.handleflag_codedstring) ~= 0 then
handle = handle - sim.handleflag_codedstring
data = sim.unpackFloatTable(data)
end
local item = _S.realDrawingObjects[handle]
if item then
if data and next(data) then
local newShapes = {}
function createTube(coord1, coord2, diameter)
diameter = diameter or 0.005
local retVal = -1
local v1 = Vector3(coord1)
local v2 = Vector3(coord2)
local dv = v2 - v1
local length = dv:norm()
if length > 0.001 then
local dw = dv / length
local a = math.acos(dw[3])
retVal = sim.createPrimitiveShape(sim.primitiveshape_cylinder, {diameter, diameter, length}, 4 + 8)
local p = sim.getObjectPosition(retVal)
sim.setObjectPosition(retVal, {p[1], p[2], p[3] + length * 0.5})
sim.relocateShapeFrame(retVal, {0, 0, 0, 0, 0, 0, 1})
if dw[3] < 0.9999 then
local np = sim.rotateAroundAxis({0, 0, 0, 0, 0, 0, 1}, {1, 0, 0}, {0, 0, 0}, a)
a = math.pi * 0.5 + math.atan2(dw[2], dw[1])
np = sim.rotateAroundAxis(np, {0, 0, 1}, {0, 0, 0}, a)
sim.setObjectPose(retVal, np)
sim.setObjectPosition(retVal, coord1)
end
end
return retVal
end
if item.type == sim.drawing_spherepts then
if not multiple then
data = {data[1], data[2], data[3]}
end
for i = 0, #data//3 - 1, 1 do
local c = {data[i * 3 + 1], data[i * 3 + 2], data[i * 3 + 3]}
if item.localCoord then
c = sim.multiplyVector(sim.getObjectPose(item.parent), c)
end
local addIt = true
if item.tol > 0 then
local p0 = Vector3(c)
for j = 1, #item.objects, 1 do
local p = Vector3(sim.getObjectPosition(item.objects[j]))
if (p-p0):norm() < item.tol then
addIt = false
break
end
end
end
if addIt then
local h = sim.createPrimitiveShape(sim.primitiveshape_spheroid, {item.size, item.size, item.size})
sim.setObjectPosition(h, c)
if item.parent ~= -1 then
sim.setObjectParent(h, item.parent)
end
newShapes[#newShapes + 1] = h
if #item.objects >= item.maxItems then
item.objects[#item.objects + 1] = h
else
if not item.nextIndex then
item.nextIndex = 1
end
sim.removeObjects({item.objects[item.nextIndex]})
item.objects[item.nextIndex] = h
item.nextIndex = item.nextIndex + 1
if item.nextIndex > item.maxItems then
item.nextIndex = 1
end
end
end
end
end
for i = 1, #newShapes, 1 do
sim.setObjectColor(newShapes[i], 0, sim.colorcomponent_ambient_diffuse, item.color)
sim.setObjectSpecialProperty(newShapes[i], 0)
end
else
sim.removeObjects(item.objects)
item.objects = {}
item.nextIndex = nil
end
end
end
end
function sim.removeDrawingObject(handle)
if handle >= 1000000 and _S.realDrawingObjects then
local item = _S.realDrawingObjects[handle]
if item then
sim.removeObjects(item.objects)
_S.realDrawingObjects[handle] = nil
end
end
end