Go to Post "I got flour all over my Chromebook!" - frcguy [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi