Announcement

Collapse
No announcement yet.

Gamepad Connections

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gamepad Connections

    Hi there,

    Our team is using app inventor and I recently had the driver and controller phones connected and the driver phone was recognizing the gamepads, as indicated by the little gamepad symbols that light up in the upper right hand corner. However, when I tried to execute my code, our bot did not do anything. You could see on the driver station that it was logging the movements of the joysticks and buttons on the controllers, but our bot didn't move. So I created a new program and tried to test it again, but this time the driver station doesn't recognize the gamepads when I press A and B to register them as Driver One and Driver Two, because the little icons do not appear in the corner. This is frustrating because I cannot test the new program and the tournament is only a few days away.

    Does anybody have tips, ideas, or suggestions?

    Thanks so much!

  • #2
    Originally posted by clairelaffan View Post
    Hi there,

    Our team is using app inventor and I recently had the driver and controller phones connected and the driver phone was recognizing the gamepads, as indicated by the little gamepad symbols that light up in the upper right hand corner. However, when I tried to execute my code, our bot did not do anything. You could see on the driver station that it was logging the movements of the joysticks and buttons on the controllers, but our bot didn't move. So I created a new program and tried to test it again, but this time the driver station doesn't recognize the gamepads when I press A and B to register them as Driver One and Driver Two, because the little icons do not appear in the corner. This is frustrating because I cannot test the new program and the tournament is only a few days away.

    Does anybody have tips, ideas, or suggestions?

    Thanks so much!
    When troubleshooting gamepads it's always best to first verify if the hardware is configured properly by writing a simple autonomous opmode that sets power to the servos or motors directly.


    "but this time the driver station doesn't recognize the gamepads when I press A and B to register them as Driver One and Driver Two, b"

    The correct sequence is start-A

    If that does not work then reboot the phone.

    Comment


    • #3
      One thing to check when the robot isn't moving is on the face of the Robot Controller, down near the bottom, if there are 2 game pads registered with the OpMode you will see two lines of "telemetry-like" data on the Robot Controller. This shows all of the inputs that the RC is getting from the DS. So, if you see that the DS is registering activity from the game pads (the game pad symbols are "glowing green") but there isn't any corresponding change in value of the thing you're doing shown on the face of the RC, then you can surmise that there is something amiss between your DS and your RC's wifi or program. I would reboot both phones and try again. IF, OTOH, your RC is showing changes in things such as the gamepad1.right_joystick.Y value, then you know that the OpMode is seeing that something's happening, but the robot isn't moving. In that instance it's definitely a code issue.

      Good luck!

      -- Gordon.

      Comment


      • #4
        Thank you,

        So I have a pretty simple program. The motors go forward when I move the joysticks outwards and the servos move out 90 degrees when I press the A and B buttons. Two motors in the arm move forward as well when the X and Y buttons are pressed. Some of the code I go straight from the Intellitek tutorials, and appInventor has a very clear and logical layout. Does anybody know of any common mistakes often made in the code? Like you said, gorpong, the RC is receiving telemetry data from the gamepads, so I know the connections are okay.

        Thank you

        Comment


        • #5
          code

          Here is a picture of my code:

          Comment


          • #6
            The imagine did was not attached . Try copy and pasting in a [code] block.
            Also - I'll refer you back to my prior post which ask the question: "Did you test the motor server operations without the gamepads"?

            Comment


            • #7
              I am not sure why your robot was doing nothing, but here are some tips to fix your code:
              -Use if statements instead of while loops when setting motor or servo values from the joystick. You should never make the Loop method wait for some condition to be met to finish.
              -Make sure to remember to set the motors powers and servo positions to their default value when you are not pressing the buttons (i.e. stop the motors and move the servos back in)
              -Initialize the servo positions in the Init method because otherwise setting one servo position will set the position of all the other servos on the controller to some (probably undesired) value

              Comment


              • #8
                Originally posted by dlevy View Post
                The imagine did was not attached . Try copy and pasting in a [code] block.
                Also - I'll refer you back to my prior post which ask the question: "Did you test the motor server operations without the gamepads"?
                It wasn't a link to an image, but rather a webpage containing the image: https://onedrive.live.com/?authkey=%...d=root&o=OneUp

                Comment


                • #9
                  Originally posted by GearTicks View Post
                  It wasn't a link to an image, but rather a webpage containing the image: https://onedrive.live.com/?authkey=%...d=root&o=OneUp
                  Thanks for the link. On the post it shows up as a broken link in my browser.

                  I think you are correct about the "while". It's possible that the gamepad will only show one state of a button in each iteration of the loop. So when the X finally registers the while loop may block there permanently. So changing to an "if" and following your other recommendations should solve the problem.

                  Comment


                  • #10
                    Originally posted by dlevy View Post
                    The imagine did was not attached . Try copy and pasting in a [code] block.
                    Also - I'll refer you back to my prior post which ask the question: "Did you test the motor server operations without the gamepads"?
                    No I have not. How would I do that?

                    Comment


                    • #11
                      Originally posted by clairelaffan View Post
                      No I have not. How would I do that?

                      I'd first change the "while" to "if" as GearTicks suggested. If that does not work than write a program that does not use the gamepads but just turns the power on the motors. If the motors still don't come on then the problem is not with your gamepads.

                      Comment


                      • #12
                        Originally posted by clairelaffan View Post
                        No I have not. How would I do that?
                        I wonder whether the question was concerning
                        The imagine did was not attached . Try copy and pasting in a [code] block.
                        To answer that one, use the button at the top of the Quick Reply window. When the mouse hovers over it, it will display a tool tip 'Wrap [QUOTE] tags around selected text'. Copy and paste the desired text from your computer into the posting window between the
                        and
                        tags.

                        Another way is to use the Go Advanced button and select the # symbol, except the tag will become [CODE].

                        Comment


                        • #13
                          Oops, the "and" should read '['QUOTE']' and '['/QUOTE']'. I didn't think about the system taking my text literally.

                          Comment


                          • #14
                            Team 5197 here. Can’t get Controller app to see the gamepad as in Troubleshooting guide. Developing in Linux Android Studio. Opmode with motor and gamepad support:

                            Code:
                            public class FirstOpmode extends LinearOpMode {
                                /* Declare OpMode members. */
                                private ElapsedTime runtime = new ElapsedTime();
                                DcMotor leftMotor = null;
                                DcMotor rightMotor = null;
                                @Override
                                public void runOpMode() {
                                    telemetry.addData("Status", "Initialized");
                                    telemetry.update();
                                    /* eg: Initialize the hardware variables. Note that the strings used here as parameters
                                     * to 'get' must correspond to the names assigned during the robot configuration
                                     * step (using the FTC Robot Controller app on the phone).
                                     */
                                    leftMotor  = hardwareMap.dcMotor.get("leftMotor");
                                    rightMotor = hardwareMap.dcMotor.get("rightMotor");
                                    // eg: Set the drive motor directions:
                                    // "Reverse" the motor that runs backwards when connected directly to the battery
                                    leftMotor.setDirection(DcMotor.Direction.FORWARD); // Set to REVERSE if using AndyMark motors
                                    rightMotor.setDirection(DcMotor.Direction.REVERSE);// Set to FORWARD if using AndyMark motors
                                    // Wait for the game to start (driver presses PLAY)
                                    waitForStart();
                                    runtime.reset();
                                    // run until the end of the match (driver presses STOP)
                                    while (opModeIsActive()) {
                                    telemetry.addData("GP1", gamepad1.toString());
                                    telemetry.addData("GP2", gamepad2.toString());
                            
                                    telemetry.update();
                             //       leftMotor.setPower(0.05); //runs
                             //       rightMotor.setPower(0.05); //runs
                            
                                    }
                                }
                            }
                            No “motor not found” exception. “Run time” telemetry works. Gamepad thumbstick positions remain at zero, presumably because the gamepad1 is not registered. The Driver phone responds to gamepad action: X and Y quit the Driver app; the left thumbstick can select apps; the start button can launch the selected app. Yes, gamepad type on Driver app is Logitech F310 for both.
                            Questions:
                            1. What software has to be running in order for a gamepad to be registered as in the Troubleshooting Guide p. 41-42?
                            2. What is the proper button gesture on the Logitech: with mode light off: start and A pressed together; start, release, A release; hold start, tap A; hold start, tap B; any of these gestures with mode light on? All these fail.

                            Comment


                            • #15
                              More results from FirstOpmode: motors run when setPower(0.2) is uncommented. Gamepad toString methods both return ID_UNALLOCATED = -1.

                              Comment

                              Working...
                              X