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

Having problems with using a Xbox controler
http://www.robotc.net/forums/viewtopic.php?f=11&t=8084
Page 1 of 1

Author:  adamelwer [ Thu Feb 27, 2014 8:48 pm ]
Post subject:  Having problems with using a Xbox controler

So Im a noob and trying to set up an Xbox controled clawbot for an openhouse
(Im also trying to switch my coding skills from Python to C, rather unsuccessfully so far)

The controller is set up and recognized by RobotC but keeps throwing errors on the "getJoystickSettings(joystick)

Keep getting **Error**:Undefined procedure 'getJoystickSettings'.

What am I doing wrong? ive got the joystickdriver.c call and I've checked to see that there's actually a
file called that. Do I need to have the files in the same directory?
Trying to get this going for an open house tomorrow :)

Thanks for your help!!

Adam

-here's my code - also Im using Win 7 on boot camp, with robotc 4.05 if that makes anysort of difference

#pragma config(Motor, port1, LeftMotor, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port6, ClawMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, ArmMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, RightMotor, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"


task main()
{

while (true)
{
getJoystickSettings(joystick);

int buffer;
buffer = 20;
int claw;
claw=joystick.joy1_x2;
int arm;
arm = joystick.joy1_y2;
int speed;
speed=joystick.joy1_y1;
int turn;
turn=joystick.joy1_x1;


if (speed < -1*buffer) //forward motion
{
if (turn < -1*buffer) // with left turn
{
startMotor(LeftMotor, speed-(turn/3));
startMotor(RightMotor, speed);
}
else if (turn > buffer) //with right turn
{
startMotor(LeftMotor, speed);
startMotor(RightMotor, speed+(turn/3));
}
else //with no turning
{
startMotor(LeftMotor, speed);
startMotor(RightMotor, speed);
}
}
else if (speed < buffer) //reverse
{
if (turn < -1*buffer) // with left turn
{
startMotor(LeftMotor, speed+(turn/3));
startMotor(RightMotor, speed);
}
else if (turn > buffer) //with right turn
{
startMotor(LeftMotor, speed);
startMotor(RightMotor, speed-(turn/3));
}
else
{
startMotor(LeftMotor, speed);
startMotor(RightMotor, speed);
}
}
else if (speed >= -1*buffer && speed <= buffer) //reverse
{
if (turn < -1*buffer) // with left turn
{
startMotor(LeftMotor,-1*turn );
startMotor(RightMotor, turn);
}
else if (turn > buffer) //with right turn
{
startMotor(LeftMotor, turn);
startMotor(RightMotor, -1*turn);
}
else
{
stopMotor(LeftMotor);
stopMotor(RightMotor);
}


if (claw > buffer)
{
startMotor(ClawMotor,(claw/2));
}
else if (claw < -1* buffer)
{
startMotor(ClawMotor, (claw/2));
}
else if (claw <= buffer && claw >= -1*buffer)
{
stopMotor(ClawMotor);
}
if (arm > buffer)
{
startMotor(ArmMotor,(claw/2));
}
else if (arm < -1* buffer)
{
startMotor(ArmMotor, (claw/2));
}
else if (arm <= buffer && arm >= -1*buffer)
{
stopMotor(ArmMotor);
}
}
}
}

Author:  adamelwer [ Thu Feb 27, 2014 8:52 pm ]
Post subject:  Re: Having problems with using a Xbox controler

Restarted RobotC - now Im getting a new error on the same line - Urg!

**Error**:Undefined variable 'joystickCopy'. 'short' assumed.
**Error**:'*' Indirection levels mismatch. Call to 'memcpy'. Parameter: 'void * pFromBuffer' is 'joystickCopy' of type 'short'.

Author:  JohnWatson [ Fri Feb 28, 2014 10:26 am ]
Post subject:  Re: Having problems with using a Xbox controler

Are you using this with the Virtual Worlds or physical robot Compiler Target? This can be found under the 'Robot -> Compiler Target' menu option; you won't be able to use the Xbox controller to control a physical Cortex robot, as the only remote control connection you will be able to make to the robot is by using the VEXNet system: http://robomatter.com/Shop-By-Robot/VEX ... unications.

However, you will be able to use the Xbox Controller to control a Virtual Worlds robot instead, if you would like. More information on the Virtual Worlds compiler option can be found here: http://www.robotvirtualworlds.com/

Author:  adamelwer [ Fri Feb 28, 2014 1:02 pm ]
Post subject:  Re: Having problems with using a Xbox controler

I was trying to compile to the cortex of a physical robot.

That seems pretty weird that it would only do one but not the other and my only solution is to purchase a 300$ for each of my vex kits (12 in all). Definitely not my favorite answer. :?

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