Jog Speed slider

More
22 Mar 2022 13:55 - 22 Mar 2022 13:57 #238010 by Nebur
Jog Speed slider was created by Nebur
I'm playing around with some physical controls to control stuff.

Most of the sliders in axis reflect on halui-pins and vice versa (e.g. overrides and max velocity).
The jog speed slider seems to be an exception.

I would have expected that moving the slider changes related halui-pins (halui.joint.J.jog-speed, halui.axis.N.jog-speed) but it doesn't.

Basically I want _one_  jog-speed that applies to
  • (+/-)-jogging from the axis-ui & keyboard cursor keys and
  • as well to my physical external buttons.

    It seems obvious that this should be possible / desirable!

    Currently jogging e.g. with the keyboard adheres to the speed on the jog-speed slider and using my external jog-button uses  'my' halui jog-speed.

    Basically different jog-buttons move the machine at different speeds which is inconvenient, confusing and potentially dangerous.

    Pointers in the right direction would be much appreciated.
Last edit: 22 Mar 2022 13:57 by Nebur. Reason: typos

Please Log in or Create an account to join the conversation.

More
23 Mar 2022 01:49 #238069 by cmorley
Replied by cmorley on topic Jog Speed slider
Linuxcnc doesn't have global jog speed/increment settings.
Each user interface has it's own concept of jog controls.

It's often a pain in the ass.

AXIS has a jog increment HAL pin but not a jog speed pin.
You could probably add it with some custom code.
it would probably be better if we added the pin officially.
The following user(s) said Thank You: Nebur

Please Log in or Create an account to join the conversation.

More
23 Mar 2022 16:22 - 23 Mar 2022 17:10 #238113 by Nebur
Replied by Nebur on topic Jog Speed slider
Thanks. I managed to add an I/O pin for the jog speed. It stays in sync with the slider and allows to r/w the jog speed.
It's quite a messy hack and consists of more comments than code in order to remember what I did and why.
It would be great if the pin would be added officially as you suggested.

In the meantime here is the python code, in case somebody else needs the functionality:
################################################################################################
# Description:
#     This script creates a HAL pin to read/write the jog speed selected in the axis ui.
#     It allows to access the ui jog speed via HAL (e.g. keep the ui in sync with physical
#     jog speed controls and vice-versa).
#    
#     HAL pin:
#         Name: axisui.jog.speed
#         Type: float
#         Direction: I/O
#
#        Compatibility:         
#            Tested on LinucCNC 2.8.2 only
#
#        Usage:
#            Set this file as the user command file in the ini's display section. See docs for details.
#                [DISPLAY]
#                USER_COMMAND_FILE = axis_hal_jog_speed.py
#
#            If a user command file is already in use, just merge the code accordingly:
#                - HalJogspeed.init() must be called in user_hal_pins()
#                - HalJogspeed.update() must be called in user_live_update()
#                - class HalJogspeed must be in scope
#     Note:
#         The jog speed slider moves in steps and has a max and min value.
#            Writing a value to the hal pin will select the nearest possible slider step    and then update
#            the hal pin to the resulting slider value.
#         The hal pin will also 'self correct' it's value to stay in the configured jog speed bounds
#            of the Axis-ui.
################################################################################################

# axis user callbacks, see docs
def user_hal_pins():
    HalJogspeed.init()

def user_live_update():
    HalJogspeed.update()

# keep axis namespace tidy
class HalJogspeed:
    @staticmethod
    def init():
        # create and init hal pin with current ui jogspeed
        comp.newpin("jog.speed", hal.HAL_FLOAT, hal.HAL_IO)
        comp["jog.speed"] = vars.jog_speed.get()
        
        ### hook into slider change callback
        # make python function availabe to tk
        nf.makecommand(root_window, "jogspeed_slider_change", HalJogspeed.__slider_change)
        
        # redirect the change callback
        root_window.tk.eval("${pane_top}.jogspeed.s configure -command jogspeed_slider_change")
    
    @staticmethod
    def update():
        # bail if hal pin is in sync with jog speed var
        if comp["jog.speed"] == vars.jog_speed.get(): return
        
        # write hal pin value to the jog speed var
        vars.jog_speed.set(comp["jog.speed"])

        # update the slider
        root_window.tk.eval("${pane_top}.jogspeed.s set [setval $jog_speed $max_speed]")
            
        # debug
        print "[HalJogspeed] HAL -> UI", vars.jog_speed.get()
        
    @staticmethod
    def __slider_change(val):
        # call the original tk callback; this will update the jog_speed var
        root_window.tk.call("update_jog_slider_vel", val)
        
        # write resulting jog speed to the hal pin
        comp["jog.speed"] = vars.jog_speed.get()
        
        # debug
        print "[HalJogspeed] UI -> HAL", vars.jog_speed.get()

Attachments:
Last edit: 23 Mar 2022 17:10 by Nebur. Reason: attached file
The following user(s) said Thank You: cakeslob, Unlogic

Please Log in or Create an account to join the conversation.

More
09 Feb 2023 03:39 #264096 by foxkid
Replied by foxkid on topic Jog Speed slider
I am trying to implement this for an addition to the axis UI.  I downloaded the code file, as is, and linked it with the "USER_COMMAND_FILE=<name>" option.

Using Machine/Show Hal Configuration, I do not see the new pin.  I verified that I am reading the file by adding a syntax error, and the error was reported.  I "added" another pin with a different name, and I don't see that pin either.

I am running the sim_9axis.ini configuration on a VirtualBox installation of Linux/AXIS version 2.8.4-1-gb7824717b.

Where should I debug next?
 

Please Log in or Create an account to join the conversation.

More
10 Feb 2023 03:48 #264198 by cmorley
Replied by cmorley on topic Jog Speed slider
I would start by adding print statements to user_hal_pins() then user_live_update()
to prove they are called.

Also check that the pin isn't created with a different prefix then axisui.

Please Log in or Create an account to join the conversation.

More
10 Feb 2023 05:07 #264202 by foxkid
Replied by foxkid on topic Jog Speed slider
Indeed, you are right! It was created with the pyvcp prefix.
Next I'll see if I can change the prefix to something else. Each bit of info opens doors.

Please Log in or Create an account to join the conversation.

More
10 Feb 2023 05:19 #264203 by cmorley
Replied by cmorley on topic Jog Speed slider
comp.setprefix('mypin')

Please Log in or Create an account to join the conversation.

More
10 Feb 2023 15:57 #264229 by cakeslob
Replied by cakeslob on topic Jog Speed slider
Do you have a pyvcp with your current axis config? That usually causes the halpins to be renamed pyvcp instead of axisui

I think Phil fixed this, but it might be in 2.9

Please Log in or Create an account to join the conversation.

More
12 Feb 2023 13:33 - 12 Feb 2023 13:37 #264354 by Nebur
Replied by Nebur on topic Jog Speed slider
Wish I could help, but I'm still on 2.8.2 with currently no test machine at hand to do any experiments. On that version the script works as expected.
The whole thing is highly dependent on axis.tcl and axis.py and kind of a 'hack', so any changes that might have happened from 2.8.2 to 2.8.4 can affect the script.

As already suggested, 'print-debugging' through stuff makes sense.
Last edit: 12 Feb 2023 13:37 by Nebur.

Please Log in or Create an account to join the conversation.

Time to create page: 0.122 seconds
Powered by Kunena Forum