LinuxCNC HAL #5: XBox controller, hal_input, and subroutines

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024

Комментарии • 26

  • @philb1466
    @philb1466 4 года назад +1

    To say there are nuggets of gold in your content would be a massive understatement, they are great big boulders! I searched for ages trying to find a decent "how to" W.R..T using an Xbox controller, then I found your channel; I got that but SO MUCH MORE besides! Now I've gone back to the first video and I'm really looking forward to all the cool stuff I'm going to learn from you. I have bunged $50 your way via P.P by way of thanks for the amazing content! So, again, huge thanks!

  • @CutterCo
    @CutterCo 10 месяцев назад

    Fantastic video. I learned a lot. Thank you!

  • @fanaakbarkan9304
    @fanaakbarkan9304 4 года назад

    Thanks for share this video. I use qjoypad too for my linuxcnc. Works great for me.

  • @keithscott9774
    @keithscott9774 Год назад +1

    Fantastic video, thanks very much. Bit off topic but I am always saddened when I see such a great educational video have only 99 likes after 3 years, whereas some meaningless video about absolute rubbish gets millions of likes. I made an educational video on inline boring (machining stuff) and I think most of the world, except for a few, were completely bored by it LOL.
    Well, I'm one of the few that thinks yours are awesome.

  • @Hossein_Ash
    @Hossein_Ash 2 года назад

    very cool. thanks

  • @fredfreund2096
    @fredfreund2096 4 года назад

    Great tutorial thank you again!
    I have a Xbox one controller with xpad driver.
    In jstest-gtk under mapping you see which button is BTN_A and so on.
    Need to implement now following your tutorial! (crosslaser already done!thx)

    • @swolebro
      @swolebro  4 года назад

      Really, with xpad? My system loads that module too, but still didn't show anything when I plugged in an XBox One controller and did an `lsusb`. Weird.
      Unfortunately, I don't have that controller for testing any more, since it was on loan from a friend. If you get yours working, please report back, and I might have a second try at it myself.
      Glad to hear your crosshairs are working. That's an extremely useful accessory, especially once you set up the shortcut buttons for removing the offset.

    • @fredfreund2096
      @fredfreund2096 4 года назад

      On the beginning I saw it in lsusb short, once only and then searched the problem which I identified the very long USB micro cable provided with it, switched to a shorter one both (two controllers) worked reliably.
      I also don't get a Xbox 360 controller to work. this one has also a long connection cable as well. (maybe the power provided on my USB outlet on the laptop is too low)
      Tried to get the Xbox one controller wireless as well which I failed.
      DEBIAN 10 mate desktop
      When using the xboxdrv I don't get it to work.
      Just verified xboxdrv shows BOTH 360 & one in lsusb , but jstest-gtk only the Xbox one with short cable.
      So seems xpad or xboxdrv, both work with the Xbox one on mine.

    • @swolebro
      @swolebro  4 года назад

      I didn't think to try multiple micro USB cables with the XBox One controller - might see if I can borrow another one, go through my pile of cables, and see if I an get any of them working. Of course, the problem might also be that I'm using LinuxCNC 2.7 (based on Debian 7), instead of one with a newer kernel. Lots of variables.
      If the XBox 360 controllers shows up in lsusb with the xboxdrv driver, does it also work wit QJoypad and hal_input? It may be jstest-gtk which is buggy and not seeing it.

    • @fredfreund2096
      @fredfreund2096 4 года назад

      @@swolebro I am trying to find the event created for the controller. I guess that is a js indicator. /dev/input/ list.
      sudo evtest /dev/input/event# one after the other.
      I go through all of them, 0 is Keyboard so I start from highest top.
      I have 4 Xbox 360 with two cables. On lsusb they show up then not, you move them around it's there, then gone again. I'd prefer those since the cable is so long 3m. I never got an event for them.
      Xbox one works and event created as well. Immediately a js0 event. Jstest /dev/input/js0 works.
      Qjoypad on opening claims an instant is already running so have to get rid of the process first. Never saw any of the devices there.
      I installed debian 10 and then buster buildbot installation 2.9version.(pause option!) start from line in gcode.
      Your idea to use github for Linuxcnc and a symlink! Best ever!
      Just came to my mind the Xbox 360 are wireless controllers with this funny USB connector, I guess those don't work at all.
      Even they are seen in lsusb.
      Xbox one is same wireless and wired in case.

  • @skt2287
    @skt2287 4 года назад

    In copper we trust.

  • @SkyscraperGuitars
    @SkyscraperGuitars 4 года назад

    I'm totally new to linux and I'm trying to get an xbox controller to work in path pilot for Tormach. From what I understand, Tormach stripped out Hal_input from their install. I'm trying to figure out where/how to get that piece installed. Next, I thought that Hal_input already had the needed code for the xbox controller. You are using QJoyPad. It looks like that doesn't have the sensitivity input from the joystick inputs for left, right, etc. Can you dumb this down for me? I hate that I don't understand the language for linux yet.. Thanks, Greg

    • @swolebro
      @swolebro  4 года назад +1

      Sure, happy to help. You're right in noticing that QJoyPad doesn't have any sensitivity controls beyond the on/off threshold I showed at 6:50. It's just emulating the keyboard arrow keys, and they don't have sensitivity either. I'm still using QJoyPad for the jogging/motion anyway, since it was less work to set up than all the hookups for doing it in HAL.
      I still do the XBox buttons in HAL, since those connections are much more straightforward, and you can do a lot more with that than you can with QJoyPad's dumb keyboard emulation.

    • @swolebro
      @swolebro  4 года назад +1

      For the missing hal_input component, as far as I can tell from my installation, and from the LinuxCNC installation scripts here:
      github.com/LinuxCNC/linuxcnc/blob/master/src/hal/user_comps/Submakefile#L14
      (Yes, that line of code is going to gibberish unless you speak Makefile. That's ok.)
      Mostly all it's doing is copying this file to where all your executable programs live in /usr/bin (basically the equivalent of Window's C:/Program Files):
      github.com/LinuxCNC/linuxcnc/blob/master/src/hal/user_comps/hal_input.py
      To be a bit more precise, if you had a copy of hal_input.py, then running these commands manually from a terminal should replicate what that makefile does.
      echo '#!/usr/bin/python' > hal_input.tmp
      sed '1 { /^#!/d; }' hal_input.py >> hal_input.tmp
      chmod +x hal_input.tmp
      sudo mv -f hal_input.tmp /usr/bin/hal_input
      The first two lines of that make a temporary copy of the file, and adjust the "shebang" line, which says which python you should use to run the program (since you can have multiple copies of python on your system). The third line changes the mode (chmod) of the file to be executable (+x), so Linux knows it isn't simply a text file, but a program you can run. The last line is what moves (mv) the temporary copy over to its final location, forcefully overwriting (-f) any copy that might already be there, and doing it as the superuser/admin (sudo) since it's touching system files.
      So, that *should* do it.. assuming Tormach hasn't mucked with the rest of the python installation too much. Hahah. But give it a shot, and if it doesn't work, we'll try some more troubleshooting.
      Also, give video 1(b) a watch if you haven't already, since I go over some of this Linux voodoo in that one. Should be helpful for someone who's new to this stuff.

    • @SkyscraperGuitars
      @SkyscraperGuitars 4 года назад

      @@swolebro Man!!! Thank you!!! I will attempt to get into this tonight when I can sit and concentrate. I'll get back to you with my results. This is wonderful! I'll take detailed notes so when I get something that works, I can share it with the youtube audience on my other channel: Greg's Garage. There are quite a few Tormach users over there and I know they'd love this type of functionality as well.f. Cheers!

    • @SkyscraperGuitars
      @SkyscraperGuitars 4 года назад +1

      And also... I will NOT take credit for all this. I'll let everyone know that you are the brains behind this operation and I'll send them your way. I watched a handful of the vids in your series, but I was up WAY too late trying to figure some of this stuff out. I'll go back again today with a fresh set of eyes and pay close attention to the details. Thanks again, you're a life saver. -Greg

    • @swolebro
      @swolebro  4 года назад

      The important part isn't the credit, it's getting people's machines running. It's not like I wrote any of the code for LinuxCNC/HAL. All I've done is spend the time to grok it, and try to break it down into manageable chunks.
      When all this virus panic blows over, I should have some limited access to a Tormach at a local university, and I'll be a bit more familiar with their quirks. I know a postdoc who works in the lab, and he was helping set it up just before campus shut down. I was so looking forward to taking that thing for a test drive...
      And I've definitely seen that "Shit Welders Say" video before. That one's a classic. Hahah.

  • @kevinharder289
    @kevinharder289 4 года назад

    Thanks for the tutorial, QjoyPad seemed to install ok and there is a game controller icon on the top bar, but when I right click the icon to setup the controller it tells me to plug in a controller, but it is already plugged in. In terminal I ran lsusb and the controller is listed there, would you have any suggestions as what to try next. Thank you.

    • @swolebro
      @swolebro  4 года назад

      Right-click or left-click? Usually you left-click to bring up the layout/configuration menu, but if you just plugged the controller in, that will bitch at you until you right-click it and choose "update joystick devices." I have yet to see the right-click menu bring up any error dialogs at all.
      Check that again, and if that doesn't work, try launching it from the commandline with the "--device" (from the manpage) and see if it gives you any better debug info. Let me know how it goes for you.

    • @kevinharder289
      @kevinharder289 4 года назад

      You are correct left click brings up no joystick devices available even after right click to update joystick devices. I tried qjoypad _ _device/dev/input, doesn’t output anything, I opened file system,dev,input and I don’t see anything about joystick or anything related to that.

    • @swolebro
      @swolebro  4 года назад

      Huh, so there's no /dev/input/js0, but the controller shows up with you do an lsusb? What about lsmod? (I got joydev and xpad showing up in mine.)
      If you look at the comments from Fred Freund, he seemed to find it working with both xpad and xboxdrv drivers, but then had sporadic issues with longer cables. And then I had sporadic issues with that knock-off controller of mine.
      What controller do you have exactly?

    • @kevinharder289
      @kevinharder289 4 года назад

      i am using an xbox 360 controller,lsmod shows only joydev, I have tried different usb ports and rebooted

    • @swolebro
      @swolebro  4 года назад

      Hm. You on LinuxCNC 2.7.14? Because xpad is installed by default on that, and should load automatically.
      Check if `locate xpad.ko` brings anything up. Should find a file under "/something/module/something/drivers/something/". If it does, then `sudo modprobe xpad` will load it, and you should be able to unplug/replug the controller, refresh in QJoypad, then be on your way.
      If you're not seeing xpad installed on your system, next step would be to look that up, then try.
      If it's installed, but loading xpad explicitly still doesn't work, then he next step would be to see if you can bum another controller off a gamer buddy and try that. Make sure isn't your controller acting wonky.