Button Bindings on Command Based

Hello, I am currently the Programming Team Captain for my Robotics Team and we decided to switch to a command based program this year. We are inexperienced with joystick button bindings and are having difficulties with it. I was wondering if I could potentially get some help with this issue. Thank you.

Here is our current RobotContainer.cpp file with our button bindings:

/----------------------------------------------------------------------------/

/* Copyright © 2019 FIRST. All Rights Reserved. */

/* Open Source Software - may be modified and shared by FRC teams. The code */

/* must be accompanied by the FIRST BSD license file in the root directory of */

/* the project. */

/----------------------------------------------------------------------------/

#include “RobotContainer.h”

RobotContainer::RobotContainer() {

// Initialize all of your commands and subsystems here

m_joystick = new frc::Joystick(JOYSTICK_PORT);

frc::SmartDashboard::PutData(&m_drivetrain);

m_drivetrain.SetDefaultCommand(ArcadeDriveCommand(

  &m_drivetrain,

  [this] {return m_joystick->GetY(); },

  [this] {return m_joystick->GetX(); }));

//frc::SmartDashboard::PutString(“DB/String 1”, “b4 read”);

m_wheel.SetDefaultCommand(GetColorCommand(&m_wheel));

m_camera.SetDefaultCommand(VisionCommand(&m_camera));

// Configure the button bindings

ConfigureButtonBindings();

}

void RobotContainer::ConfigureButtonBindings() {

// Configure your button bindings here

rotate_wheel = new frc2::JoystickButton(m_joystick, ROTATE_WHEEL_BUTTON);

rotate_wheel -> WhenPressed(RotateWheelCommand(&m_wheel));

set_color = new frc2::JoystickButton(m_joystick, SET_COLOR_BUTTON);

set_color -> WhenPressed(SetColorCommand(&m_wheel));

}

frc2::Command* RobotContainer::GetAutonomousCommand() {

// An example command will be run in autonomous

return nullptr;

}

What kind of issues are you having? Could you be hitting the known issue? https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/known-issues.html#c-command-based-joystickbutton-and-povbutton-not-functioning

Couple things…

First, it’s best to simply link to your code instead of pasting it here as formatting gets weird.
Second, it’s generally helpful if you describe the issues you’re having. As much as I’d enjoy being psychic, I’m not.

Sorry this is my first time using ChiefDelphi and I am not very familiar with posting etiquette. Either way, when we enable the roborio to test the code and click the proper buttons, nothing occurs. The issue is not with the Joystick as the driver station clearly indicates that buttons are being pressed and processed. Moreover, we also know that the commands are not being called upon as our print statements within them are not being called. Any feedback is appreciated. Thank you.

posting etiquette

No worries. Nobody here is angry, we’re just informing you.

As for your issue, your RobotContainer class seems fine at first glance. We’ll definitely need to see more of your code. Can you post the entire project in a public github repository and share a link?

There was a similar discussion recently. There may be an issue which will be fixed in the next release. Please check that one out and see if it explains your symptoms. If so, there is a temporary work-around.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.