Go to Post If Teflon-coated pans have a no-stick surface, then how to they get the Teflon to stick to the pans? - dlavery [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 12-01-2009, 18:21
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
need help understanding c code in robotdrive

hey...
i have this code that i got from WPILib. its a part from robotdrive.cpp
Code:
 RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor,
						SpeedController *frontRightMotor, SpeedController *rearRightMotor,
						float sensitivity)
i just copied it and pasted here from notepad.

i want to understand what is float sensitivity?? what could i put on it?
and other question: can i replace speedcontroller *...... with a number of the pwm in the digital sidecar? i mean if i am using a victor and have a connection for pwm number 1 so could i write for example :
Code:
myrobot.robotdrive(1,2,3,4,float sensitivity)
and here are constructor maybe it could help:
Code:
* Constructor for RobotDrive with 4 motors specified as SpeedController objects.
 * Speed controller input version of RobotDrive (see previous comments).
 * @param rearLeftMotor The back left SpeedController object used to drive the robot.
 * @param frontLeftMotor The front left SpeedController object used to drive the robot
 * @param rearRightMotor The back right SpeedController object used to drive the robot.
 * @param frontRightMotor The front right SpeedController object used to drive the robot.
 * @param sensitivity Effectively sets the turning sensitivity (or turn radius for a given value)
help me rapidly please
Reply With Quote
  #2   Spotlight this post!  
Unread 12-01-2009, 20:34
360skier 360skier is offline
RTFM!!
AKA: Eric A.
FRC #1334 (Red Devils)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Oakville, Ontario
Posts: 45
360skier is an unknown quantity at this point
Re: need help understanding c code in robotdrive

Sensitivity is a multiplier in case you have a different brand of joystick (from what I can understand). I'd set it to 1.
Reply With Quote
  #3   Spotlight this post!  
Unread 13-01-2009, 08:25
charrisTTI charrisTTI is offline
Ramblin' Wreck
AKA: Charles Harris
FRC #0623
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Vienna, VA
Posts: 106
charrisTTI has a spectacular aura aboutcharrisTTI has a spectacular aura about
Send a message via AIM to charrisTTI
Re: need help understanding c code in robotdrive

Here are the constructor declarations from robotdrive.h:

RobotDrive(UINT32 leftMotorChannel, UINT32 rightMotorChannel, float sensitivity = 0.5);
RobotDrive(UINT32 frontLeftMotorChannel, UINT32 rearLeftMotorChannel,
UINT32 frontRightMotorChannel, UINT32 rearRightMotorChannel, float sensitivity = 0.5);
RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor, float sensitivity = 0.5);
RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor, float sensitivity = 0.5);
RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor,
SpeedController *frontRightMotor, SpeedController *rearRightMotor,
float sensitivity = 0.5);
RobotDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor,
SpeedController &frontRightMotor, SpeedController &rearRightMotor,
float sensitivity = 0.5);

This is the comment for the sensitivity parameter.

* @param sensitivity Effectively sets the turning sensitivity (or turn radius for a given value)

In each contstructor, there is a default value for the sensitivity parameter of 0.5.

If you want to use the default value, do not specify any value in that position.

ie:

myrobot.robotdrive(1,2,3,4); // using the default sensitivity of 0.5


If we go the .cpp file we can see how sensitivity is used.

In each of the constructors, the sensitivity parameter is copied to the class member variable m_sensitivity.

m_sensitivity = sensitivity;


The only method which uses m_sensitivity is Drive:

