ROBOTC.net forums
http://robotc.net/forums/

remote control
http://robotc.net/forums/viewtopic.php?f=1&t=5116
Page 3 of 3

Author:  royalthemaster [ Mon Dec 03, 2012 5:28 pm ]
Post subject:  Re: remote control

after configuering that code you posted...there came to 94 errors, i dont understand the coding involved with tele-op
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#define DEADBAND_THRESHOLD 15
#define DEADBAND(x) ((abs(x) >= DEADBAND_THRESHOLD)? x: 0)
#define BOUND(x) (((x) > 100)? 100: ((x) < -100)? -100: (x))
#define JOYSTICK_POWER(x) (BOUND(DEADBAND(x)))

#define ARM_MIN_ANGLE 0
#define ARM_MAX_ANGLE 180

task main()
{
    while (true)
    {
        //
        // Get joystick readings.
        //
        getJoystickSettings(joystick);

        //
        // Translate controller 2 right stick x axis value to within motor power range (-100 to 100) and with deadband.
        //
        motor[armRotMotor] = JOYSTICK_POWER(joystick.joy2_x1)/3;
        wait1Msec(100);
    }
}

Author:  MHTS [ Mon Dec 03, 2012 5:43 pm ]
Post subject:  Re: remote control

According to your motor configuration, I assume you are just trying to use the joystick to drive the robot around. If so, you can't just paste my code into your program. That code is for an arm. Here is what you need:
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

#define DEADBAND_THRESHOLD 15
#define DEADBAND(x) ((abs(x) >= DEADBAND_THRESHOLD)? (x): 0)
#define BOUND(x) (((x) > 100)? 100: ((x) < -100)? -100: (x))
#define JOYSTICK_POWER(x) (BOUND(DEADBAND(x)))

task main()
{
    while (true)
    {
        //
        // Get joystick readings.
        //
        getJoystickSettings(joystick);

        //
        // Assuming motorD is the left wheel motor and motorE is the right wheel motor.
        //
        motor[motorD] = JOYSTICK_POWER(joystick.joy1_y1);
        motor[motorE] = JOYSTICK_POWER(joystick.joy1_y2);

        wait1Msec(100);
    }
}

Author:  royalthemaster [ Mon Dec 03, 2012 6:03 pm ]
Post subject:  Re: remote control

it has an error with " getJoystickSettings(joystick); " so tell me, what does this do? is it similair to the line fo code that looks similair to this in some of the sample codes:
#getjoystick.c
?

Author:  MHTS [ Mon Dec 03, 2012 6:06 pm ]
Post subject:  Re: remote control

Sorry, forgot to include JoystickDriver.c. I have updated the code above. The getJoystickSettings() is to update the joystick structure with all the joystick readings.

Author:  royalthemaster [ Fri Jan 04, 2013 12:28 am ]
Post subject:  Re: remote control

Merry Chistmas!
Happy New Years!!!
^_^
okay, breakthrough. I asked 1 of the tech department people of my school to come and help and we found out that everything is actually working correctly (we think) so then the only other possible problem would be the code, so if i were to take that code u posted above, what should i do exactly? (other than config the motors and sensors)

Author:  royalthemaster [ Fri Jan 04, 2013 12:33 am ]
Post subject:  Re: remote control

i ask because in alegebra, an X is a variable which is basically an unkown number, so i am just wondering if that rule applies here to, or if i actually need those X's there

Author:  MHTS [ Fri Jan 04, 2013 1:01 am ]
Post subject:  Re: remote control

Is the above code not working for you? If so, what's not working? You need to give us more details on the problems you have.

Author:  amcerbu [ Fri Jan 04, 2013 1:46 am ]
Post subject:  Re: remote control

You're right, the x in those macros represents an unknown. The macros tell the RobotC compiler to replace every instance of DEADBAND(x) with ((abs(x) >= DEADBAND_THRESHOLD)? (x): 0). There, the x represents whatever is within the parentheses of DEADBAND. For example, if I wrote the line ...
Code:
int variable = DEADBAND(20 + 45);
... the compiler would interpret ...
Code:
int variable = ((abs(20 + 45) >= DEADBAND_THRESHOLD) ? (20 + 45) : 0);
This looks confusing, but it's just compact code. That weird ?: statement is a ternary operator from the C programming language (more information here).

Basically, the following two statements are equivalent, but one is much more compact.
Code:
int variable = ((abs(20 + 45) >= DEADBAND_THRESHOLD) ? (20 + 45) : 0)

if (abs(20 + 40) >= DEADBAND_THRESHOLD)
{
   variable = (20 + 40);
}
else
{
   variable = 0;
}

MHTS provided a few macros for more easily deciding whether to give power to the motors. If the absolute value of the joystick is underneath the deadband (15), the value is not registered. This is because the joysticks don't always settle back to exactly 0; feeding them the joystick value could cause slight unwanted motion.

Author:  royalthemaster [ Mon Jan 07, 2013 6:02 pm ]
Post subject:  Re: remote control

now we have another problem, for some reason the computer is unable to connect to the controller that is hooked up via USB, and i know for a fact that the remote control works because i have playd with the robot in frusteration ( i took a reak and played with the robot moving around wired)
i am begging anybody to post a website showing how to properly configur the remote and the nxt to be able to work correctly and do what it is told.
Thank You

Author:  MHTS [ Mon Jan 07, 2013 6:16 pm ]
Post subject:  Re: remote control

royalthemaster wrote:
now we have another problem, for some reason the computer is unable to connect to the controller that is hooked up via USB, and i know for a fact that the remote control works because i have playd with the robot in frusteration ( i took a reak and played with the robot moving around wired)
i am begging anybody to post a website showing how to properly configur the remote and the nxt to be able to work correctly and do what it is told.
Thank You

I don't understand your description. You said you have problem connecting the computer to the controller. Are you saying you have problem with your laptop recognizing the USB game controller? Or are you saying you have problem having the laptop communicating with the Mindstorms brick via USB cable? You said it doesn't work but then you knew it worked when you were playing with it in frustration? Sorry, I really don't get what you meant. Are you having connectivity problem using Bluetooth or Wifi? Please clarify your problem.

Author:  royalthemaster [ Tue Jan 08, 2013 5:37 pm ]
Post subject:  Re: remote control

forget it...so far we have found out that everything is connecting correctly (as it appears) and yet we dont know what is going on...

the code is good
we know this because we can make it move with the joystick with a wired connection

the samantha can connect to the router and laptop can connect to the router

we are all out of ideas so again please post advice and perhaps a link on how to configur or use the remote control for remote use, or what i need to do with the NXT itself (e.g. code, debugger windows, motors and sensors setup ect.)
thank you for all your hard work, and im sorry this has taken so long

Author:  royalthemaster [ Wed Jan 09, 2013 4:22 pm ]
Post subject:  Re: remote control

okay, new possible answer:
when using the FCS under teams it says "choose" and apprntly the samantha is supposed to show up and show the samanthas name and IP address or something, but ours doesnt...also the samsostat thing on the nxt isnt able to work finish aquiring

so what do we do to fix both of these problems?

Author:  MHTS [ Wed Jan 09, 2013 4:48 pm ]
Post subject:  Re: remote control

If you are just practicing, you don't have to use the Samantha. We use Bluetooth for practicing. Provisioning Samantha is an art. We haven't gotten it to work ourselves either although we did not try very hard. We tried it. It didn't work. We gave up and use Bluetooth instead.

Author:  royalthemaster [ Thu Jan 10, 2013 5:22 pm ]
Post subject:  Re: remote control

O THANK GOD WE ARE NOT ALONE!!! since the start of this thing i have been feeling like we were the only ones not able to get the samantha to work correctly, so can someone link me the proces in which i need to load programs, download things, and then launch certain things idk, anyhing helps...
also the wifi light keeps blinking fast and yet we were able to confirm that the samantha and the router are connecting, so im wondering if i am missing something for passwords or something when using the FCS...

(still not sure how we are supposed to get the samntha module to show up on the FCS team choosing thing0
anything helps, THANK YOU!!!!

Author:  royalthemaster [ Mon Jan 14, 2013 4:28 pm ]
Post subject:  Re: remote control

WE GOT IT TO WORK MUAHAHAAAAAA!!!!
i got it to work at the scrimige at the dallas, and now that we are home it isnt responding, the problem isnt the wifi, we can 100% connect to the robot via the FCS and everything looks like its working, but the robot isnt responding to the remote control wirlesly for some reason...

Page 3 of 3 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/