WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Drawing trajectory of an object (https://forum.worldviz.com/showthread.php?t=5412)

Daniel 07-23-2015 03:22 PM

Drawing trajectory of an object
 
It is possible to attach the pencil tool to an object and draw its trajectory?

Or there is a better way to do that??

I'm doing a robot kinematic simulator and I want to display the end effector trajectory

Jeff 07-24-2015 11:44 AM

Yes, you can link the pencil tool to any object. You could either activate the pencil draw command with an input signal (mouse button, keypress, etc.) or have it draw continuously.

Daniel 07-24-2015 02:14 PM

Hi Jeff, thank you for your answer

Could you please show me an example of a pencil attached to an object and drawing continuosly? Because I can't make it work properly

Jeff 07-28-2015 05:06 PM

Take a look at the pencil documentation for commands available. The following example script executes the draw command continuously:

Code:

""" 
Right mouse button clears the drawing. 
Middle mouse button changes color. 
Mouse movements control viewpoint orientation. 
Arrow Keys control viewpoint position. 
"""

import viz
import vizshape
import vizinfo
vizinfo.InfoPanel(align=viz.ALIGN_LEFT_BOTTOM)

viz.setMultiSample(4)
viz.fov(60)
viz.go()

piazza = viz.add('piazza.osgb')
arrow = vizshape.addArrow(length=0.2, color = viz.RED)

from tools import pencil
tool = pencil.Pencil()

# update code for pencil
def update(tool):

        state = viz.mouse.getState()
        if state & viz.MOUSEBUTTON_RIGHT:
                tool.clear()
        elif state & viz.MOUSEBUTTON_MIDDLE:
                tool.cycleColor()
        else:
                tool.draw()

tool.setUpdateFunction(update)

#Link the pencil tool to an arrow 
#Then move the arrow in the reference frame of the viewpoint
from vizconnect.util import virtual_trackers
mouseTracker = virtual_trackers.ScrollWheel(followMouse = True)
mouseTracker.distance = 1
arrowLink = viz.link(mouseTracker,arrow)
arrowLink.postMultLinkable(viz.MainView)
viz.link(arrowLink,tool)

import vizcam
vizcam.FlyNavigate()

#Hide the mouse cursor
viz.mouse.setVisible(viz.OFF)


Daniel 07-29-2015 09:41 AM

Thank you Jeff, but what I can't do is to attach the pencil to an osgb object (in this case the robot end effector), how can I do that?

Thank you in advance

Daniel 09-24-2015 02:31 PM

Could you please help me to attach the pencil tool to an osgb object?

Samuli 09-25-2015 12:45 AM

Have you tried to modify the pencil example code like this:
Code:

robot=viz.add('your_robot_name.osgb')
...
arrowLink = viz.link(mouseTracker,robot)


Daniel 09-25-2015 10:43 AM

I've tried it , but if you add mousetracker , I end up drawing with the mouse.

What I want is to attach the pencil to the end of the robot and the pencil draw the trajectory of the robot end effector

Jeff 10-08-2015 03:53 PM

You can parent or link the pencil tool to any node in Vizard.


All times are GMT -7. The time now is 06:02 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC