So, I have already set up one working drive with my Dual Shock 4 using DS4Windows. It works with one joystick. What I want to do is have One joystick be the main control, and the other (Raw Axis 4&5) to be precision control or very slow movements. I tried making two different drives but that did not work, as the motors would spasm out. Any tips? Thanks.
(Edit, I have read the WPI Library and its subsidiaries about Xbox Controllers.)
We use the default PS4 controller for everything except rumble. We use the emulated Xbox controller for rumble. If you could post the code you’re using that would help out.
You cannot set motor outputs in more than a single place. They will fight each other and the last one to be set will win.
You will need code that chooses between the two joysticks and only lets one joystick be operational at a time.
Alternatively you can devise code that merges the two joystick settings and then uses that combined input to drive the motors.
We have an algorithm that does this. I will post it later, but here is the gist.
Stick one controls the motor output up to a max unless a bolean (allow overdrive) is returned True from the DS.
If it is true, stick one + stick two set the motor value. We use some math to make stick one control the 0 - max and stick 2 to control max to 1.
We use python, and I am not on my phone, but I will post some code later. We created our first season in Labview. But it is language agnostic.
Edit, Sorry @Mark_McLeod that is exactly what you said.
Here is the code we use. I am still on my phone, so there may be an errant parenthesis.
self.drive.arcadeDrive(((self.stick.getTriggerAxis(Hand.kRight)*((1-self.driveLimit)/1))+self.driveLimit)*-1*(self.stick.getY(Hand.kRight)),(self.stick.getTriggerAxis(Hand.kRight)*((1-self.driveLimit)/1)+self.driveLimit)*(self.stick.getX(Hand.kRight))
Sorry for the delay. Here is our code:
myDrive.arcadeDrive(dualShock.getRawAxis(0)*.8,dualShock.getRawAxis(1)*.8);
Little update: I had someone come over and try to help me and he said that with your (my) level, it would just be better to move the joystick carefully. Thanks for the help guys!
Sorry it took so long to see this. I think you can get this to work.
Try using a smaller multiplier than .8 and try the following…
myDrive.arcadeDrive((DualShock.getRawAxis(0))*.3,(dualShock.getRawAxis(1))*.3)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.