Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: cannot convert '<unresolved overloaded function type>' to 'std::function<void(OdomDebug::state_t)>' #3

Open
MiPlayer123 opened this issue Mar 19, 2022 · 6 comments

Comments

@MiPlayer123
Copy link

Hello. I am trying to use odomDebug and I am running into an error. I have the template installed in my project. Here is the error:

Compiled src/main.cpp make: *** [common.mk:270: bin/main.cpp.o] Error 1
[ERRORS]
src/main.cpp: In function 'void opcontrol()':
src/main.cpp:116:35: error: cannot convert '<unresolved overloaded function type>' to 'std::function<void(OdomDebug::state_t)>'
  116 |  display.setStateCallback(setState);
      |                                   ^
In file included from ./include/main.h:83,
                 from src/main.cpp:1:
./include/odomDebug/odomDebug.hpp:79:60: note:   initializing argument 1 of 'void OdomDebug::setStateCallback(std::function<void(OdomDebug::state_t)>)'
   79 |   void setStateCallback(std::function<void(state_t state)> callback);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
ERROR - pros.cli.build:make - Failed to make project: Exit Code 2

Here is the code I am using:

void setState(OdomDebug::state_t state) {
	chassis->setState({state.x, state.y, state.theta});
}
void resetSensors() {
	// reset sensors and reset odometry
	chassis->setState({0_in, 0_in, 0_deg});
}

void opcontrol() {
    OdomDebug display(lv_scr_act(), LV_COLOR_ORANGE);
	display.setStateCallback(setState);
	display.setResetCallback(resetSensors);
    while(true) {
        //chassis->getModel()->tank(controller.getAnalog(ControllerAnalog::leftY), controller.getAnalog(ControllerAnalog::rightY));
        display.setData({chassis->getState()}, {LOdom.get(), ROdom.get()});
        pros::delay(10);
    }
}
@theol0403
Copy link
Owner

Is that really all the code you are using? It seems like you have another overloaded function somewhere called setState.

@MiPlayer123
Copy link
Author

That's not all the code I am using, but this is all the code relevant to odomDebug. I renamed the functions to 2 different things and I am getting the same error still. And I don't think odomDebug got loaded in twice:
image

@theol0403
Copy link
Owner

You should probably share your code.

@MiPlayer123
Copy link
Author

Yep. Here is the code: https://drive.google.com/file/d/1ANesyWP012L7EFZ0cdK-g9WAoyNdBBdU/view?usp=sharing (Note most of the stuff is pretty experimental)

@theol0403
Copy link
Owner

Replacing
display.setData({chassis->getState()}, {LOdom.get(), ROdom.get()});
with

    auto state = chassis->getState();
    display.setData({state.x, state.y, state.theta},
                    {LOdom.get(), ROdom.get()});

Makes it compile fine for me on gcc 9.

@MiPlayer123
Copy link
Author

Ok cool, that works.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants