View unanswered posts | View active topics It is currently Mon Oct 20, 2014 4:23 am






Reply to topic  [ 7 posts ] 
Need help with atan2 function causing errors 
Author Message
Rookie

Joined: Sat Nov 09, 2013 8:26 pm
Posts: 4
Post 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


Attachments:
Accel_Test_3.c [3.02 KiB]
Downloaded 115 times
Sat Nov 09, 2013 10:47 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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
Profile
Rookie

Joined: Sat Nov 09, 2013 8:26 pm
Posts: 4
Post 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
Profile
Rookie

Joined: Sat Nov 09, 2013 8:26 pm
Posts: 4
Post 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
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Need help with atan2 function causing errors
no_handlebars wrote:
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.

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
Profile
Rookie

Joined: Sat Nov 09, 2013 8:26 pm
Posts: 4
Post 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.


Attachments:
Accel_Test_5.c [2.6 KiB]
Downloaded 113 times
Sun Nov 10, 2013 5:38 pm
Profile
Expert
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 164
Location: California, USA
Post Re: Need help with atan2 function causing errors
no_handlebars wrote:
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.


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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.