Go to Post Humility tends to take people places, pompous boasts tend to get people left at home by themselves. - Karthik [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 24-02-2012, 17:24
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Errors when running

Hi,
Our code uses the command based robot template, and builds and downloads with no problems. However, there is an error message that comes in waves through the console, and sometimes creates lag issues. It looks like this:

Assertion failed: "(rawValue >= GetMinNegativePwn()) && (rawValue <= GetMaxPositivePwn())" in SetSpeed() in C://WindRiver/workspace/WPILib/PWM.cpp at line 241

This message then repeats itself a bunch of times and then stops, and comes back again sometime later.

When it happens, it often creates lag, which might be detrimental when it comes to the competition. Any help would be greatly appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread 27-02-2012, 07:57
frdrake frdrake is offline
Registered User
FRC #0233
 
Join Date: Feb 2012
Location: Melbourne
Posts: 23
frdrake is on a distinguished road
Re: Errors when running

What's the rest of that statement? Are you calling an ASSERT? Without seeing the entire command one can only guess what the issue may be.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-02-2012, 16:07
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Errors when running

The errors happen in the console, and no where in our code do we use anything directly from a PWM class. I'm thinking somehow, the jaguars and victors are causing it. Do you want me to post code that operates on those objects?
Reply With Quote
  #4   Spotlight this post!  
Unread 28-02-2012, 08:57
frdrake frdrake is offline
Registered User
FRC #0233
 
Join Date: Feb 2012
Location: Melbourne
Posts: 23
frdrake is on a distinguished road
Re: Errors when running

I'm sure you include WPILib and by extension you are also including the PWM.cpp. I bet if you look in the PWM.cpp file at the line specified there will be an assertion of some kind made by that code that is then failing and that's why you're getting this error. I'm at work and don't have the libraries in front of me to try and find it myself. Some part of your inputs the PWM doesn't like.
Reply With Quote
  #5   Spotlight this post!  
Unread 28-02-2012, 11:01
rbmj rbmj is offline
Registered User
FRC #0612 (Chantilly Robotics)
Team Role: Alumni
 
Join Date: Apr 2011
Rookie Year: 2011
Location: DC Area/Fairfax County
Posts: 192
rbmj is a jewel in the roughrbmj is a jewel in the roughrbmj is a jewel in the rough
Re: Errors when running

Code:
/**
 * Set the PWM value based on a speed.
 * 
 * This is intended to be used by speed controllers.
 * 
 * @pre SetMaxPositivePwm() called.
 * @pre SetMinPositivePwm() called.
 * @pre SetCenterPwm() called.
 * @pre SetMaxNegativePwm() called.
 * @pre SetMinNegativePwm() called.
 * 
 * @param speed The speed to set the speed controller between -1.0 and 1.0.
 */
void PWM::SetSpeed(float speed)
{
	if (StatusIsFatal()) return;
	// clamp speed to be in the range 1.0 >= speed >= -1.0
	if (speed < -1.0)
	{
		speed = -1.0;
	}
	else if (speed > 1.0)
	{
		speed = 1.0;
	}

	// calculate the desired output pwm value by scaling the speed appropriately
	INT32 rawValue;
	if (speed == 0.0)
	{
		rawValue = GetCenterPwm();
	}
	else if (speed > 0.0)
	{
		rawValue = (INT32)(speed * ((float)GetPositiveScaleFactor()) +
									((float) GetMinPositivePwm()) + 0.5);
	}
	else
	{
		rawValue = (INT32)(speed * ((float)GetNegativeScaleFactor()) +
									((float) GetMaxNegativePwm()) + 0.5);
	}

	// the above should result in a pwm_value in the valid range
	wpi_assert((rawValue >= GetMinNegativePwm()) && (rawValue <= GetMaxPositivePwm()));
	wpi_assert(rawValue != kPwmDisabled);

	// send the computed pwm value to the FPGA
	SetRaw((UINT8)rawValue);
}
What speed are you calling the function with (or some object that calls the function). If it's not x|-1.0<=x<=1.0 then that might be the cause of your issues.

Edit: The assert that's failing is the second-to-last assert
Reply With Quote
  #6   Spotlight this post!  
Unread 01-03-2012, 15:53
Supernovapsy Supernovapsy is offline
Registered User
FRC #1334
 
Join Date: Feb 2012
Location: Canada
Posts: 18
Supernovapsy is an unknown quantity at this point
Re: Errors when running

Thanks!

I looked through the code again, and I found a place where I divide the driver input value by itself. This gives NaN when the values are 0, and this created the assertion error.

Thank you everyone, I appreciate everyone's help!
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 02:34.

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