View unanswered posts | View active topics It is currently Wed Oct 01, 2014 4:57 am






Reply to topic  [ 5 posts ] 
Upgrading from robotc 2.x to 3.x 
Author Message
Rookie

Joined: Sat Nov 19, 2011 11:23 am
Posts: 3
Post Upgrading from robotc 2.x to 3.x
I just recently upgraded to 3.x and none of my teleop code is working.

Here is the code:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  none)
#pragma config(Motor,  mtr_S1_C1_1,     motorRight1,   tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorRight2,   tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motorLeft1,    tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     motorLeft2,    tmotorNormal, openLoop)
#pragma config(Servo,  srvo_S1_C3_1,    rightServo,           tServoNormal)
#pragma config(Servo,  srvo_S1_C3_2,    leftServo,            tServoNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


#include "JoystickDriver.c"

const int JOYSTICKPADDING = 17;
const float JOYSTICKRATIO = .7813;

int leftPower, rightPower;

void setMotors(int leftMotorPower, int rightMotorPower){
  motor[motorLeft1] = leftMotorPower;
  motor[motorLeft2] = leftMotorPower;

  motor[motorRight1] = rightMotorPower;
  motor[motorRight2] = rightMotorPower;
}

void setServos(int leftServoAngle, int rightServoAngle){
  servo[leftServo] = leftServoAngle;
  servo[rightServo] = rightServoAngle;
}

task main()
{
  waitForStart();   // wait for start of tele-op phase

  while (true)
  {


    getJoystickSettings(joystick); // Update Joystick variables


    leftPower = (int)(joystick.joy1_y1 * JOYSTICKRATIO);
    rightPower = (int)(joystick.joy1_y2 * JOYSTICKRATIO);

    if (abs(leftPower) < JOYSTICKPADDING) {
      leftPower = 0;
    }

    if (abs(rightPower) < JOYSTICKPADDING) {
      rightPower = 0;
    }

    setMotors(leftPower, rightPower);


    if(joy1Btn(5)){
      setServos(0, 260);
    }else if(joy1Btn(6)){
      setServos(80,175);
    }
  }
}



Does anyone know how to fix this code for robotc 3.x


Last edited by ohsrobotics on Sun Nov 20, 2011 5:48 pm, edited 2 times in total.



Sat Nov 19, 2011 11:26 am
Profile
Rookie

Joined: Sat Nov 19, 2011 11:23 am
Posts: 3
Post Re: Upgrading from robotc 2.x to 3.x
In robotc 2.02 when I called waitForStart() the nxt would show a screen that said waiting for start, then I would open the debugger window and press telop: running. Now the nxt just says program running... and when I press teleop: running on debug window nothing happens


Sat Nov 19, 2011 12:01 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post Re: Upgrading from robotc 2.x to 3.x
Check your Platform type by going to the "Robot" menu, then "Platform Type", then selecting NXT + TETRIX. Then you need to make sure that "Compiler Target" is set to Physical robot.

Also, did you start a new competition template by going to New -> Autonomous Template and New -> User Control Template?

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Sun Nov 20, 2011 3:46 pm
Profile
Rookie

Joined: Sat Nov 19, 2011 11:23 am
Posts: 3
Post Re: Upgrading from robotc 2.x to 3.x
I already had the platform type set to NXT + TETRIX and the Compiler Target was already Physical robot.

I didn't create the program from the template but does that actually change anything? This same code worked in robotc 2.02


Sun Nov 20, 2011 5:47 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post Re: Upgrading from robotc 2.x to 3.x
Aside from the competition template itself, there were a ton of changes since 2.02. So I would suggest placing your code within the Competition template found in 3.x first, and then we'll work from there.

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Mon Nov 21, 2011 10:17 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.