-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Bluetooth Joystick to mobile VR set #86
Comments
@AndriyPt, Do I understand you correctly that you suggest to use the Web Bluetooth API? It's still being developed and not a standard yet. https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API |
@MaxZhaloba I do not have any preference in solutions. Feel free to choose any :) |
At first it appeared to me, that the most straightforward way will be just to initialise the Blutooth connection between the joystick and the robot. This will eliminate the necessity to implement the Web BT API, which is currently a very new standard. It's not supported by Safari so far, and the support in Chrome might vary between platform and OS version (if supported in iOS or requires Android 6+ only), so this question needs investigation. But, on second thought, I realised that we cannot connect the joystick to robot, because the Blutooth radius is too short (typically up to 10 meters) and the robot can be located on a great distance from operator. So, joystick needs to be connected to the VR smartphone in any case. And the phone will send the joystick data to the robot via WiFi. This means that Web BT is again an option for us (option 1). Otherwise we will need to develop (or find and reuse) a dedicated mobile application (option 2) that will perform one of the following: So, for the beginning, I'm going to investigate:
@AndriyPt, how does this all sound to you? |
@MaxZhaloba sounds good to me. Also I would check how web browser is reacting on joystick commands. Maybe it could read some key pressed events. |
I've just tested the BT joystick on iOS 11.2.6. It reacts only to pressing the front bottom button (button 2) and button B. Other buttons adjust the volume or give no response. So, all browsers (Safari, Chrome and Firefox) return such object on keydown event:
The kypress data is practically identical for both buttons and on all browsers:
I've also noticed a difference in handling of button 2 and button B. When joystick is paired with smartphone, and I disable the bluetooth connection, then enable it and the phone connects to joystick, those two buttons act for adjusting the volume just as other buttons. When I leave the blutooth connection enabled, switch off the joystick and then switch it on, I get a popup message on my phone, stating that joystick wants to initiate the connection. After I allow it, button B and button 2 start to trigger the events in browsers. To summarise, this approach doesn't work for us, because most buttons do not trigger browser events, neither the X/Y manipulator does. |
@MaxZhaloba please check specification of the joystick here https://www.kotulas.com/wcsstore/KotulaStorefrontAssetStore/images/pdf/54632.pdf |
Hooray! This joystick recognizes all buttons and the X/Y thumbstick in additional modes. It triggers 3 events (keydown, keypress, keyup) when I press any key, and then 3 events again when I release it. The Here's the detailed info. Each key pressing typically triggers 2 keypress events which are sent when the corresponding button is pressed and released. This data is collected in iOS Safari.
Legend: It seems that the thumbstick supports a kind of differentiation in movement. Also, there's memory which is seemingly designed to initiate continuous movement, e.g. in some cases |
ROS Control looks interesting, but unfortunately I don't have any Android device to test it. I'd like to come up with solution that would support the BT joystick on iOS too. |
It turns out that Web Bluetooth is not supported under iOS by any browser so far (status). Actually, there's one program which implements support in iOS. Interestingly, it's open-source but costs 2$ in AppStore. Also, Google Chrome supports Web BT only on sites downloaded via HTTPS (source). Web BT can be tested using these pages. It seems that we won't be able to utilise this technology at the moment. |
I've googled the word combination "bluetooth over ip" (exact match). It turns out to be rather a theoretical thing, and nobody has implemented this so far. Here's a stackoverflow thread with the reasoning. So, at the bare minimum, the app on the phone will need to recognise the joystick and send its data in some other format than encapsulated bluetooth. |
@AndriyPt, what if we use another phone with gyro and magnetometer to control the robot? I think it might produce even better user experience than a real joystick with thumbstick. It's more intuitive to rotate and tilt the phone in your hands rather than to use a thumbstick, especially when you're in VR and you don't see it. Nowadays not everyone has a joystick, but it's easy to find another phone or lend it from your relatives :) And this will be easier in terms of implementation, since we already know that reading from IMU works well in web pages. And it's cross-platform. I'd prefer to focus on this approach as primary instead of the original request. This will work better for the demo and can make an impression. |
I can see 3 options:
|
@SystemDiagnosticss Do you have Android phone? This might be good demo for presentation. I guess for now it could be limited to Andoid phones. |
@AndriyPt Yes :) |
@AndriyPt, Why don't you like an approach with second phone to control the robot? If you'd still like to use the approach with hardware joystick I can implement it for the one that you gave me using the |
@MaxZhaloba for demo purposes I would like to have bluetooth joystick integrated. |
@SystemDiagnosticss, when you'll be adding joystick key mappings please implement them as JS arrays (e.g.: |
This issue has 2 open branches in repository: F#86_bt_joystick and F86_bluetooth_joy. @SystemDiagnosticss, is it ok to continue the development in F86_bluetooth_joy? |
@MaxZhaloba in this brunch (F86_bluetooth_joy) old version vr.js and main.js . I think better solution for you is create new branch for this issue |
@AndriyPt, We've investigated the availability of Gamepad API using our BT joystick on different platforms with @SystemDiagnosticss. We used such tools as https://html5gamepad.com/ and http://luser.github.io/gamepadtest/. Here are our results.
I'm doubtful whether this issue is something to do with this particular joystick or all BT joysticks in iOS. I think we need another BT joystick to compare the results since Can I Use clearly states that iOS is supported. If testing with another joystick wouldn't make any difference then such coverage won't make it possible to support the iOS at the moment and – for me – to develop the joystick configuration tool. So, I'm not sure if we could stick to Gamepad API in this case. We might limit the support to Android devices and extend the support when Gamepad API becomes available on iOS. |
@MaxZhaloba thank you for good analysis. I guess sticking with Android for now is good idea. |
@SystemDiagnosticss, are the more recent version of these libraries already in kinetic-devel? If so, then they should have been updated when I've merged it into F86_bluetooth_joy. |
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
@AndriyPt This feature is implemented on the whole. I saved the configuration data to local storage (several lines of code) to make it running. I'd prefer a separate task for backend storage functionality or combination of both storage options to keep this issue from bloating. There's one issue with the joystick I ended up applying a workaround so far. Axis #9 gives some unuseful data and misleads the configuration routine. Ideally, I'd like to ignore the data from this axis somehow. Currently this scenario is resolved with magic number at config.js line 265. Please let me know if you have any ideas how to approach this issue.
To facilitate the testing of configuration wizard on PC I added the keypress handlers for such keys: Enter, Space, Backspace and letter R. At this stage the wizard allows to assign only one button or thumbstick movement for each robot action. We can extend this functionality in future. Remaining subtasks required to finish this task:
Other related functionality (good to have at some point):
Please let me know what you think on this matter. |
@MaxZhaloba thank you for detailed report. |
@AndriyPt, Gamepad API represents joystick state as number of buttons and axes. Axes have a number and a value in range [-1; 1]. It could have been sufficient to use 2 axes for this gamepad but in fact it's represented with 10. Axes ## 0 and 1 return continuous readings for horizontal/vertical thumbstick tilt (depends on mode B/C). I had't understood it before but now I've found out that axis #9 represents thumbstick position in polar coordinates, where 3.28571 corresponds to center, despite the spec says that axis data should change in range [-1; 1]. Here's the data for mode B:
The axis data changes discontinuosly so that these are all possible values. The difference in mode C is that notional zero is found at bottom position and all values turn 90 deg counterclockwise. Calibration routine detects the axis which gives the max delta from centered position. For this reason the axis #9 always wins. Off the top of my head I have an idea that we could detect axes which return non-standard readings out of the range [-1; 1] in centered position and ignore them during joystick calibration. |
@MaxZhaloba thank you for explanations.
|
|
@AndriyPt, as for the units – as i see it – the value for axis #9 is measured in their own normalized units which equal to rad/pi or deg/180. They cannot use radians or degrees becase according to Gamepad API the axis values sould be found in range of [-1; 1]. |
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
…connected" event instead of the moment when user proceeds to configuration tab For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
…sition For task: Integrate Bluetooth Joystick to mobile VR set #86
…y connected on page loading For task: Integrate Bluetooth Joystick to mobile VR set #86
@AndriyPt, I have some news related to testing of configuration page. We've tried to connect the Joystick to @SystemDiagnosticss Android phone and it remained unvisible despite the site https://html5gamepad.com showed the joystick. Now I've returned home and launched the Lineage OS Android 7.x x64 build from flash drive on my laptop. It supports my blutooth adapter and it connected to jostick successfully. I've tested the configuration page on the latest Chrome and it works fine despite joystick is represented with significantly different software interface. More specifically, it doesn't expose any axis data and all thumbstick movements are represented as button pressings. Such use case is supported by the configuration routine. Interestingly, my 2.4 GHz mouse is also available via Gamepad API and added to list of devices for configuration under this Android x64 OS. Long story short, I don't have any idea how to debug this issue which occurs on Igor's Android phone since I don't know where to lend a physical Android device for longer term and under Android for PC everything works fine. |
Actually, we can meet somewhere in the city with @SystemDiagnosticss to investigate this issue more thoroughly. |
For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
…ad name placeholder For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
…f user switched to configuration tab with UI button For task: Integrate Bluetooth Joystick to mobile VR set #86
For task: Integrate Bluetooth Joystick to mobile VR set #86
…uration role even if user skips assigning an action for this role For task: Integrate Bluetooth Joystick to mobile VR set #86
Hi @AndriyPt, I've tested that vr.html receives button and axis pressing from joystick on Android. But there's some issue with sending of commands to ROS so that robot doesn't move in simulation. All movement actions are implemented as functions so it will be easy to adjust them for all input methods. Joystick configuration is performed on config.html page. The implementation is available in branch F86_bluetooth_joy. I'm finishing my work on this task. Please reassign according to your priorities. |
Joystick will be used for teleoperation.
Mobile browser should read commands from joystick and move robot accordingly.
There should be ability to calibrate joystick on the web page.
The text was updated successfully, but these errors were encountered: