No Reading from Sensors

Questions about Marilou Open Devices Access (MODA)
Post Reply
AhmadKamalNasir
Posts: 11
Joined: Fri Nov 13, 2009 10:38 am

No Reading from Sensors

Post by AhmadKamalNasir » Fri Jul 23, 2010 8:26 pm

Hi,

I created the simple program and a robot using the tutorial. I have created the class of robot using the wizard and added the resulted files into VC2005 project. I try to print the sensor data in the command windows but no success, can you explain me my problem.Following is my code.

Code: Select all

	void MyRobot::MainLoop( void )
	{
		float AbsCompass;
		float LeftSensor,RightSensor;
		float LeftEncoder,RightEncoder;
		static float RelCompass;
		static float LeftMotorVel = 20, RightMotorVel = 20;
		AbsCompass = this->GetAbsolutCompassByIndex(0)->GetAngleDEG();
		LeftSensor = this->GetDistanceByIndex(0)->GetMeasure();
		RightSensor = this->GetDistanceByIndex(1)->GetMeasure();
		LeftEncoder = this->GetMotorByIndex(0)->GetOdometerCounter();
		LeftEncoder = this->GetMotorByIndex(1)->GetOdometerCounter();
		_cprintf("Compass(Abs): %f, ", &AbsCompass);
		_cprintf("Left US: %f, ", &AbsCompass);
		_cprintf("Right US: %f, ", &AbsCompass);
		_cprintf("Left Encoder: %f, ", &LeftEncoder);
		_cprintf("Right Encoder: %f\r\n", &RightEncoder);
		this->GetMotorByIndex(0)->SetVelocityDPS(LeftMotorVel);
		this->GetMotorByIndex(1)->SetVelocityDPS(LeftMotorVel);
	}
Kind Regards from Germany.


P.S:
I have added the above function into the MyRobot.cpp class, created by the class wizard, which I call from the Main.cpp.

LR
Posts: 305
Joined: Mon Feb 12, 2007 11:55 pm
Location: FR

Post by LR » Sat Jul 24, 2010 12:01 pm

Try something like:

Code: Select all

 _cprintf("Compass(Abs): %f, ", AbsCompass);
 _cprintf("Left US: %f, ", LeftSensor);
 _cprintf("Right US: %f, ", RightSensor );
 _cprintf("Left Encoder: %f, ", LeftEncoder);
 _cprintf("Right Encoder: %f\r\n", RightEncoder); 
LR

AhmadKamalNasir
Posts: 11
Joined: Fri Nov 13, 2009 10:38 am

Post by AhmadKamalNasir » Sat Jul 24, 2010 7:52 pm

Thanks

Post Reply