How to emulate a xbox 360 controller in Ubuntu 16.04 - python

I am a windows 10 user and using wsl to run ubuntu 16.04 to use ROS without a virtual machine.Now I need to use a jotstick to control a robot simulation in gazebo but the problem is wsl doesn't support usb joysticks yet. I have tried USBIP and it doesn't work without wsl2.
So I used inputs library to get data from joystick and using socket to "transmit" and then "receive" and print the data in a script running in the wsl terminal. I am sending the data whenever a joystick event occurs.I am planning to use the received data to emulate a xbox 360 controller.
I have looked into the evdev library but failed to find documentation on how to emulate xbox 360 controller. Is there any better way to do it?

Related

Bluetooth inputs form wireless devices

I have a pair of Bluetooth earbuds that have touch capabilities to pause and play music and it works fine on my win 10 pc. So, I am trying to make a small python script that triggers an event on receiving signals from the earbuds as I had heard that python 3.9 now supports Bluetooth for windows 10. So is there any way to receive those signals in python? I have tried wire shark but it does not detect any Bluetooth devices at all .
What I have tried:
pybluez (doesn't work for win 10)
sockets (it requires a client program installed on the other device which is not possible)

Remote bluetooth camera trigger for phone

I would like to build a camera trigger for my phone by simulating a BLE keyboard that sends the Volume Up key to the phone connected by Bluetooth. I want this because I want to trigger the native Camera app, and not an embedded camera view.
I'm agnostic about technology used but ideally for simplicity I'd like it to be a command line utility in my Macbook, with something like Go or Node.js.
I've looked into Noble for Node.js, which doesn't seem to be oriented at emitting, and found projects for arduino, and found a couple of StackOverflow questions asking the same, but nothing definitive yet.
Apparently the Bleno project for Node.js could be better suited, but apparently it's very outdated.
Would someone please point me in the right direction?
Thank you
Edit
I was able to use Bleno to emit 0xEA and 0xE9 (Volume Up and Volume Down apparently), and using the LightBlue app I'm able to inspect that receive those messages, however, connecting to the MacBook through the phone's bluetooth does not increase/decrease volume.
Edit
Found this outdated project written in Swift 3 for reference
Edit Apparently the pybluez project looks like it could be a good option
You should be able to use the terminal for that. Eg. in Windows, you can start the camera app using start microsoft.windows:camera
Something similar should be available even in Mac. Try that out. Otherwise, go to the root directory where the camera app is stored. And then trigger that from code.
You need to create a Bluetooth HID (or HID over GATT) peripheral that your phone can connect to and will receive the key commands from.
There is a project here that did it with a Raspberry Pi:
https://gist.github.com/ukBaz/a47e71e7b87fbc851b27cde7d1c0fcf0#gistcomment-2997623
Unfornately the underlaying Bluetooth library will not move across to your Mac Book.
The HID protocol is documented here: https://github.com/jpbrucker/BLE_HID/blob/master/doc/HID.md
In summary, I think what your saying is that you want to make an cli application which is on your laptop/desktop connect to your phone via Bluetooth and simulate a volume key from your laptop/desktop keyboard.
Android:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
Android Studio
Java Development Kit 8 (preferably 11 or 14)
Android BLE
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Android BLE and then simulates the volume button press.
DISCLAIMER:
This only works when the phone is already paired to your pc and only work on android phones 4.4.4 and above.
Some Links That Could Help You:
Bluetooth lib for python 3 ,
detect key press in python? ,
Create a socket for 4.0 bluetooth transmission
IOS:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
XCode
Swift
Core Bluetooth Module
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Core Blutooth Module in swift and then simulates the volume button press.
DISCLAIMER:
The phone and laptop/desktop must be paired before it runs this might sound obvious but some people might ignore this.
Some Links That Could Help You:
iOS use the volume buttons as input ,
https://developer.apple.com/documentation/corebluetooth/transferring_data_between_bluetooth_low_energy_devices

How to find a radio on a Linux Machine using Python and OpenCV

Hello I'm doing a home project where I want to use two radios: one connected directly to an FPV camera and one connected to a Linux laptop via USB.
The thing that's getting me stumped is finding the radio on my Ubuntu 16.04 Linux machine via Python.
I know there is Mission Planner used specifically for telemetry and FPV data but I also want to analyze the video using OpenCV. I have it working with the camera connected to the laptop directly but not with any radios.
Looking around the internet I've seen people mention ttyAMA0 in the /dev directory but when I use that as an argument for the OpenCV function VideoCapture() it throws an exception and says it can't open the video. Same thing when I just put in 0 or 1. (my laptop doesn't have a webcam but just in case I tried both)
I also have a version of my code in C++ if anyone knows that way instead.
Any help would be appreciated.
Ashley

Programmatically manipulating active RDP session

I've got Mac OSX running and want to programmatically manipulate a active RDP session to for instance, perform actions within a launched program within the session (dynamics specifically, yet woudn't hurt to know a universal way).
I don't know if this is possible. Currently using a RDP file to launch the RDP session with credentials and have the process ID of my active session, retrieved via NSWorkspace. With that I can do the basic stuff like closing my session again, yet i want to manipulate the session.
My RDP client currently is Microsoft Remote Desktop.
Would wish to reach my goal in either bash or python.
Here are few ideas:
Use Quartz graphics library in Python to manipulate with RDP client window. Here is a good start: How to list all windows from all workspaces in Python on Mac?
Use libfreerdp via ctypes.
Run RDP session under Wine and use tools such as AutoHotKey, AutoIT or xdottool. See: How to programmatically control X11 forwarded apps?
Use WinRM (pywinrm) instead of RDP to run remote commands/scripts. Check this example. This can allow to run auto tools mentioned above (e.g. AHK script controlling the apps).
Use Python GUI automation library for simulating user interaction in apps.
See also: GUI scipting for Linux.
Write an RDP client that dumps the pixels of the screen. E.g. WebRTC or using libFreeRDP.
If RDP client runs via X11 protocol (Quartz), you can try to tap into X11 requests as per this post.
Use FreeRDP and its API. Its client is compatible with Linux, macOS and Windows.

How to send data from Windows to embedded linux over USB

My setup looks like this: A 64-bit box running Windows 7 Professional is connected to a Beaglebone running Angstrom Linux.
I'm currently controlling the beaglebone via a putty command line on the windows box.
What I'd like to do is run an OpenCV script to pull some vision information, process it on the windows box, and send some lightweight data (e.g a True or False, a triplet, etc.) over the (or another) USB connection to the beaglebone.
My OpenCV program is running using Python bindings, so any piping I can do with python would be preferable. I've played around with pyserial to receive data on a windows box via a COM port, so it seems like I could use that on the windows side... at a total loss though on the embedded linux front
Normally on the linux front, if the usb dongle is of the right type, you will see something like /dev/usbserial or similar device. Maybe check dmesg after plugging the cable.
(on linux you can run find /dev | grep usb to list all usb related devices)
Just a side note, I've seen the beaglebone has an ethernet port, why not just using a network socket? It's all easier than reinventing a protocol on usb.
If you want to use python, take a look o PyUSB, as you can see for example in Sending data via USB using PyUSB. A related post is PyUSB for the Raspberry Pi.

Categories

Resources