Vismach - The easist example

More
3 years 7 months ago #267132 by zz912
Hello,

I am trying make something "Hello to world" for Vismach.
Code:
#imports from vismach import * import hal #create the HAL component and pins comp = hal.component("vismach-example") comp.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN) comp.newpin("joint1", hal.HAL_FLOAT, hal.HAL_IN) comp.newpin("joint2", hal.HAL_FLOAT, hal.HAL_IN) #create the floor, tool and work floor = Box(-50, -50, -3, 50, 50, 0) work = Capture() tooltip = Capture() #Build and assemble the model part1 = Collection([Box(-6,-3,94,6,3,100)]) #part1 = Color([1,1,1,1],[part1]) #part1 = HalRotate([part1],comp,"joint0",360,0,0,1) #part1 = Translate([part1],-1,49,0) #create a top-level model model = Collection([part1]) #Start the visualization main(model, tooltip, work, 100)


but it returns:
Code:
halcmd: loadusr vismach-example halcmd: Exception in Tkinter callback Traceback (most recent call last):   File "/usr/lib/python3.7/tkinter/__init__.py", line 1705, in __call__     return self.func(*args)   File "/home/zdenek/linuxcnc/linuxcnc-2.9_2023-03-15/lib/python/rs274/OpenGLTk.py", line 374, in tkExpose     self.tkRedraw()   File "/home/zdenek/linuxcnc/linuxcnc-2.9_2023-03-15/lib/python/rs274/OpenGLTk.py", line 351, in tkRedraw     self.redraw()   File "/home/zdenek/linuxcnc/linuxcnc-2.9_2023-03-15/lib/python/vismach.py", line 820, in redraw     view2work = invert(self.work2view.t)   File "/home/zdenek/linuxcnc/linuxcnc-2.9_2023-03-15/lib/python/vismach.py", line 668, in invert     inv[0][1],inv[1][0] = inv[1][0],inv[0][1] IndexError: list index out of range

Please Log in to join the conversation.

More
3 years 7 months ago #267174 by Aciera
Replied by Aciera on topic Vismach - The easist example
part1 = Collection([Box(-6,-3,94,6,3,100)])

model = Collection([part1])

If I am not mistaken the 'Collection' function expects two or more list entries while you pass only one item

[edit]
Maybe try:

part1 = Box(-6,-3,94,6,3,100)

model = part1

Please Log in to join the conversation.

More
3 years 7 months ago #267210 by zz912
Replied by zz912 on topic Vismach - The easist example
I changed it:
Code:
#!/usr/bin/env python3 #imports from vismach import * import hal #create the HAL component and pins comp = hal.component("vismach-example") comp.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN) comp.newpin("joint1", hal.HAL_FLOAT, hal.HAL_IN) comp.newpin("joint2", hal.HAL_FLOAT, hal.HAL_IN) #create the floor, tool and work floor = Box(-50, -50, -3, 50, 50, 0) work = Capture() tooltip = Capture() #Build and assemble the model part1 = Box(-6,-3,94,6,3,100) #create a top-level model model = part1 #Start the visualization main(model, tooltip, work, 100)

But it returns the same thing. 

It's weird that lineardelta.py and others Vismach work.
When I started building the new Vismach, I started trimming lineardelta.py. Fortunately after deleting many lines it stopped working.

So I wanted to do it the other way around and I exited this example and it also fails.
linuxcnc.org/docs/2.9/html/gui/vismach.h..._of_a_vismach_script

Please Log in to join the conversation.

More
3 years 7 months ago #267211 by zz912
Replied by zz912 on topic Vismach - The easist example
It wooooorrkkkksssss !!!
Code:
#!/usr/bin/env python3 #imports from vismach import * import hal #create the HAL component and pins comp = hal.component("vismach-example") comp.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN) comp.newpin("joint1", hal.HAL_FLOAT, hal.HAL_IN) comp.newpin("joint2", hal.HAL_FLOAT, hal.HAL_IN) #create the floor, tool and work floor = Box(-50, -50, -3, 50, 50, 0) work = Capture() tooltip = Capture() #Build and assemble the model part1 = Box(-6,-3,94,6,3,100) #create a top-level model model = Collection([part1, floor, tooltip, work]) #Start the visualization main(model, tooltip, work, 100)

"model" must contain "tooltip, work"

Please Log in to join the conversation.

