Go to Post Its a good idea to learn to tame CAD monkeys. They're very useful. - Akash Rastogi [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 13-06-2010, 16:28
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Arcade Drive Troubles in Autonomous

Hi all,

I'm almost done with reprogramming this year's robot in C++ instead of LabVIEW. The only thing holding me back from marking it done is the autonomous.

In autonomous I'm telling the robot to go forward like so:
Code:
static const float autonomousForwardPower = -0.5;

//Move forward!
drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);
Same exact drivetrain I use for teleop. I even use the function in teleop. Though it seems no matter what I do the robot turns left at full speed instead of going straight.

I even tried it in teleop and it does the same thing.

So, yeah - I'm confused why this is happening. Thoughts?

-Tanner
Reply With Quote
  #2   Spotlight this post!  
Unread 13-06-2010, 16:40
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Arcade Drive Troubles in Autonomous

Have you checked the hardware? Does it work if you re-load the LabVIEW code?
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
  #3   Spotlight this post!  
Unread 13-06-2010, 16:46
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Radical Pi View Post
Have you checked the hardware? Does it work if you re-load the LabVIEW code?
Hardware is fine as far as I know. Like it drives in teleop fine.

In teleop the code is:
Code:
//Drive the robot
drivetrain->ArcadeDrive(driverJoystick->GetRawAxis(4),driverJoystick->GetRawAxis(2));
Which works perfectly fine. The robot drives straight and turns where I want it to.

The LabVIEW code would probably work if I hadn't lost my flash drive with it on it.

-Tanner

Last edited by Tanner : 13-06-2010 at 16:57.
Reply With Quote
  #4   Spotlight this post!  
Unread 13-06-2010, 17:34
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Arcade Drive Troubles in Autonomous

Are you using Simple Robot or Iterative Robot ?

What other code do you have in autonomous besides what you posted ?
Reply With Quote
  #5   Spotlight this post!  
Unread 13-06-2010, 17:41
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Ether View Post
Are you using Simple Robot or Iterative Robot ?

What other code do you have in autonomous besides what you posted ?
Iterative.

Code:
void AutonomousContinuous(void) {
	printf("Running in autonomous continuous...\n");

	GetWatchdog().Feed();

	if (kicker->HasBall())
	{
		//We have a ball, thus stop moving and kick the ball
		drivetrain->Drive(0.0, 0.0);
		kicker->SetKickerMode(KICKER_MODE_KICK);
	} else {
		//We do not have a ball
		if (kicker->IsKickerInPosition())
		{
			//Move forward!
			drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);
		} else {
			//If not in position, wait for it to be there...
			drivetrain->ArcadeDrive(0.0, 0.0);
			kicker->SetKickerMode(KICKER_MODE_ARM);
		}
	}

	//Run the kicker
	kicker->Act();
}
-Tanner
Reply With Quote
  #6   Spotlight this post!  
Unread 13-06-2010, 18:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Arcade Drive Troubles in Autonomous

Save what you've got, then get rid of everything in autonomous except

drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);

...and see if it drives properly.

If it does, then you've got a weird problem somewhere else in your code. Like for example, are you protecting kicker->Act(); from re-entering?

Edit: I just saw your other post. Uncontrolled re-entry could cause a stack overflow and crash your code.

Last edited by Ether : 13-06-2010 at 18:36.
Reply With Quote
  #7   Spotlight this post!  
Unread 13-06-2010, 18:40
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Ether View Post
If it does, then you've got a weird problem somewhere else in your code. Like for example, are you protecting kicker->Act(); from re-entering?

Edit: I just saw your other post. Uncontrolled re-entry could cause a stack overflow and crash your code.
Protecting kicker->Act(); from re-entering? Sorry, but what do you mean by that? I've never heard of that.

-Tanner
Reply With Quote
  #8   Spotlight this post!  
Unread 13-06-2010, 18:44
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Arcade Drive Troubles in Autonomous

re-entering is when a function is called again before it finishes being called the first time. The variables in your kicker object may not be in a clean state for the second call, causing a crash
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
  #9   Spotlight this post!  