/**
* Drive the motors at "speed" and "curve".
*
* The speed and curve are -1.0 to +1.0 values where 0.0 represents stopped and
* not turning. The algorithm for adding in the direction attempts to provide a constant
* turn radius for differing speeds.
*
* This function sill most likely be used in an autonomous routine.
*
* @param speed The forward component of the speed to send to the motors.
* @param curve The rate of turn, constant for different forward speeds.
*/
void RobotDrive :: Drive(float speed, float curve)
{
float leftSpeed, rightSpeed;

if (curve < 0)
{
float value = log(-curve);
float ratio = (value - m_sensitivity)/(value + m_sensitivity);
if (ratio == 0) ratio =.0000000001;
leftSpeed = speed / ratio;
rightSpeed = speed;
}
else if (curve > 0)
{
float value = log(curve);
float ratio = (value - m_sensitivity)/(value + m_sensitivity);
if (ratio == 0) ratio =.0000000001;
leftSpeed = speed;
rightSpeed = speed / ratio;
}
else
{
leftSpeed = speed;
rightSpeed = speed;
}
SetLeftRightMotorSpeeds(leftSpeed, rightSpeed);
}
__________________
FRC 623 2003,2004,2005,2006,2007,2008, 2009, 2010, 2011
FRC 1900 2007
FVC 60 and 193 2006
FVC 3271 2007
FTC 226 and 369 2008, 2009, 2010, 2011
FTC 3806 2010
Reply With Quote
  #4   Spotlight this post!  
Unread 13-01-2009, 11:30
Ryan O's Avatar
Ryan O Ryan O is offline
FRC Eclipse Plug-in Developer
no team (FRC Eclipse)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Plaistow
Posts: 111
Ryan O is an unknown quantity at this point
Send a message via AIM to Ryan O
Re: need help understanding c code in robotdrive

In answer to sensitivity:

Don't worry about it, it
a) Has a default value
and
b) Will be gone soon if it isn't already


In answer to your other question, you cannot pass a pwm number into the function - speedcontroller is an "placeholder" class, designed to allow operations on victors and jaguars by the same functions - so it does need to a class derived from speedcontroller
__________________
CRUD Name: Windows
Rookie Year: 2005
Alumni to Team: 350
Reply With Quote
  #5   Spotlight this post!  
Unread 13-01-2009, 15:21
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
Re: need help understanding c code in robotdrive

ok which code i could use to pass a pwm number ??
maybe this??
Code:
RobotDrive::RobotDrive(UINT32 frontLeftMotor, UINT32 rearLeftMotor,
		UINT32 frontRightMotor, UINT32 rearRightMotor, float sensitivity)
Reply With Quote
  #6   Spotlight this post!  
Unread 13-01-2009, 15:24
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
Re: need help understanding c code in robotdrive

or can u write the code we can use to drive 4 motors (2 left . 2 right) with one joystick ... so i could copy it to the simple template i got from frc and delete the tank code or the arcade...
Reply With Quote
  #7   Spotlight this post!  
Unread 13-01-2009, 20:57
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
Re: need help understanding c code in robotdrive

still waiting !!!
Reply With Quote
  #8   Spotlight this post!  
Unread 13-01-2009, 21:17
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: need help understanding c code in robotdrive

Quote:
Originally Posted by mahmosh View Post

i want to understand what is float sensitivity?? what could i put on it?
and other question: can i replace speedcontroller *...... with a number of the pwm in the digital sidecar? i mean if i am using a victor and have a connection for pwm number 1 so could i write for example :
Code:
myrobot.robotdrive(1,2,3,4,float sensitivity)
the sensitivity parameter you can leave out.

As far as replacing speedcontroller if you look at the class the constructor is overloaded and one of the possible variations is:

Code:
	RobotDrive(UINT32 frontLeftMotorChannel, UINT32 rearLeftMotorChannel,
				UINT32 frontRightMotorChannel, UINT32 rearRightMotorChannel, float sensitivity = 0.5);
so you could do
Code:
myrobot.robotdrive(1,2,3,4);
then for arcade
Code:
myrobot.ArcadeDrive(stick);
for 1 joystick control
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
Reply With Quote
  #9   Spotlight this post!  
Unread 14-01-2009, 17:36
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
Re: need help understanding c code in robotdrive

