View unanswered posts | View active topics It is currently Sun Dec 21, 2014 12:45 am






Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
how detect one thing....then another 
Author Message
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: how detect one thing....then another
It seems there are at least two of you trying to do this, so I've made a post with some pictures here: [LINK].

Let me know if that helps you.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Nov 03, 2010 3:32 am
Profile WWW
Rookie

Joined: Fri Oct 15, 2010 2:20 pm
Posts: 17
Location: Rochdale, UK
Post Re: how detect one thing....then another
Yep thats amazing, fantastic help!!! It makes things seem alot more simpler in how to construct the structure of the program. :)

Thanks alot :)


Wed Nov 03, 2010 3:39 pm
Profile
Rookie

Joined: Fri Oct 15, 2010 2:20 pm
Posts: 17
Location: Rochdale, UK
Post Re: how detect one thing....then another
Just to let you know, I have got a working program!! :D

I though I should let you know, since you have helped me alot with it.

So thanks :bigthumb:


Sat Nov 06, 2010 8:00 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3297
Location: Rotterdam, The Netherlands
Post Re: how detect one thing....then another
Could you post it so that others can learn from it?

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Nov 06, 2010 1:35 pm
Profile WWW
Rookie

Joined: Fri Oct 15, 2010 2:20 pm
Posts: 17
Location: Rochdale, UK
Post Re: how detect one thing....then another
Of course.
Code:
#pragma config(Sensor, S2,     Back,                sensorSONAR)
#pragma config(Sensor, S3,     Front,               sensorSONAR)
#pragma config(Sensor, S4,     Side,                sensorSONAR)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


void moveForward()
{
  nMotorEncoder(motorB) = 0;
  nMotorEncoderTarget(motorB) = 600;      // move car forward to bring in level with car it is parking behind.
  motor(motorB) = -45;
  wait1Msec(2500);
}

void park()
{
  nMotorEncoder[motorC] = 0;
  nMotorEncoderTarget[motorC]=180;
  motor(motorC)=75;                     //turn wheels right
  wait1Msec(1000);

  nMotorEncoder[motorB] = 0;
  nMotorEncoderTarget[motorB]=900;
  motor(motorB)=25;
  wait1Msec(2000);                     //move car back

  nMotorEncoder[motorC] = 0;
  nMotorEncoderTarget[motorC]=180;
  motor(motorC)=-75;                    //turn wheels left
  wait1Msec(1000);

  nMotorEncoder[motorC] = 0;
  nMotorEncoderTarget[motorC]=180;
  motor(motorC)=-75;                    //turn wheels left
  wait1Msec(1000);

  nMotorEncoder[motorB] = 0;
  nMotorEncoderTarget[motorB]=350;
  motor(motorB)=35;                     //move car back
  wait1Msec(2000);

  nMotorEncoder[motorC] = 0;
  nMotorEncoderTarget[motorC]=180;
  motor(motorC)=75;                     //turn wheels right
  wait1Msec(1000);

  nMotorEncoder[motorB] = 0;
  nMotorEncoderTarget[motorB]=120;
  motor(motorB)=-35;                    //move car forward
  wait1Msec(1000);

}

task main()
{
  int A;
  int B;
  int totalDistance;
  int distance = 10;
  nMotorEncoder(motorB) = 0;

  while(true)
  {
    motor(motorB) = -35;

  if(SensorValue(S4)>distance)
    {
      A = nMotorEncoder(motorB);
    }

  if(SensorValue(S4)<distance)
    {
      B = nMotorEncoder(motorB);
    }

  totalDistance = B - A;

  if(totalDistance>750)
    {
      moveForward();
      park();
      StopAllTasks();
    }
    else
    {
      motor(motorB) = 0;
    }
  }
}


Sat Nov 06, 2010 7:54 pm
Profile
Rookie

Joined: Fri Oct 15, 2010 2:20 pm
Posts: 17
Location: Rochdale, UK
Post Re: how detect one thing....then another
If you feel there are parts which could be made more efficient, it would be handy to know too :)

Thanks.


Sat Nov 06, 2010 7:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 21 posts ]  Go to page Previous  1, 2

Who is online

Users browsing this forum: No registered users and 1 guest


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.