View unanswered posts | View active topics It is currently Sun Oct 26, 2014 2:03 am






Reply to topic  [ 4 posts ] 
Having problems with using a Xbox controler 
Author Message
Rookie

Joined: Thu Feb 27, 2014 8:36 pm
Posts: 3
Post 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);
}
}
}
}


Thu Feb 27, 2014 8:48 pm
Profile
Rookie

Joined: Thu Feb 27, 2014 8:36 pm
Posts: 3
Post 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'.


Thu Feb 27, 2014 8:52 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 596
Post 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/

_________________
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


Fri Feb 28, 2014 10:26 am
Profile
Rookie

Joined: Thu Feb 27, 2014 8:36 pm
Posts: 3
Post 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. :?


Fri Feb 28, 2014 1:02 pm
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:  
cron



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