View Single Post
  #3   Spotlight this post!  
Unread 26-02-2014, 15:44
Toa Circuit's Avatar
Toa Circuit Toa Circuit is offline
Thaddeus Maximus
AKA: Thad Hughes
FRC #4213 (MetalCow Robotics)
Team Role: Leadership
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Shirley, IL
Posts: 131
Toa Circuit is an unknown quantity at this point
Re: Trouble Printing to NetConsole

A few things:
I'm fairly certain modulus (%) works only on int... that could be causing some issues. (Though I think I see what you're doing (Trying to make this code execute once every 24 run-throughs) and that isn't the issue)

You most likely are having issues at this line:

Code:
*G = int(gyro->GetAngle());
I believe what you're doing here is creating a new pointer to an int (With the int()) and passing that into the value of *G. I think what you want to do is either remove the asterisk (assign the new pointer to G, not the value pointed to by G). You also need to remember to delete G each time. So you should end with something like this:
Code:
delete G;
G = int(gyro->GetAngle());
I believe the easier option is to remove the pointer-ness altogether. Direct access of data isn't bad.

That cout statement looks... very... very... very strange... and it's mere existance looks to be the issue...

Code:
 cout<<("Gyroscope Angle: " && *G && "\n");
In 5-6 years of C++, I've never seen anything like that. (I've thought && was soley a boolean operator and couldn't be used on strings, especially in the way it is here.) I think you're trying to write something like this:

Code:
cout<<"Gyroscope Angle: "<<*G<<"\n";
Though I've noticed execution speed issues, formatting mishaps, with cout<<, and tend to use printf.
If *G is an int, then use this:

Code:
printf("Gyroscope Angle: %d\n", *G);
If *G is a double/float, replace the %d with %f.
__________________

2012 Head of Programming and Electrical
2013-14 Overall Team Captain and Programming Head
2012-14 Mentor of FLL Team Power Surge
2014 Dean's List Finalist
2014 CIR Xerox Creativity Award
Webpage

Last edited by Toa Circuit : 26-02-2014 at 15:45. Reason: Error in printf example code
Reply With Quote