yeah thanks it is working for arcade drive ... but if i wanna all 4 wheels get just (y)axis speed what i have to change ...
second Q. : We wanna use this year 2 motors to control the directions(see attachment files)
we have to make the motors number 1,2,3,4 just get speed from (y)axis
and motor number 5,6 ... get the directions by (x) axis - {we wanna use one joystick for driving not more like tank!
so who can help me to do this ?
Attached Thumbnails
Click image for larger version

Name:	chassi.JPG
Views:	37
Size:	9.5 KB
ID:	7146  
Reply With Quote
  #10   Spotlight this post!  
Unread 14-01-2009, 21:06
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 591
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: need help understanding c code in robotdrive

Quote:
Originally Posted by mahmosh View Post
yeah thanks it is working for arcade drive ... but if i wanna all 4 wheels get just (y)axis speed what i have to change ...
second Q. : We wanna use this year 2 motors to control the directions(see attachment files)
we have to make the motors number 1,2,3,4 just get speed from (y)axis
and motor number 5,6 ... get the directions by (x) axis - {we wanna use one joystick for driving not more like tank!
so who can help me to do this ?
The class and the methods were designed for simple 2 and 4 motor drive robots with skid steering. If you have more complex designs then you might consider subclassing the RobotDrive class and adding your own method to control the motors. Also you grab the source code and modify it to work in your robot, although subclassing where possible is usually a better solution.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #11   Spotlight this post!  
Unread 14-01-2009, 21:35
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 591
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: need help understanding c code in robotdrive

There are three ways of getting the robot to turn under program control in the library:
  1. RobotDrive:: Drive(speed, curve) - this takes a forward speed and rate of curve value. It tries to use the curve value to create a constant angle curve regardless of speed. We'd be interested in feedback on how well it's working for you. The sensitivity parameter is used to modify that turn rate based on the curve parameter.
  2. RobotDrive::ArcadeDrive(moveValue, rotateValue) - uses the moveValue for forward speed and the rotateValue to bias the left and right sides of the robot like you would expect. One interesting thing here is that there is an optional parameter where it will square the inputs. Because the parameters are between -1.0 and 1.0 squaring the input has the effect of making the robot more sensitive at low speeds (expanding the low end of the joystick range). This can also be used with a Joystick parameter making it very easy to create a driving robot.
  3. RobotDrive::TankDrive(leftValue, rightValue) - the traditional tank drive sending the leftValue to the left side of the robot and the rightValue to the right side of the robot. This can also be used with Joystick parameters making it very easy to create a driving robot.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #12   Spotlight this post!  
Unread 15-01-2009, 10:49
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
Re: need help understanding c code in robotdrive

thank u
can u help me how to use this parameters to our robot??
i just want to give a speed by joystick (y) axis (forward,backward) to all the wheels
and the curves i wanna make by the same joystick (x) axis but not for the same motors .... see the picture again that i attached
Reply With Quote
  #13   Spotlight this post!  
Unread 15-01-2009, 15:22
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: need help understanding c code in robotdrive

Code:
Joystick stick1(1);//ds port1
RobotDrive rd(1,2);//pwm port 1 and 2
at the top
and
Code:
rd.ArcadeDrive(stick1);
in the telop while loop
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Reply With Quote
  #14   Spotlight this post!  
Unread 15-01-2009, 15:43
mahmosh's Avatar
mahmosh mahmosh is offline
Registered User
FRC #1946
 
Join Date: Jan 2008
Location: israel
Posts: 125
mahmosh is an unknown quantity at this point
Re: need help understanding c code in robotdrive

can you tell me what this code for exactly?
Reply With Quote
  #15   Spotlight this post!  
Unread 16-01-2009, 08:56
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: need help understanding c code in robotdrive

Code:
Joystick stick1(1);
//Declare Variable "stick1" of type "Joystick" on 
//Driverstation Port 1 "(1)"
RobotDrive rd(1,2);
//create variable "rd" of type "RobotDrive" (which controls 2
//or 4 pwm's for a base) with 2 pwm's on pwm ports 1 and 2 "(1,2)"
at the top
and
Code:
rd.ArcadeDrive(stick1);
//Arcade drives (one joystick) the RobotBase rd with
//the paramaters for speed and turn in Joystick stick1
in the telop while loop
Got it?
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
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
Help for Better Understanding of Shaft Encoders Xufer Programming 2 08-01-2007 23:14
need help w/ joystick code willie837 Programming 6 02-02-2005 23:17
code violation...need help Vince lau Programming 4 20-02-2004 16:31
Help with understanding Fuse panel Blue_Midnight Electrical 3 10-02-2004 23:12
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46


All times are GMT -5. The time now is 02:58.

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