More
3 years 7 months ago #267218 by Aciera
Replied by Aciera on topic Vismach - The easist example
Yes the model must contain 'work' and 'tooltip'. Note though that usually you would not add the two to the same body. Here is an example:
Code:
#!/usr/bin/env python3 #imports from vismach import * import hal #create the HAL component and pins comp = hal.component("vismach-example") comp.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN) comp.ready() #create the floor, tool and work tooltip = Capture() tool = CylinderZ(0, 1, 20, 1) tool = Color([1,0,0,0],[tool]) tool = Collection([tooltip, tool]) tool = Translate([tool],0,0,150) work = Capture() part = Box(-50, -50, 0, 50, 50, 100) part = Collection([work, part]) #create a top-level model model = Collection([tool, part]) #Start the visualization #main(model, tooltip, work) main(model, tooltip, work, 400)

Please Log in to join the conversation.

More
3 years 7 months ago #267221 by zz912
Replied by zz912 on topic Vismach - The easist example
So far I manage to create what I need.
 

Attachment not found



But I absolutely do not understand what the tooltip and work is good for.

In manual is only:
  • Code:
    main(model, tooltip, work, size=10, hud=0, rotation_vectors=None, lat=0, lon=0)
    This is the command that makes it all happen, creates the display etc.
    • model should be a collection that contains all the machine parts.
    • tooltip and work need to be created by
      Code:
      Capture()
      to visualize their motion in the back plot.
      See
      Code:
      scaragui.py
      for an example of how to connect the tool tip to a tool and the tool to the model.
    • Either rotation_vectors or latitude/longitude can be used to set the original viewpoint and it is advisable to do as the default initial viewpoint is rather unhelpfully from immediately overhead.
    • size sets the extent of the volume visualized in the initial view.
    • hud refers to a head-up display of axis positions.
I can integrate the tooltip into my code, but it doesn't do anything.
Code:
#!/usr/bin/env python3 #imports from vismach import * import hal X0 = -300 #create the HAL component and pins c = hal.component("tripteron-gui") c.newpin("joint0", hal.HAL_FLOAT, hal.HAL_IN) c.newpin("joint1", hal.HAL_FLOAT, hal.HAL_IN) c.newpin("joint2", hal.HAL_FLOAT, hal.HAL_IN) #create the floor, tool and work floor = Box(-500, -100, -3, 500, 100, 0) work = Capture() tooltip = Capture() #define colour red = (1,.5,.5,0) green = (.5,1,.5,0) blue = (.5,.5,1,0) #Build and assemble the model carriage0 = Collection([Box(-30,-20,-3,30,20,3)]) carriage0 = Color(red,[carriage0]) carriage0 = Translate([carriage0],-100+X0,0,-5) carriage0 = HalTranslate([carriage0], c, "joint0", 1, 0, 0) carriage1 = Collection([Box(-30,-20,-3,30,20,3)]) carriage1 = Color(green,[carriage1]) carriage1 = Translate([carriage1],100+X0,-50,-5) carriage1 = HalTranslate([carriage1], c, "joint1", 1, 0, 0) carriage2 = Collection([Box(-30,-20,-3,30,20,3)]) carriage2 = Color(blue,[carriage2]) carriage2 = Translate([carriage2],100+X0,50,-5) carriage2 = HalTranslate([carriage2], c, "joint2", 1, 0, 0) head = Collection([     tooltip,     Box(-30,-30,0,30,30,-30)]) head = Translate([head],X0,0,-100) #create a top-level model model = Collection([floor, carriage0, carriage1, carriage2, head, tooltip, work]) #Start the visualization main(model, tooltip, work, 1200, lat=-120, lon=30)

 

Please Log in to join the conversation.

More
3 years 7 months ago #267224 by Aciera
Replied by Aciera on topic Vismach - The easist example
As I understand it, 'tooltip' and 'work' are used by OpenGL for it's matrix transformations. The Backplot line in vismach shows the movment of the tooltip in reference to the work. This of course is only visible when there is a connection to a running linuxcnc instance with halpins.

Please Log in to join the conversation.

More
3 years 7 months ago #267225 by zz912
Replied by zz912 on topic Vismach - The easist example
The problem is that 'tooltip' and 'work' do not create any HALpins. Look at the screenshot of my screen that I gave above.

Please Log in to join the conversation.

More
3 years 7 months ago #267228 by Aciera
Replied by Aciera on topic Vismach - The easist example
Why would you expect 'tooltip' and 'work' to create halpins? They are only for the vismach model internals.

Please Log in to join the conversation.

More
3 years 7 months ago #267236 by zz912
Replied by zz912 on topic Vismach - The easist example
Because you wrote:

This of course is only visible when there is a connection to a running linuxcnc instance with halpins.

Please Log in to join the conversation.

Time to create page: 0.062 seconds
Powered by Kunena Forum