View Single Post
  #1   Spotlight this post!  
Unread 18-02-2012, 17:17
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Robot "Output Not updated often Enough" Help Please!

Ok, so what has happened is your declared several pointers to jaguars, then gave them to myRobot to use, however the pointers don't point to anything until you call new, so myRobot (which apparantly doesn't null protect itself!? ) seems to crash trying to derefernce these pointers.

Code:
Jaguar *leftmotor;
Jaguar *rightmotor;
Jaguar *leftbackmotor;
Jaguar *rightbackmotor;

leftmotor = new Jaguar(1);
rightmotor = new Jaguar(2);
leftbackmotor = new Jaguar(3);
rightbackmotor = new Jaguar(4);

myRobot = new RobotDrive(leftmotor,leftbackmotor,rightmotor,leftbackmotor);
^That's all you need to do to fix it

You can also do it like this:
Code:
class Robot2012 : public IterativeRobot
{
	Jaguar jaguarFrontLeft;
	Jaguar jaguarFrontRight;
	Jaguar jaguarRearLeft;
	Jaguar jaguarRearRight;

	Robot2012(void):
		jaguarFrontLeft(1),
		jaguarFrontRight(2),
		jaguarRearLeft(3),
		jaguarRearRight(4),
		myRobot(&jaguarFrontLeft, &jaguarRearLeft, &jaguarFrontRight, &jaguarRearRight),
Putting an & in front of an object gives you a reference to that object(aka it's pointer)
Reply With Quote