WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-23-2015, 03:22 PM
Daniel Daniel is offline
Member
 
Join Date: Jun 2013
Posts: 7
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
Reply With Quote
  #2  
Old 07-24-2015, 11:44 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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.
Reply With Quote
  #3  
Old 07-24-2015, 02:14 PM
Daniel Daniel is offline
Member
 
Join Date: Jun 2013
Posts: 7
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
Reply With Quote
  #4  
Old 07-28-2015, 05:06 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #5  
Old 07-29-2015, 09:41 AM
Daniel Daniel is offline
Member
 
Join Date: Jun 2013
Posts: 7
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
Reply With Quote
  #6  
Old 09-24-2015, 02:31 PM
Daniel Daniel is offline
Member
 
Join Date: Jun 2013
Posts: 7
Could you please help me to attach the pencil tool to an osgb object?
Reply With Quote
  #7  
Old 09-25-2015, 12:45 AM
Samuli Samuli is offline
Member
 
Join Date: Aug 2015
Posts: 15
Have you tried to modify the pencil example code like this:
Code:
robot=viz.add('your_robot_name.osgb')
...
arrowLink = viz.link(mouseTracker,robot)
Reply With Quote
  #8  
Old 09-25-2015, 10:43 AM
Daniel Daniel is offline
Member
 
Join Date: Jun 2013
Posts: 7
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
Reply With Quote
  #9  
Old 10-08-2015, 03:53 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can parent or link the pencil tool to any node in Vizard.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rotate object around mainView? performlabrit Vizard 3 12-19-2013 06:31 AM
How to render a texture of the transparent object and then blur it whj Vizard 1 09-25-2012 03:15 PM
AMD graphics hardware seems not to preload object sleiN13 Vizard 2 03-20-2012 06:08 AM
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM


All times are GMT -7. The time now is 12:27 PM.


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