Unread 13-06-2010, 18:54
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Radical Pi View Post
re-entering is when a function is called again before it finishes being called the first time. The variables in your kicker object may not be in a clean state for the second call, causing a crash
Ah. How would one prevent this?

I think though re-entering has more to do with the robot crashing than the robot not being able to drive straight from arcadeDrive(). Unless they're somehow weirdly related and the kicker is affecting the drivetrain.

-Tanner
Reply With Quote
  #10   Spotlight this post!  
Unread 13-06-2010, 18:58
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Tanner View Post
Protecting kicker->Act(); from re-entering? Sorry, but what do you mean by that? I've never heard of that.

-Tanner
You are running AutonomousContinuous, which means the cRIO is repeatedly running your autonomous code as fast as it possibly can. You are calling the kicker->Act() method each time. I haven't seen the rest of your code; if there's another concurrent thread which also calls kicker->Act() it might cause a problem.

Removing everything except
drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);
and testing to see if that fixes the problem is a quick way to help pinpoint the problem.

Last edited by Ether : 14-06-2010 at 06:58. Reason: clarified per Pat's post #15
Reply With Quote
  #11   Spotlight this post!  
Unread 13-06-2010, 19:01
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Tanner View Post
Unless they're somehow weirdly related and the kicker is affecting the drivetrain.
That's why you should remove all the code except

drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);

and see if it fixes the problem.
Reply With Quote
  #12   Spotlight this post!  
Unread 13-06-2010, 19:12
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Ether View Post
That's why you should remove all the code except
drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);
and see if it fixes the problem.
I'll have to see tomorrow as I'm done with the robot for today.

I'm not sure how I would rethink to fix this. How would I protect the function from reentry? A google search on the topic didn't bring up anything other than NASA links.

-Tanner
Reply With Quote
  #13   Spotlight this post!  
Unread 13-06-2010, 19:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Tanner View Post
How would I protect the function from reentry? A google search on the topic didn't bring up anything other than NASA links.
It's pretty easy. Here's some pseudocode:

Code:
Declare a static boolean within the method, say "kicker_busy".

if kicker_busy exit;

kicker_busy=1;

// put your code here.  It's now protected from re-entry.

kicker_busy=0;

//return
But before you do that, please see what happens when you remove everything except
drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);
Reply With Quote
  #14   Spotlight this post!  
Unread 13-06-2010, 19:23
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Arcade Drive Troubles in Autonomous

Quote:
Originally Posted by Ether View Post
It's pretty easy. Here's some pseudocode:

<CODE>

But before you do that, please see what happens when you remove everything except
drivetrain->ArcadeDrive(autonomousForwardPower, 0.0);
Ah. That seems pretty simple. I was so over thinking it.

I'll take a look at that tomorrow and then get back.

Thanks for the help.

-Tanner
Reply With Quote
  #15   Spotlight this post!  
Unread 13-06-2010, 20:01
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,132
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: Arcade Drive Troubles in Autonomous

I suspect that your problem is that your RobotDrive class is not set up properly for the way your robot is wired (one side is either not inverted (using RobotDrive::SetInvertedMotor()), or inverted when it shouldn't be).

It's probably just working in teleop mode by lucky coincidence, because your joystick setup looks strange - you're feeding what seems to be the twist axis (4) into the moveValue parameter of ArcadeDrive, and the Y-axis (2) into the rotateValue parameter.

I doubt the non-reentrancy of your kicker function is the issue, because non-reentrant functions only cause problems when they're called more than once at the same time (i.e. by different threads), and I'm pretty sure all the Periodic/Continuous methods in IterativeRobot execute in the same thread.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Semi-Omni-Arcade Drive byteit101 Programming 20 24-01-2010 08:21
Programming Arcade Drive kyungjin C/C++ 4 06-04-2009 11:28
Non-Arcade Drive causes problems in Autonomous... pinballwizard96 NI LabVIEW 2 01-02-2009 20:45
Arcade/Tank Drive Malfunction piedmont Programming 2 19-01-2009 17:37
Arcade Drive Anfony VEX 4 08-11-2006 19:46


All times are GMT -5. The time now is 03:25.

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