Go to Post if the school doesn't have a team - just start one. - Pattie [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 21-02-2012, 10:46
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Absolute Value of Joystick position

The joysticks I have are somewhat off center slightly so the drive motors are constantly running at like .05 as an example.

This is what I am trying to do below but I think the Abs() function converts it to an Integer. How can I use it on a float (or should I resort to more "or's" in the "if's"

Code:
if(abs(J_stick1.GetY()) <= .05 || abs(J_stick2.GetY()) <= .05)
     R_myRobot.Drive(0.0, 0.0);
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
Reply With Quote
  #2   Spotlight this post!  
Unread 21-02-2012, 10:59
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,015
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: Absolute Value of Joystick position

Quote:
Originally Posted by DavisC View Post
This is what I am trying to do below but I think the Abs() function converts it to an Integer.
My copy of K&R says that fabs()* should be part of the C ANSI standard library.


* fabs() = floating point absolute value



Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2012, 12:09
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Re: Absolute Value of Joystick position

Quote:
error: `fabs' undeclared (first use this function)
This is the message I get when trying to use fabs() where i have abs() in the previous post
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
Reply With Quote
  #4   Spotlight this post!  
Unread 21-02-2012, 12:12
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 987
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Absolute Value of Joystick position

Quote:
Originally Posted by DavisC View Post
This is the message I get when trying to use fabs() where i have abs() in the previous post
Sounds like you are missing this:
Code:
#include "Math.h"
Reply With Quote
  #5   Spotlight this post!  
Unread 21-02-2012, 18:17
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Re: Absolute Value of Joystick position

Thanks, I built it and it didn't produce an error. I will have to wait to test in a week because we sealed the bot and we are making an extra bot.

I will see if i can test it on this 1 scrap bot some day before then hopefully.

Thanks,
Davis
__________________
FRC Team 539
Student Member: 2010 Breakaway - 2014 Aerial Assist
Mentor: 2015 Recycle Rush - present
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:33.

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