To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1840
1839  |  1841
Subject: 
code
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 19 Apr 2001 09:33:47 GMT
Viewed: 
1256 times
  
Hi,I'm trying to run 2 infinate loops at the same time. Is this possible?
this is an example of what I'm trying to do. thanks


#include <unistd.h>
#include <dmotor.h>
#include <dsensor.h>
#include <conio.h>
#include <time.h>

pid_t fun_a;
pid_t fun_c;

int go = 0;
int move = 0;

int input_a(int argc, char *argv[])
{



}
int pivot(int argc, char *argv[])
{
while(1<10)
{
      while(ROTATION_1 != go)
  {
  if(ROTATION_1 < go)
  {
  motor_a_dir(fwd);
  }

  if(ROTATION_1 > go)
  {
  motor_a_dir(rev);
  }
  }

  motor_a_dir(brake);
}
}

int rail(int argc, char *argv[])
{
while(1<10)
{
      while(ROTATION_3 != move)
  {
  if(ROTATION_3 < move)
  {
  motor_c_dir(fwd);
  }

  if(ROTATION_3 > move)
  {
  motor_c_dir(rev);
  }
  }

  motor_c_dir(brake);
}
}

int main(int argc, char *argv[])
{
    ds_active(&SENSOR_3);
    ds_rotation_on(&SENSOR_3);
    ds_active(&SENSOR_1);
    ds_rotation_on(&SENSOR_1);

    ds_rotation_set(&SENSOR_3,0);
    ds_rotation_set(&SENSOR_1,0);
    msleep(100);

    fun_a = execi(&pivot,0,0,9,
                     DEFAULT_STACK_SIZE);

    fun_c = execi(&rail,0,0,10,
                     DEFAULT_STACK_SIZE);

    go = 15;
    msleep(400);
    go = -15;
    msleep(400);
    go = 0;
    msleep(400);

    move = 2;
    msleep(400);
    move = -2;
    msleep(400);
    move = 0;
msleep(400);

kill(fun_c);
kill(fun_a);

return 0;
}



Message has 1 Reply:
  Re: code
 
(...) [snip] (...) Can't see anything glaringly obvious, except you've used different priorities for your tasks. As they're infinite loops with no waiting, it's probably better to make their priorities equal. But the best way is probably to do all (...) (23 years ago, 19-Apr-01, to lugnet.robotics.rcx.legos)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR