Skip to content

Conversation

@ion098
Copy link
Collaborator

@ion098 ion098 commented Jun 17, 2024

Add controller deadband, curves and fisheye, also changes the const references to Button/floats into getter methods, and renames some stuff.

Test code:

#include "main.h"

#include "gamepad/api.hpp"

void initialize() {
    gamepad::master.set_left_transform(gamepad::TransformationBuilder(gamepad::Deadband(0.05, 0.05))
                                           .and_then(gamepad::Fisheye(1.26))
                                           .and_then(gamepad::ExpoCurve(1.1, 1.1)));
    while (true) {
        gamepad::master.update();
        std::cout << "With curves:" << std::endl;
        std::cout << "(" << gamepad::master.axisLeftX() << "," << gamepad::master.axisLeftY() << ") ("
                  << gamepad::master.axisRightX() << "," << gamepad::master.axisRightY() << ")" << std::endl;
        std::cout << "Without curves:" << std::endl;
        std::cout << "(" << gamepad::master.axisLeftX(false) << "," << gamepad::master.axisLeftY(false) << ") ("
                  << gamepad::master.axisRightX(false) << "," << gamepad::master.axisRightY(false) << ")" << std::endl
                  << std::endl;
        pros::delay(1000);
    }
}

Download the template for this pull request:

Note

This is auto generated from Add Template to Pull Request

curl -o gamepad@0.3.0+3f88e1.zip https://nightly.link/LemLib/Gamepad/actions/artifacts/2618353504.zip;
pros c fetch gamepad@0.3.0+3f88e1.zip;
pros c apply gamepad@0.3.0+3f88e1;
rm gamepad@0.3.0+3f88e1.zip;

ion098 added 5 commits June 16, 2024 18:59
Add an abstarct DriveCurve class and a concrete ExproDriveCurve class, both based on LemLib's implementation.
Allow users to assign a DriveCurve per axis to be used by the controller when updating joystick values.
@ion098 ion098 added the enhancement New feature or request label Sep 11, 2024
@ion098 ion098 marked this pull request as ready for review November 4, 2024 16:46
@ion098 ion098 requested review from SizzinSeal and jmakif November 4, 2024 19:34
Copy link
Member

@SizzinSeal SizzinSeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm from a design standpoint, but it needs more docs as well as some other nitpickings

@ion098 ion098 requested a review from SizzinSeal November 16, 2024 23:44
Copy link
Member

@SizzinSeal SizzinSeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (almost), just need to wrap up our convo on function defs in headers vs in source, and fix style issues

@ion098 ion098 changed the title Joystick enhancements ✨ Joystick enhancements Nov 20, 2024
@ion098 ion098 added the needs testing This PR/bug report needs testing label Nov 20, 2024
@SizzinSeal
Copy link
Member

Test data:

With curves:
(0,0) (0,0)
Without curves:
(0,0) (0,0)

With curves:
(0,0) (0.401575,-0.330709)
Without curves:
(-0.149606,0.212598) (0.401575,-0.330709)

With curves:
(0,0) (0.322835,-0.606299)
Without curves:
(-0.0866142,0.511811) (0.322835,-0.606299)

With curves:
(0,0) (0.244094,-0.574803)
Without curves:
(-0.0472441,0.346457) (0.244094,-0.574803)

With curves:
(0,0) (0.0708661,0.15748)
Without curves:
(0.181102,-0.88189) (0.0708661,0.15748)

With curves:
(0,0) (0,0.417323)
Without curves:
(0.23622,-0.984252) (0,0.417323)

With curves:
(0,0) (-0.433071,0.204724)
Without curves:
(0.527559,0) (-0.433071,0.204724)

With curves:
(0,0) (0.0866142,-0.566929)
Without curves:
(0.0866142,0.519685) (0.0866142,-0.566929)

With curves:
(0,0) (0.795276,-0.165354)
Without curves:
(-0.582677,-0.173228) (0.795276,-0.165354)

@SizzinSeal
Copy link
Member

More tests:

With curves:
(-0.294027,1) (0,0)
Without curves:
(-0.362205,1) (0,0)

With curves:
(-1,0.351606) (0,0)
Without curves:
(-1,0.417323) (0,0)

With curves:
(0.703634,-0.520595) (0,0)
Without curves:
(0.740157,-0.574803) (0,0)

With curves:
(0.598425,0.14346) (0,0)
Without curves:
(0.645669,0.212598) (0,0)

With curves:
(-0.891154,-0.22151) (0,0)
Without curves:
(-0.905512,-0.291339) (0,0)

With curves:
(0.189927,-1) (0,0)
Without curves:
(0.259843,-1) (0,0)

With curves:
(0,-1) (0,0)
Without curves:
(0,-1) (0,0)

With curves:
(1,0.494878) (0,0)
Without curves:
(1,0.551181) (0,0)

With curves:
(1,-0.326815) (0,0)
Without curves:
(1,-0.393701) (0,0)

With curves:
(-1,-1) (0,0)
Without curves:
(-0.84252,-0.80315) (0,0)

@ion098 ion098 changed the title ✨ Joystick enhancements feat: ✨ Joystick enhancements Jan 29, 2025
@ion098 ion098 merged commit 01fa938 into main Feb 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs testing This PR/bug report needs testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants