Go to Post It looks very simple to build, and I like simplicity. - Nick Lawrence [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

 
 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #13   Spotlight this post!  
Unread 13-04-2010, 00:42
Bigcheese Bigcheese is offline
C++0x FTW!
AKA: Michael Spencer
FRC #1771
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2008
Location: GA
Posts: 36
Bigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the rough
Re: Unexpected results from Encoder::GetRate()

Here's 4x decoding data with the same changes to Encoder.cpp as listed above.

http://spreadsheets.google.com/ccc?k...E1zX 2c&hl=en

And here's the relevant code for getting the data.

Code:
void  updateCSV(void* stream)
{
	CompetitionRobot1771* r = CompetitionRobot1771::GetInstance();
	std::ofstream& s = *reinterpret_cast<std::ofstream*>(stream);

	static double left_previous_distance = r->m_PMU.m_leftEncoder.GetDistance();
	static double right_previous_distance = r->m_PMU.m_rightEncoder.GetDistance();
	static double previous_time = static_cast<double>(GetFPGATime() - r->m_BumpTestStartTime) * 1e-6;

	double current_time = static_cast<double>(GetFPGATime() - r->m_BumpTestStartTime) * 1e-6;

	double left_distance = r->m_PMU.m_leftEncoder.GetDistance();
	double right_distance = r->m_PMU.m_rightEncoder.GetDistance();

	double left_derived_rate = (left_distance - left_previous_distance) / (current_time - previous_time);

	double right_derived_rate = (right_distance - right_previous_distance) / (current_time - previous_time);

	double left_rate = r->m_PMU.m_leftEncoder.GetRate();
	double right_rate = r->m_PMU.m_rightEncoder.GetRate();

	s << current_time << "," << r->m_CO << ","
	  << left_distance << "," << left_rate << "," << left_derived_rate << ","
	  << right_distance << "," << right_rate << "," << right_derived_rate << std::endl;

	left_previous_distance = left_distance;
	right_previous_distance = right_distance;
	previous_time = current_time;

	r->GetWatchdog().Feed();
}

void CompetitionRobot1771::Autonomous(void) 
{
	GetWatchdog().SetEnabled(true);
	while(IsAutonomous() && IsEnabled())
	{
		GetWatchdog().Feed();
		std::ofstream csv("bump_test.csv", std::ios::trunc);
		Notifier csv_update(updateCSV, &csv);

		csv << "Time,CO,Left Distance,Left PV,Left Derived PV,Right Distance,Right PV,Right Derived PV\n";
		m_CO = 0;
		m_BumpTestStartTime = GetFPGATime();

		m_PMU.m_leftEncoder.Reset();
		m_PMU.m_rightEncoder.Reset();
		
		csv_update.StartPeriodic(0.005);

		foreach(CANJaguar* c, m_LeftJags)
		{
			c->Set(-m_CO);
		}
		foreach(CANJaguar* c, m_RightJags)
		{
			c->Set(m_CO);
		}
		Wait(0.1);
		
		m_CO = m_BumpTestCO;
		foreach(CANJaguar* c, m_LeftJags)
		{
			c->Set(-m_CO);
		}
		foreach(CANJaguar* c, m_RightJags)
		{
			c->Set(m_CO);
		}
		Wait(m_BumpTestTime);
		
		m_CO  = 0;
		foreach(CANJaguar* c, m_LeftJags)
		{
			c->Set(-m_CO);
		}
		foreach(CANJaguar* c, m_RightJags)
		{
			c->Set(m_CO);
		}
		Wait(m_BumpTestTime);

		csv_update.Stop();
	}
}
I agree that the problem is with the period returned by the FPGA.
Reply With Quote
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[BB] An unexpected change in plans yodameister General Forum 22 01-12-2009 21:26
Inconsistent reading from encoder get rate rwood359 National Instruments LabVIEW and Data Acquisition 5 13-01-2009 19:10
Results from Drexel, thanks from 365. archiver 2001 1 24-06-2002 02:44
Results from GLR? archiver 2001 0 24-06-2002 02:44
results from regionals archiver 2000 0 23-06-2002 22:31


All times are GMT -5. The time now is 08:52.

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