WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-29-2015, 02:38 AM
lalechuza lalechuza is offline
Member
 
Join Date: Jun 2015
Posts: 7
sensor radius bug?

Hey there!

I am using the circleArea proximity sensor so one can "collect" objects.
I want the difference between the radius of the object and the radius of the sensor to be constant. Therefore I pass the radius of the object plus my constant value to the circleArea sensor and then link the sensor to the object.
Before you start the programm you can change the transformation of the object that will be "collected".
Now here is my Problem:
When I scale the object the sensor is much bigger (or smaller) as it should be. I think its because I linked the sensor and the object. But I need the link so I can easily let the object disappear, when someone "collects" it.

To show my problem I wrote an example, where I just pass a constant to the sensor and it still gets much bigger as the one of the non-scaled object:

Code:
import viz
import vizshape
import vizproximity

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

viz.MainView.setPosition(0,5,-4)
viz.MainView.setEuler(0,45,0)

manager = vizproximity.Manager()
#to see the circleArea
manager.setDebug(viz.ON)

purpleCylinder = vizshape.addCylinder(height=2.0,radius=0.3,topRadius=None,bottomRadius=None,yAlign=vizshape.ALIGN_MIN,slices=20,bottom=True,top=True)
purpleCylinder.color(viz.PURPLE)
purpleCylinder.setPosition(-2.5,0,0)
#non-scaled purple cylinder
purpleSensor = vizproximity.CircleArea(radius=0.7)
#link sensor to the object
linkedPurpleSensor = vizproximity.Sensor(purpleSensor, purpleCylinder)
manager.addSensor(linkedPurpleSensor)
print 'purple: ', linkedPurpleSensor

redCylinder = vizshape.addCylinder(height=2.0,radius=0.3,topRadius=None,bottomRadius=None,yAlign=vizshape.ALIGN_MIN,slices=20,bottom=True,top=True)
redCylinder.color(viz.RED)
redCylinder.setPosition(1,0,0)
#scale the second red cylinder up
redCylinder.setScale(4,4,4)
redSensor = vizproximity.CircleArea(radius=0.7)
#link sensor to the object
linkedRedSensor = vizproximity.Sensor(redSensor, redCylinder)
manager.addSensor(linkedRedSensor)
print 'red: ', linkedRedSensor
the print says the radius is the same in both:
purple: Sensor(shape=CircleArea(radius=0.7, center=(0.0, 0.0)), source=NodeSource(node=viz.VizPrimitive(2), flag=4, name=''))
red: Sensor(shape=CircleArea(radius=0.7, center=(0.0, 0.0)), source=NodeSource(node=viz.VizPrimitive(4), flag=4, name=''))

Can someone tell me what happened? Am I doing something wrong or is it a bug?
Reply With Quote
  #2  
Old 07-29-2015, 04:39 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
One solution would be to avoid linking the sensor and the 3d node.

When you create a sensor, you can specify a 3d node as its source. This way, you can make the 3d node disappear by calling the source of the activated sensor and let it disappear

Below is a small example:

Code:
# create ball and sensor
ball = vizshape.addSphere(radius = 10)
ballSensor = vizproximity.Sensor(vizproximity.CircleArea(10),source=ball)


# wait for sensor to be activated, can be a list of sensors
enteredSensor = yield vizproximity.waitEnter(ballSensor)

# get 3d node of ball and let it disappear
ball = enteredSensor.sensor.getSource()
ball._node.visible(viz.OFF)

Last edited by mape2k; 07-29-2015 at 04:44 AM.
Reply With Quote
  #3  
Old 07-29-2015, 05:32 AM
lalechuza lalechuza is offline
Member
 
Join Date: Jun 2015
Posts: 7
I thought that was exactly what I've done? I just wrote the sources name instead of writing source=sourceName. Am I missing something?
However, it comes to the same result: The sensors have different sizes, although the passed radius is the same.
Reply With Quote
  #4  
Old 07-30-2015, 01:17 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
True! Sorry, I did not try out your code and replied only to the text you wrote.

With normal linking, you can specify a mask to only link position, orientation, etc. With sensor linking, that does not seem to be possible.

Maybe one of the devs could shed some light into this?
Reply With Quote
  #5  
Old 07-30-2015, 03:55 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Thanks for the example script that reproduces the issue. I'll ask a developer to take a look.
Reply With Quote
  #6  
Old 08-04-2015, 02:43 PM
lalechuza lalechuza is offline
Member
 
Join Date: Jun 2015
Posts: 7
Thank you!
Could you please let me know what the developer said? I really got to get this working because we would like to use it for a study
Reply With Quote
  #7  
Old 08-04-2015, 04:23 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
As a workaround, would the following work for you? This sets a group node to be the sensor's source object. The red cylinder is linked to the group node and scaling the cylinder does not affect the area shape:

Code:
import viz
import vizshape
import vizproximity

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

import vizcam
cam = vizcam.PivotNavigate(center=[1,0,0],distance=5)
cam.rotateUp(30)

manager = vizproximity.Manager()
#to see the circleArea
manager.setDebug(viz.ON)

redCylinder = vizshape.addCylinder(height=2.0,radius=0.3,topRadius=None,bottomRadius=None,yAlign=vizshape.ALIGN_MIN,slices=20,bottom=True,top=True)
redCylinder.color(viz.RED)

group = viz.addGroup(pos=[1,0,0])
viz.link(group,redCylinder)

#scale the second red cylinder up
redCylinder.setScale(2,2,2)
redSensor = vizproximity.CircleArea(radius=0.7)

#link sensor to the object
linkedRedSensor = vizproximity.Sensor(redSensor, group)
manager.addSensor(linkedRedSensor)
Reply With Quote
  #8  
Old 08-25-2015, 05:57 AM
lalechuza lalechuza is offline
Member
 
Join Date: Jun 2015
Posts: 7
Hey Jeff!
I guess this workaround wouldn't work for me, because there is a various number of cylinders placed in my setting and every cylinder has its own proximitysensor. I don't know how I could get the right cylinder to an activated sensor with that kind of linking. Maybe you have an idea to this?
Anyway, I've got a solution that is not very performant but it works well enough for me:
The sensores are placed at the same position like the cylinders. When setting the sensors the source is NONE, so that the sensores will not be affected by the scaling of the cylinders.
Next I just set up a list of tuples with the sensor as the first part of the tuple and the object as the second, so when a sensor is activated I can find it in that list with the right object and delete the object and the sensor.

Could you still let me know what the developer said to the bug or when it is going to work?

Thank you for your help
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


All times are GMT -7. The time now is 04:39 AM.


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