Author |
Message |
no_handlebars
Rookie
Joined: Sat Nov 09, 2013 8:26 pm Posts: 4
|
 Need help with atan2 function causing errors
I have a program with the following line that causes a number of compiler errors
testAtan2 = atan2(_y_axis,_z_axis);
Here are the errors I get when I try to compile my program
**Error**:'*' Indirection levels mismatch. Call to 'sendI2CMsg'. Parameter: 'char * pSendMsg' is 'error_array[0]' of type 'ubyte'. **Error**:'*' Indirection levels mismatch. Call to 'sendI2CMsg'. Parameter: 'char * pSendMsg' is 'data[0]' of type 'ubyte'. **Error**:'*' Indirection levels mismatch. Call to 'sendI2CMsg'. Parameter: 'char * pSendMsg' is 'data[0]' of type 'ubyte'. **Error**:'*' Indirection levels mismatch. Call to 'readI2CReply'. Parameter: 'char * pReplyBytes' is 'data[0]' of type 'ubyte'. **Error**:Multiple overloads for 'atan2' match *Warning*:Selected: Converted 0:0/2/200 (Parm/Const/Indirect) atan2(float x, float y) *Warning*:Worse: Converted 1:0/2/200 (Parm/Const/Indirect) atan2(const float Y, const float X)
In the past I am pretty certain that I ran this program just as it is, does anyone have any ideals?
Thanks
|
Sat Nov 09, 2013 10:47 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Need help with atan2 function causing errors
I downloaded your code and fixed the #include path and the accelerometer driver name to hitechnic-accelerometer.h. After those fixes, I have no problem compiling the program. What version of RobotC do you have? I am using the latest (3.62).
BTW, a quick look at your code, I did find several issues. I did not spend time to understand what you were trying to do but you had several divisions in your code that will potentially fault with "divide by zero".
|
Sun Nov 10, 2013 3:40 am |
|
 |
no_handlebars
Rookie
Joined: Sat Nov 09, 2013 8:26 pm Posts: 4
|
 Re: Need help with atan2 function causing errors
Thanks, I am using version 3.62
I changed the sensor set up to #pragma config(Sensor, S1, HTAC, sensorI2CCustom)
and the include to #include "drivers/hitechnic-accelerometer.h"
These both match the example file 'hitechnic-accelerometer-test1.c' which I can compile and run. However I can't get my file to compile, I am still getting the following.
**Error**:'*' Indirection levels mismatch. Call to 'sendI2CMsg'. Parameter: 'char * pSendMsg' is 'error_array[0]' of type 'ubyte'. **Error**:'*' Indirection levels mismatch. Call to 'sendI2CMsg'. Parameter: 'char * pSendMsg' is 'data[0]' of type 'ubyte'. **Error**:'*' Indirection levels mismatch. Call to 'sendI2CMsg'. Parameter: 'char * pSendMsg' is 'data[0]' of type 'ubyte'. **Error**:'*' Indirection levels mismatch. Call to 'readI2CReply'. Parameter: 'char * pReplyBytes' is 'data[0]' of type 'ubyte'. **Error**:Array size mismatch. Call to 'writeI2C'. Parameter: 'short replylen' is 'HTAC_I2CReply' of type 'tByteArray'. **Error**:Multiple overloads for 'atan2' match *Warning*:Selected: Converted 0:0/2/200 (Parm/Const/Indirect) atan2(float x, float y) *Warning*:Worse: Converted 1:0/2/200 (Parm/Const/Indirect) atan2(const float Y, const float X)
|
Sun Nov 10, 2013 11:16 am |
|
 |
no_handlebars
Rookie
Joined: Sat Nov 09, 2013 8:26 pm Posts: 4
|
 Re: Need help with atan2 function causing errors
I found my problem... It was not the atan2 function after all, I move all of my programming files from 'my documents' to a root folder on the c drive and things are ok now.
|
Sun Nov 10, 2013 12:10 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Need help with atan2 function causing errors
Glad to hear you solved your problem but you still need to look closer at your close where you could potentially divide by zero. This will cause your code to crash at run-time.
|
Sun Nov 10, 2013 1:51 pm |
|
 |
no_handlebars
Rookie
Joined: Sat Nov 09, 2013 8:26 pm Posts: 4
|
 Re: Need help with atan2 function causing errors
Yep, thanks again for the help. Now that I am compiling and able to do some testing I have removed the portion of the program with the error you commented on and simplifying things a bit with the atan2 function.
This is my attempt at a Accelerometer remote that will send a heading in degrees and a power level to a three wheeled bot. Still got a little ways to go still but take a look again if you are curious.
|
Sun Nov 10, 2013 5:38 pm |
|
 |
roboRed
Expert
Joined: Fri Nov 02, 2012 12:07 am Posts: 163 Location: California, USA
|
 Re: Need help with atan2 function causing errors
Yeah, I had also considered that, but I wasn't so sure about how accurate the accelerometer would be at being a remote control.
_________________ string Robored = "Awesome" ~~Neil Balch~~
|
Sun Nov 10, 2013 11:52 pm |
|
|