Thread: Pointers Issues
View Single Post
  #1   Spotlight this post!  
Unread 20-01-2012, 00:29
cjlane1138 cjlane1138 is offline
Team 1138
FRC #1138 (Eagle Engineering)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Los Angeles
Posts: 88
cjlane1138 is an unknown quantity at this point
Pointers Issues

Hey everyone,

So, we are having issues with pointers. I just wanted to know if anyone else is getting the same errors. They are kernel task exceptions. When I get rid of the pointers and initialize the classes another way, it all works.

If anyone has a solution, please tell me. Otherwise, I just want to know if everyone else is having the same issue or it's just me....

Code:
#include "WPILib.h"
#include "Drive.h"

class RobotDemo : public SimpleRobot
{
	Drive *dr;

public:
	RobotDemo(void)
	{
		GetWatchdog().Kill();
		dr = new Drive();
		//AxisCamera &camera = AxisCamera::GetInstance();
		dr->myRobot->SetExpiration(0.1);
	}

	/**
	 * Drive left & right motors for 2 seconds then stop
	 */
	void Autonomous(void)
	{
		GetWatchdog().Kill();
		//dr->myRobot->SetSafetyEnabled(false);
		dr->myRobot->Drive(0.5, 0.0); 	// drive forwards half speed
		Wait(2.0); 				//    for 2 seconds
		dr->myRobot->Drive(0.0, 0.0); 	// stop robot
	}



	void OperatorControl(void)
	{
		GetWatchdog().Kill();
		//dr->myRobot->SetSafetyEnabled(true);
		while (IsOperatorControl())
		{
			printf("In Operator\n");
			dr->myRobot->TankDrive(dr->leftstick, dr->rightstick);
			Wait(0.01);
		}
	}

	void Disabled(void)
	{
		printf("Disabled\n");
	}
};

START_ROBOT_CLASS(RobotDemo);

It keeps giving me that the Drive *dr; has not been initialized correctly, where I believe I have. Anyone know any ways I can debug this?

Thanks,
-Eagle Engineering 1138

Last edited by cjlane1138 : 20-01-2012 at 11:42.
Reply With Quote