Go to Post Happy 6 days till FIRSTmas! (and Happy New Year, but that pales in comparison =D) - VKP [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 22-01-2017, 14:33
Glitch159's Avatar
Glitch159 Glitch159 is offline
Registered User
FRC #0839 (Rosie Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2009
Location: Agawam, Mass
Posts: 3
Glitch159 is an unknown quantity at this point
Motion Profiling won't work

Hello! So, we are testing motion profiling on a robot, and we are able to feed the points to it, but it doesn't seem to want to actually utilize these points for anything (as in, it is getting the points, but not moving at all). We've made sure that the robot is physically fully functional, so it isn't a hardware problem. Any help would be appreciated. Thanks
Reply With Quote
  #2   Spotlight this post!  
Unread 22-01-2017, 15:20
TimTheGreat's Avatar
TimTheGreat TimTheGreat is online now
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 238
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Motion Profiling won't work

Quote:
Originally Posted by Glitch159 View Post
Hello! So, we are testing motion profiling on a robot, and we are able to feed the points to it, but it doesn't seem to want to actually utilize these points for anything (as in, it is getting the points, but not moving at all). We've made sure that the robot is physically fully functional, so it isn't a hardware problem. Any help would be appreciated. Thanks
Something like this is really hard to diagnose without some code. Could you share it?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #3   Spotlight this post!  
Unread 22-01-2017, 17:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
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: Motion Profiling won't work

Quote:
Originally Posted by Glitch159 View Post
we are testing motion profiling on a robot, and we are able to feed the points to it, but it doesn't seem to want to actually utilize these points for anything
Have you carefully followed the detailed steps provided in Section 6 of this document?


Reply With Quote
  #4   Spotlight this post!  
Unread 23-01-2017, 19:24
Glitch159's Avatar
Glitch159 Glitch159 is offline
Registered User
FRC #0839 (Rosie Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2009
Location: Agawam, Mass
Posts: 3
Glitch159 is an unknown quantity at this point
Re: Motion Profiling won't work

First of all, that entire document has been read in it's entirety, and we made sure that we added in everything that was specified that we would need. Second of all, here is the code:

Code:
package org.usfirst.frc.team839.robot.commands;

import org.usfirst.frc.team839.robot.instrumentation;

import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.CANTalon.FeedbackDevice;
import edu.wpi.first.wpilibj.CANTalon.TalonControlMode;
import edu.wpi.first.wpilibj.command.Command;

public class GoodMotionProfileCommand extends Command
{

	CANTalon _talon = new CANTalon(5);
	CANTalon _talonSlave = new CANTalon(4);
	
	//MotionProfileExample _example = new MotionProfileExample(_talon);
	private CANTalon.MotionProfileStatus _status = new CANTalon.MotionProfileStatus();

	boolean isFinished = false;
	double[][] profile;
	public GoodMotionProfileCommand(double[][] points)
	{
		System.out.println("GoodMotionProfileCommand constructor");
		profile = points;
	}

	@Override
	protected void initialize()
	{

		System.out.println("GoodMotionProfileCommand initialize");

		_talon.clearMotionProfileTrajectories();
		_talon.setFeedbackDevice(CANTalon.FeedbackDevice.QuadEncoder);
		_talon.reverseSensor(false);
		
		_talon.changeControlMode(TalonControlMode.MotionProfile);
//		_talonSlave.changeControlMode(TalonControlMode.Follower);
//		_talonSlave.set(5);
		
		_talon.set(CANTalon.SetValueMotionProfile.Disable.value);
		_talon.changeMotionControlFramePeriod(10);
		
		//feed Trajectory Points
		fill(profile,profile.length);
		_talon.set(CANTalon.SetValueMotionProfile.Enable.value);
//		_talon.processMotionProfileBuffer();
	}

	private void fill(double[][] profile, int totalCnt) {

		System.out.println("GoodMotionProfileCommand fill");
		/* create an empty point */
		CANTalon.TrajectoryPoint point = new CANTalon.TrajectoryPoint();

		for (int i = 0; i < totalCnt; ++i) {
			/* for each point, fill our structure and pass it to API */
			point.position = profile[i][0];
			point.velocity = profile[i][1];
			point.timeDurMs = (int) profile[i][2];
			point.profileSlotSelect = 0; /* which set of gains would you like to use? */
			point.velocityOnly = true; /* set true to not do any position
										 * servo, just velocity feedforward
										 */
			point.zeroPos = false;
			if (i == 0)
				point.zeroPos = true; /* set this to true on the first point */

			point.isLastPoint = false;
			if ((i + 1) == totalCnt)
				point.isLastPoint = true; /* set this to true on the last point  */

			_talon.pushMotionProfileTrajectory(point);
		}
	}
	

	
	@Override
	protected void execute()
	{
		_talon.getMotionProfileStatus(_status);

		if(_status.hasUnderrun)
		{
			System.out.println("GoodMotionProfileCommand _status.hasUnderrun");

			//load points
			_talon.clearMotionProfileHasUnderrun();;
			_talon.processMotionProfileBuffer();
		}
		
		if (_status.activePointValid && _status.activePoint.isLastPoint)
		{
			System.out.println("GoodMotionProfileCommand  _status.activePoint.isLastPoint");
			_talon.set(CANTalon.SetValueMotionProfile.Hold.value);
			isFinished = true;

		}
		else
		{
			instrumentation.process(_status);
			_talon.set(CANTalon.SetValueMotionProfile.Enable.value);
			_talon.processMotionProfileBuffer();
		}

	}
	@Override
	protected boolean isFinished()
	{
		return isFinished;
	}

	@Override
	protected void end()
	{
		System.out.println("GoodMotionProfileCommand end");
		_talon.set(CANTalon.SetValueMotionProfile.Hold.value);
		_talon.clearMotionProfileTrajectories();
		_talon.set(CANTalon.SetValueMotionProfile.Disable.value);
		_talon.changeControlMode(TalonControlMode.Voltage);
	}

	@Override
	protected void interrupted()
	{
		
	}
}
Reply With Quote
  #5   Spotlight this post!  
Unread 23-01-2017, 23:03
ozrien's Avatar
ozrien ozrien is online now
Omar Zrien
AKA: Omar
no team
Team Role: Mentor
 
Join Date: Sep 2006
Rookie Year: 2003
Location: Sterling Heights, MI
Posts: 537
ozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond reputeozrien has a reputation beyond repute
Re: Motion Profiling won't work

Did you set the gains?

Screenshot the selftest in the web based config.

What firmware version?
Reply With Quote
  #6   Spotlight this post!  
Unread 25-01-2017, 19:07
Glitch159's Avatar
Glitch159 Glitch159 is offline
Registered User
FRC #0839 (Rosie Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2009
Location: Agawam, Mass
Posts: 3
Glitch159 is an unknown quantity at this point
Re: Motion Profiling won't work

Quote:
Originally Posted by ozrien View Post
Did you set the gains?

Screenshot the selftest in the web based config.

What firmware version?
Firmware is up to date, and we added the Feed-forward gains as well as P, I, and D gains. We finally have the motors turning now However, there is a new problem: we've had to ramp up the acceleration value to something that sounds unreasonable.
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 13:15.

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