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

1 Controller, 2 Control Schemes?
http://robotc.net/forums/viewtopic.php?f=52&t=4305
Page 1 of 1

Author:  JhaneelJha [ Thu Mar 01, 2012 9:23 pm ]
Post subject:  1 Controller, 2 Control Schemes?

Our robot picks up crates but it has a very narrow sweet spot to grab them. I was thinking of testing a double control scheme. When button 5 is pressed a second drive train control system should kick in. It would work something like this.
Code:
#pragma config(Hubs,  S1, HTServo,  HTMotor,  HTMotor,  HTMotor)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C2_1,     liftr,         tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     cnv,           tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     liftl,         tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_2,     motorG,        tmotorNone, openLoop)
#pragma config(Motor,  mtr_S1_C4_1,     rightm,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C4_2,     leftm,         tmotorNormal, openLoop, reversed)
#pragma config(Servo,  srvo_S1_C1_1,    clamp,                tServoStandard)
#pragma config(Servo,  srvo_S1_C1_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

void initializeRobot()
{
  nxtDisplayCenteredTextLine(0, "1337 |-|@cker");
  nxtDisplayCenteredTextLine(1, "TeleOp");
  nxtDisplayCenteredTextLine(2, "by Neel Jha");

  return;
}
void Slowmo() //drive train controls slowed down
{
  while(joy1Btn(5))
  {
   if(joystick.joy1_y1 > 5 || joystick.joy1_y1 < -5)
    {
      motor[leftm] = (joystick.joy1_y1/10);
    }
    else
    {
      motor[leftm] = 0;
    }
    if(joystick.joy1_y2 > 5 || joystick.joy1_y2 < -5)
    {
      motor[rightm] = (joystick.joy1_y2/10);
    }
    else
    {
      motor[rightm] = 0;
    }
}
}
task main()
{
  initializeRobot();
  waitForStart();      // wait for start of tele-op phase

  while(true)
  {
   
    getJoystickSettings(joystick);
    Slowmo(); // a call to Slowmo, so if Btn 5 is pressed this should hopefully take over drive train
//standard drive train control
    if(joystick.joy1_y1 > 5 || joystick.joy1_y1 < -5)
    {
      motor[leftm] = joystick.joy1_y1;
    }
    else
    {
      motor[leftm] = 0;
    }
    if(joystick.joy1_y2 > 5 || joystick.joy1_y2 < -5)
    {
      motor[rightm] = joystick.joy1_y2;
    }
    else
    {
      motor[rightm] = 0;
    }
}
}

Is this even possible, or will the 2 conflicting sets of controls conflict with each other. I just thought of this and haven't tested it yet.

Author:  NeXT-Generation [ Thu Mar 01, 2012 9:27 pm ]
Post subject:  Re: 1 Controller, 2 Control Schemes?

I don't see any problems with that. I think it should work fine.

Author:  JhaneelJha [ Thu Mar 01, 2012 9:30 pm ]
Post subject:  Re: 1 Controller, 2 Control Schemes?

I don't either I'm just afraid of testing it because of the two sets of opposing contols intefering with each other and possibly (worst case scenario burning out the motors).

Author:  NeXT-Generation [ Thu Mar 01, 2012 9:34 pm ]
Post subject:  Re: 1 Controller, 2 Control Schemes?

JhaneelJha wrote:
I don't either I'm just afraid of testing it because of the two sets of opposing contols intefering with each other and possibly (worst case scenario burning out the motors).


There aren't really any "opposing" controls. It's just a condition that changes the motor speed when a button is pressed. The motors aren't gonna be receiving different commands. You should be just fine.

Author:  MHTS [ Thu Mar 01, 2012 10:38 pm ]
Post subject:  Re: 1 Controller, 2 Control Schemes?

Why don't you do something like this:
Code:
#pragma config(Hubs,  S1, HTServo,  HTMotor,  HTMotor,  HTMotor)
#pragma config(Sensor, S1,     ,                    sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C2_1,     liftr,         tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     cnv,           tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     liftl,         tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C3_2,     motorG,        tmotorNone, openLoop)
#pragma config(Motor,  mtr_S1_C4_1,     rightm,        tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C4_2,     leftm,         tmotorNormal, openLoop, reversed)
#pragma config(Servo,  srvo_S1_C1_1,    clamp,                tServoStandard)
#pragma config(Servo,  srvo_S1_C1_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

void initializeRobot()
{
  nxtDisplayCenteredTextLine(0, "1337 |-|@cker");
  nxtDisplayCenteredTextLine(1, "TeleOp");
  nxtDisplayCenteredTextLine(2, "by Neel Jha");

  return;
}
task main()
{
  int scaleFactor;
  initializeRobot();
  waitForStart();      // wait for start of tele-op phase

  while(true)
  {
    getJoystickSettings(joystick);
    scaleFactor = joy1Btn(5)? 10: 1;
    if(joystick.joy1_y1 > 5 || joystick.joy1_y1 < -5)
    {
      motor[leftm] = joystick.joy1_y1/scaleFactor;
    }
    else
    {
      motor[leftm] = 0;
    }
    if(joystick.joy1_y2 > 5 || joystick.joy1_y2 < -5)
    {
      motor[rightm] = joystick.joy1_y2/scaleFactor;
    }
    else
    {
      motor[rightm] = 0;
    }
 }
}

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