I can’t figure out what to do from here. I checked the documentation and example codes on github to make sure that I am not doing anything wrong. I did not see much of a difference and no clue why its not working. Please help Thanks
The first couple of notes are telling you what’s wrong. ExampleAutoCommand has a constructor that takes two arguments (ExampleSubsystem*
and std::function<double()>
). You’re passing one: just ExampleSubsystem*
. You need to pass a lambda or other function, e.g. m_autonomousCommand(&m_subsystem, [=] { return ...; })
I have another question regarding the new command based. I am trying to make the same auto command run by pressing on a joystick button with a timeout.
This is my current code:
xboxA.WhenPressed(ExampleAutoCommand(&m_subsystem, [=] {return 0.5;}).WithTimeout(1));
but this returns an error saying :
“no known conversion for argument 1 from ‘int’ to ‘units::time::second_t {aka units::unit_t<units::unit<std::ratio<1>, units::base_unit<std::ratio<0, 1>, std::ratio<0, 1>, std::ratio<1> > > >}’”
is this not the correct way of declaring timeout? this is what is shown in documentation…?
WithTimeout(1.0_s)
. The documentation may have been copied from Java; in C++ you need the suffix to specify the units.
Thank you
You’re missing an include. E.g. #include <frc2/command/ParallelRaceGroup.h>
I thought I just needed frc2/command/command.h
Each of the various commands is in a different header file. You need to include what you use.
Okay, good to know
Now, I just ran the code. However, it seems that the command can be only run once.
The command is tied to button A and it will run fine the first time around. But when I press it for the second time, it doesn’t run. Do I need to do some kind of timer reset in order for it to work multiple times?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.