Does anyone know why I keep getting this error with Okapi in PROS and how I fix it? I am using pros 3.1.4, it was re-installed fresh just a couple days ago with okapi. I have no "using namespace"s, so there is no contradictory okapi and pros namespace, and the “okapi/api.hpp” is included in my “main.h”. Yet, I keep getting an error stating
> /include/globals.hpp:13:8: error: 'okapi' does not name a type
> extern okapi::ControllerButton intakeForward;
> ^~~~~
> ./include/globals.hpp:14:8: error: 'okapi' does not name a type
> extern okapi::ControllerButton intakeReverse;
> src/opfunctions.cpp:66:75: error: no matching function for call to 'okapi::ControllerButton::ControllerButton(pros::controller_digital_e_t, bool)'
> okapi::ControllerButton intakeForward(pros::E_CONTROLLER_DIGITAL_R1, false);
> ^
> In file included from ./include/okapi/api.hpp:46:0,
> from ./include/main.h:48,
> from src/opfunctions.cpp:2:
> ./include/okapi/impl/device/button/controllerButton.hpp:19:3: note: candidate: okapi::ControllerButton::ControllerButton(okapi::ControllerId, okapi::ControllerDigital, bool)
> ControllerButton(ControllerId icontroller, ControllerDigital ibtn, bool iinverted = false);
> ^~~~~~~~~~~~~~~~
> ./include/okapi/impl/device/button/controllerButton.hpp:19:3: note: no known conversion for argument 1 from 'pros::controller_digital_e_t' to 'okapi::ControllerId'
> ./include/okapi/impl/device/button/controllerButton.hpp:17:3: note: candidate: okapi::ControllerButton::ControllerButton(okapi::ControllerDigital, bool)
> ControllerButton(ControllerDigital ibtn, bool iinverted = false);
> ^~~~~~~~~~~~~~~~
> ./include/okapi/impl/device/button/controllerButton.hpp:17:3: note: no known conversion for argument 1 from 'pros::controller_digital_e_t' to 'okapi::ControllerDigital'
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate: constexpr okapi::ControllerButton::ControllerButton(const okapi::ControllerButton&)
> class ControllerButton : public ButtonBase {
> ^~~~~~~~~~~~~~~~
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate expects 1 argument, 2 provided
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate: constexpr okapi::ControllerButton::ControllerButton(okapi::ControllerButton&&)
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate expects 1 argument, 2 provided
> src/opfunctions.cpp:67:75: error: no matching function for call to 'okapi::ControllerButton::ControllerButton(pros::controller_digital_e_t, bool)'
> okapi::ControllerButton intakeReverse(pros::E_CONTROLLER_DIGITAL_L1, false);
> ^
> In file included from ./include/okapi/api.hpp:46:0,
> from ./include/main.h:48,
> from src/opfunctions.cpp:2:
> ./include/okapi/impl/device/button/controllerButton.hpp:19:3: note: candidate: okapi::ControllerButton::ControllerButton(okapi::ControllerId, okapi::ControllerDigital, bool)
> ControllerButton(ControllerId icontroller, ControllerDigital ibtn, bool iinverted = false);
> ^~~~~~~~~~~~~~~~
> ./include/okapi/impl/device/button/controllerButton.hpp:19:3: note: no known conversion for argument 1 from 'pros::controller_digital_e_t' to 'okapi::ControllerId'
> ./include/okapi/impl/device/button/controllerButton.hpp:17:3: note: candidate: okapi::ControllerButton::ControllerButton(okapi::ControllerDigital, bool)
> ControllerButton(ControllerDigital ibtn, bool iinverted = false);
> ^~~~~~~~~~~~~~~~
> ./include/okapi/impl/device/button/controllerButton.hpp:17:3: note: no known conversion for argument 1 from 'pros::controller_digital_e_t' to 'okapi::ControllerDigital'
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate: constexpr okapi::ControllerButton::ControllerButton(const okapi::ControllerButton&)
> class ControllerButton : public ButtonBase {
> ^~~~~~~~~~~~~~~~
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate expects 1 argument, 2 provided
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate: constexpr okapi::ControllerButton::ControllerButton(okapi::ControllerButton&&)
> ./include/okapi/impl/device/button/controllerButton.hpp:15:7: note: candidate expects 1 argument, 2 provided
and here is what im trying to do
In hpp file
extern okapi::ControllerButton intakeForward;
extern okapi::ControllerButton intakeReverse;
In cpp file
> okapi::ControllerButton intakeForward(pros::E_CONTROLLER_DIGITAL_R1, false);
> okapi::ControllerButton intakeReverse(pros::E_CONTROLLER_DIGITAL_L1, false);
> enum Direction {forward, reverse, stopped};
> enum Direction intakeDirection = stopped;
>
> void intakeOP() {
> if(intakeForward.changedToPressed()){
> if(intakeDirection != forward) {
> intake_right.move_velocity(200);
> intake_left.move_velocity(200);
> intakeDirection = forward;
> }
> else {
> intake_right.move_velocity(0);
> intake_left.move_velocity(0);
> intakeDirection = stopped;
> }
> }
> if(intakeReverse.changedToPressed()){
> if(intakeDirection != reverse) {
> intake_right.move_velocity(-200);
> intake_left.move_velocity(-200);
> intakeDirection = reverse;
> }
> else {
> intake_right.move_velocity(0);
> intake_left.move_velocity(0);
> intakeDirection = stopped;
> }
> }
> }