View unanswered posts | View active topics It is currently Sat Aug 30, 2014 6:31 pm






Reply to topic  [ 4 posts ] 
new teleop:compile correctly,but fail to do any movement 
Author Message
Rookie

Joined: Tue Apr 09, 2013 7:53 am
Posts: 3
Post new teleop:compile correctly,but fail to do any movement
The robot is also right.Code:
#pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTServo)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S2, ir1, sensorHiTechnicIRSeeker1200)
#pragma config(Sensor, S3, ir2, sensorHiTechnicIRSeeker1200)
#pragma config(Sensor, S4, safe, sensorTouch)
#pragma config(Motor, motorA, , tmotorNXT, openLoop)
#pragma config(Motor, motorB, , tmotorNXT, openLoop)
#pragma config(Motor, motorC, , tmotorNXT, openLoop)
#pragma config(Motor, mtr_S1_C1_1, wheel_left, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, wheel_right, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, motor3, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, motor4, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, lift, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_2, light, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S1_C4_1, g_switch, tServoStandard)
#pragma config(Servo, srvo_S1_C4_2, servo2, tServoNone)
#pragma config(Servo, srvo_S1_C4_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C4_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C4_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C4_6, servo6, tServoNone)

#include "JoystickDriver.c"

task main()
{
int mThreshold = 10;

int xVal, yVal, zVal;

float scaleFactor = 100 / 127;


while(true)
{
getJoystickSettings(joystick);

xVal = joystick.joy1_x1;
yVal = joystick.joy1_y1;
zVal = joystick.joy1_y2;

if (abs(xVal) < mThreshold)
{
xVal = 0;
}
if (abs(yVal) < mThreshold)
{
yVal = 0;
}

if(joy1Btn(4) == 1)
{
motor[wheel_left] = ((yVal) + (xVal)) * scaleFactor * 15/100;
motor[wheel_right] = ((yVal) - (xVal)) * scaleFactor * 15/100;
if (zVal < 0 && SensorValue(safe) == 1)
{
motor[lift] = 0;
}
else
{
motor[lift] = zVal * scaleFactor * 15/100;
}
}
else if(joy1Btn(4) == 0)
{
motor[wheel_left] = ((yVal) + (xVal)) * scaleFactor;
motor[wheel_right] = ((yVal) - (xVal)) * scaleFactor;
if (zVal < 0 && SensorValue(safe) == 1)
{
motor[lift] = 0;
}
else
{
motor[lift] = zVal * scaleFactor;
}
}
}
}


Tue Apr 09, 2013 8:04 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 566
Post Re: new teleop:compile correctly,but fail to do any movement
Let's take a look at what the variables and commands are doing purely from a numbers stand point:

Code:
float scaleFactor = 100 / 127;
...
motor[wheel_left] = ((yVal) + (xVal)) * scaleFactor * 15/100;
motor[wheel_right] = ((yVal) - (xVal)) * scaleFactor * 15/100;


The float scaleFactor equates to roughly 0.7874, while 15/100 equates to 0.15. Multiplying the two together will result in ~0.11811. Since the maximum theoretical value of the two joysticks together (yVal and xVal) is 254, you are looking at a theoretical maximum motor value of 254 * .11811 = 29.99 (or 30).

The problem is that the max value of 254 is theoretical and not realistically possible; the joystick ranges are physically round on the controller itself (you can't hit the 'corner' and have a max x and y value scenario) so the actual motor value will be even less than that. For instance, pushing the joysticks straight forward (all y values, no x values) nets you a motor speed of 14.99 (or 15), which may not be enough to even move the motors.

The best thing I can suggest is to tweak either scale factor values or the amount you are dividing the motor power by (try dividing by 10 instead of 100 and see what happens). This will allow you to send higher motor power levels to motors.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Apr 09, 2013 11:30 am
Profile
Rookie

Joined: Tue Apr 09, 2013 7:53 am
Posts: 3
Post Re: new teleop:compile correctly,but fail to do any movement
I'm sorry that I have tried to delete the scalefactor and the number like:
code:
motor[wheel_left] = ((xVal)+(yVal))
But it is still not moving,and in fact I have made sure that power > 10 can make the robot move by using labview.
I wonder if there are any problems in grammar or logic.
Thank you!


Wed Apr 10, 2013 3:43 am
Profile
Rookie

Joined: Tue Apr 09, 2013 7:53 am
Posts: 3
Post Re: new teleop:compile correctly,but fail to do any movement
By the way,I have checked that "waitforstart()" doesn't influence.


Wed Apr 10, 2013 3:46 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.