PRO
Davidaharrison
Canada
Asked
Resolved by DJ Sures!
I'm looking to use my L2 and R2 buttons to change what servo groups my analog sticks control when they are held, is there a way to do this?
The current method I found is to use third party software to map the joystick directions to keys, then use the keyboard skill. I have the L2 and R2 set variables when they are down and then the joystick mapped keys run the scripts for the correct servo set depending on if the variable is set.
However I'm finding this method has a noticeable lag from the L2 button being pressed and the variable being switched. The keyboard skill shows the button press instantly but the set variables delayed.
Thanks
Related Hardware Arduino Due/Mega
Related Controls
Joystick (Direct Input)
Joystick (XInput)
You should never need a third-party program - plus, most third-party stuff never works.
If this isn't the joystick skill you're using, you should use it: https://synthiam.com/Support/Skills/Navigation/Joystick-XInput?id=19182.
The only thing is there is no "Servo group." Unless you're modifying the code on the Arduino to switch servo mapping with those buttons.
That does remind me of maybe a mapping skill. It might be helpful to have a skill that maps Vx servos to anything else, as in groups. Perhaps I'll create one for you.
In the meantime, you'd have to create a script skill that does it for you...
An init script (on connection) initializes the $JoyServoGroup variable. Put this in the connection control or your init script
Create a script called "ServoGroups". This will map the Vx servos to Dx servos for you
And finally, in the Joystick Robot Skill, use the Vx servos as referenced in the above script.
And finally, set buttons to move the servo groups. I don't have a joystick with me so i don't know what buttons 16 and 17 are. But you can change to what ever...
Here's a demo project: Example - Joystick servo Group.EZB
Ah, there is a robot skill already that does what you want. It's called servo Script. It will execute a script every time a servo moves. You can do the mapping within the script. Here is the robot skill: https://synthiam.com/Support/Skills/Scripting/Servo-Script?id=19068
Or you can do the way i outlined above.
Ok thanks I'm getting somewhere now.
Part of the issue was that I forgot L2 and R2 are analog buttons.
L1 and R1 are better suited to use which are 10 and 11 on the joysticks skill.
I'm testing your method which is what I was after.
However I'm still seeing a lag on the $joyservogroup variable switching on button press. On the the Joystick(Xinput) skill window i see the press register instantly, however in the variable watch window and also the robot switching between servo groups its about a 2 second delay. Is this normal? Is seems odd that ARC sees the button press but takes so long to switch the variable.
The variable watch has a delay when updating. But the variable would be updated immediately. There is no delay when updating a variable. When the variable is assigned a new value, it’s immediately set with that value.
How’s your CPU usage during the project? Are you lagging the cpu with something?
Checked CPU and its at 15%
No idea why but when I ditched servo Script and created my own it all seems to function now, nice and fast.
Thanks Again DJ
I used your method as follows, used L1 to set $L1_Pressed when $L1_Pressed = 0 mapped the V2 to V12 then used the following script
This moves the dome with the Right stick.
when $L1_Pressed = 1 maps V0 through V3 to the Arm Servos allowing me to used the sticks to control the arms, Dome Movement moves over to the D-pad. So Simple a 9 year old can work it
Haha that’s such a great video!! Gonna be a pretty wild robot. Glad you shared it
Thant's really cool! Nice job!
great going Davidaharrison
EzAng
Ok not sure what happened but I'm not seeing the virtual servo V12 which is mapped from V2 go to 90 degrees at center.
This seemed to work before yesterday I noticed that it seemed to be going to 180 on a full right then returning to 1.
I did an ARC update, been a few months since my last, not sure if this is related.
Its been a while since I had to look at mapping from the joystick but I believe they were always 90 on center?
There was a minor bug with the direct input joystick robot skill for the right analog stick. Fixed here: https://synthiam.com/Support/Skills/Navigation/Joystick-XInput?id=19182
Ok no worries,
I just redid it using JoystickX2 Variables, no idea why I did not do that the first time round, its funny going back sometimes over old work.