Exemple #1
0
bool Flyer::charPoll( double dt ) {
    shadow_prop->setLoc(loc);
    
    // Moving in altitute axis
    h += v_h * dt;

    if( gravity != 0 ){
        v_h += gravity * dt;
    }

    if( h < 0 ) {
        land();
        return false;
    }
    // Where to draw
    draw_offset.y = h;

    loc += v * dt;
    
    if( !flyerPoll(dt)){
        return false;
    }
    
    // Landing (ex. blaster hit)
    if( gotToGoal() ){
        land();
        return false;
    }
        
    
    last_loc = loc;
    return true;
}
Exemple #2
0
literalt aig_prop_baset::lselect(literalt a, literalt b, literalt c)
{  // a?b:c = (a AND b) OR (/a AND c)
  if(a.is_true()) return b;
  if(a.is_false()) return c;
  if(b==c) return b;

  // This produces unnecessary clauses and variables
  // See convert_node for where this overhead is removed

  return lor(land(a, b), land(neg(a), c));
}
Exemple #3
0
literalt z3_propt::lselect(literalt a, literalt b, literalt c)
{
  // a?b:c = (a AND b) OR (/a AND c)
  if(a==const_literal(true)) return b;
  if(a==const_literal(false)) return c;
  if(b==c) return b;

  bvt bv;
  bv.reserve(2);
  bv.push_back(land(a, b));
  bv.push_back(land(lnot(a), c));
  return lor(bv);
}
Exemple #4
0
literalt aig_prop_baset::lxor(literalt a, literalt b)
{
  if(a.is_false()) return b;
  if(b.is_false()) return a;
  if(a.is_true()) return neg(b);
  if(b.is_true()) return neg(a);

  if(a==b) return const_literal(false);
  if(a==neg(b)) return const_literal(true);

  // This produces up to three nodes!
  // See convert_node for where this overhead is removed
  return lor(land(a, neg(b)), land(neg(a), b));
}
Exemple #5
0
literalt cnft::land(const bvt &bv)
{
  if(bv.size()==0) return const_literal(true);
  if(bv.size()==1) return bv[0];
  if(bv.size()==2) return land(bv[0], bv[1]);

  forall_literals(it, bv)
    if(it->is_false())
      return *it;

  if(is_all(bv, const_literal(true)))
    return const_literal(true);

  bvt new_bv;

  eliminate_duplicates(bv, new_bv);

  bvt lits(2);
  literalt literal=new_variable();
  lits[1]=neg(literal);

  forall_literals(it, new_bv)
  {
    lits[0]=pos(*it);
    lcnf(lits);
  }
Exemple #6
0
int main(int argc, char *argv[])
{
    double elapsedTime;
    double finalVelocity;
    int optionLetter;
    parameters.maxThrust = setDefaultDouble("MAX_THRUST", MAX_THRUST_DEFAULT);
    while((optionLetter = getopt(argc, argv, "t:")) != -1) {
        switch(optionLetter){

            case 't':
                parameters.maxThrust = strtod(optarg, NULL);
                break;

            default:
                assert(0);
        }
    }
    land(&finalVelocity, &elapsedTime);
    printf("final velocity: %.1f m/s\n", finalVelocity);
    if (fabs(finalVelocity) > 2.0)
        printf("you crashed!\n");
    else
        printf("safe landing\n");
    printf("  elapsed time: %.2f s\n", elapsedTime);
    return 0;
}
Exemple #7
0
int main(){
    int size = 6;
    int arr[size];
    int arr1[6]={1,2,3,4,5,6};
    int arr2[6]={-11,-12,-13,-14,-15,-16};
    int res[6];
    int i;
    fillRand3(arr, size);

    for (i = 0; i < size; i++)
        printf("%d\t", arr[i]);
    printf("\nrez = %d\n",checkRand3(arr, size));
    printf("sred = %.3f\n",meanValue(arr, size));
    printf("min = %d\n", minValue(arr, size));
    printf("index= %i\n", meanIndex(arr, size));
    printf("index = %d\n", minIndex(arr, size));
    printf("elem = %d\n", maxOccurance(arr, size));
    printf("res = %d\n", diff(arr1, arr2, res, size));
    sub(arr1, arr2, res, size);
    for (i=0;i<size;i++)
        printf("%d\t", res[i]);
    printf("\neq= %d\n", eq(arr1, arr2, size));
    land(arr1, arr2, res, size);
    for (i=0;i<size;i++)
        printf("%d\t", res[i]);
    return 0;
}
Exemple #8
0
void Emergency_exit (int signum)
{

	land();
	close_commands_socket();
	exit(signum);
}
	void ATCommandHandler::move() {
		FlightInput fi;

		int i = 0;

		/*while (i < 10) {
			atc.move(-0.4, 0, 0, 0);
			i++;
		}*/

		while (i < 200) {
			fi.listen();

			std::cout << "Sending move on ATCommands" << std::endl;
			atc.move(fi.pitch, fi.roll, fi.yaw, fi.throttle);

			i++;
		}


		land();

		std::cin.ignore();

	}
void VisualBird::drive()
{

  //update flight status
  eye->updateFlightStatus();
  
  ROS_DEBUG("%.3f %.3f %.3f", eye->getTargetVel().x, eye->getTargetVel().y, eye->getTargetVel().z);

  //check whether arrived at start point
  checkStartPoint();

  //check landing condition
  land();

  if (norm(vectorMinus(eye->getCurrentPoint(), shiftOrigin)) < 150 && !landing && !circleStart) 
    {
      ROS_INFO("Start virtual target");
      targetCircleCenter = eye->getCurrentPoint();
      targetCircleCenter.y += radius + 50;
      currTheta = 0;
      circleStart = true;
    }

  if (circleStart && !landing)
    {
      targetPoint.x = targetCircleCenter.x + radius * sin(currTheta);
      targetPoint.y = targetCircleCenter.y - radius * cos(currTheta);
      targetPosLog.push_back(targetPoint);
      targetVel.x = radius * omega * cos(currTheta)/1000.;
      targetVel.y = radius * omega * sin(currTheta)/1000.;
      targetVel.z = 0;
      targetVelLog.push_back(targetVel);
      targetAcc.x = - radius * omega * omega * sin(currTheta)/1000.;
      targetAcc.y = radius * omega * omega * cos(currTheta)/1000.;
      targetAcc.z = 0;
      targetAccLog.push_back(targetAcc);
      currTheta += omega/freq;
      //ROS_INFO("Virtual target at %.3f %.3f %.3f", targetPoint.x, targetPoint.y, targetPoint.z);
    }

  if (!hover)
    nav->updatePVA(scalarProduct(0.001,vectorMinus(eye->getCurrentPoint(),shiftOrigin)),scalarProduct(0.001,vectorMinus(targetPoint,shiftOrigin)),scalarProduct(0.001,eye->getCurrentVel()),targetVel,targetAcc);

  invokeController();
  visualTarget.push_back(targetPoint);   
  
  geometry_msgs::PointStamped msg;
  msg.header.frame_id = "world";
  msg.point.x = targetPoint.x/1000;
  msg.point.y = targetPoint.y/1000;
  msg.point.z = targetPoint.z/1000;
  msg.header.stamp = ros::Time::now();
  target_pub.publish(msg);

  double secs =ros::Time::now().toSec();
  timeLog.push_back(secs); 
  
  counter ++;
}
Exemple #11
0
::Ice::DispatchStatus
jderobot::Quadrotor::___land(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    __inS.is()->skipEmptyEncaps();
    land(__current);
    return ::Ice::DispatchOK;
}
Exemple #12
0
int main( )
{
	struct airport a ;
	int i, pri, curtime, endtime ;
	double expectarrive, expectdepart ;
	struct plane temp ;

  system ( "cls" ) ;

    initairport ( &a );

	start ( &endtime, &expectarrive, &expectdepart ) ;

	for ( curtime = 1 ; curtime <= endtime ; curtime++ )
	{
		pri = randomnumber ( expectarrive ) ;

		for ( i = 1 ; i <= pri ; i++ )
		{
			newplane ( &a, curtime, ARRIVE ) ;
			if ( apfull ( a, 'l' ) )
				 refuse ( &a, ARRIVE ) ;
			else
				apaddqueue( &a, 'l' ) ;
		}

		pri = randomnumber ( expectdepart ) ;
		for ( i = 1 ; i <= pri ; i++ )
		{
			newplane ( &a, curtime, DEPART ) ;
			if ( apfull ( a, 't' ) )
			   refuse ( &a, DEPART ) ;
			else
			   apaddqueue ( &a, 't' ) ;
		}

		if (  ! ( apempty ( a, 'l' ) ) )
		{
			temp = apdelqueue ( &a, 'l' ) ;
			land ( &a, temp, curtime ) ;
		}
		else
		{
			if ( ! ( apempty ( a, 't' ) ) )
			{
				temp = apdelqueue ( &a, 't' ) ;
				fly ( &a, temp, curtime ) ;
			}
			else
				idle ( &a, curtime ) ;
		}
	}

	conclude ( &a, endtime ) ;

    return 0 ;
}
void ArdroneInterface::readNav(const ardrone_autonomy::Navdata::ConstPtr & Nav)
{
    nav_data_ = *Nav;
    if (nav_data_.batteryPercent < emergency_battery_level_ && !emergency_)
    {
        emergency_ = true;
        std::cout << "Emergency Landing" << std::endl;
        land();
    }
}
Exemple #14
0
void SonarBird::drive()
{
  sonar->updateFlightStatus();

  land();

  invokeController();
    
  counter ++;
}
	void ATCommandHandler::run() {
		std::cout << std::endl << "AtCommand handler started and working" << std::endl;

		navDataDemoMode();
		fTrim();
		takeOff();
		watchdog();
		move();
		land();
	}
void ArdroneInterface::hoveringTimeOut(){
    ros::Time time0 = ros::Time::now();
    while (!checkHovering())
    {
        if(ros::Time::now() > time0 + ros::Duration(take_off_time_))
        {
            land ();
            break;
        }
    }
}
Exemple #17
0
literalt aig_prop_baset::lor(const bvt &bv)
{
  literalt literal=const_literal(true);

  // Introduces N-1 extra nodes for N bits
  // See convert_node for where this overhead is removed
  forall_literals(it, bv)
    literal=land(neg(*it), literal);

  return neg(literal);
}
Exemple #18
0
literalt z3_propt::land(literalt a, literalt b)
{
  if(a==const_literal(true)) return b;
  if(b==const_literal(true)) return a;
  if(a==const_literal(false)) return const_literal(false);
  if(b==const_literal(false)) return const_literal(false);
  if(a==b) return a;

  literalt o=new_variable();
  land(a, b, o);
  return o;
}
Exemple #19
0
void *thread_func(void *arg) {
    struct plane *p = arg;
    while (p->alive) {
        wait_for_perm(p, 0);
        land(p);
        usleep(10000);
        wait_for_perm(p, 1);
        start(p);
        usleep(10000);
    }
    return NULL;
}
void VisualBird::drive()
{

    //update flight status
    eye->updateFlightStatus();

    ROS_DEBUG("%.3f %.3f %.3f", eye->getTargetVel().x, eye->getTargetVel().y, eye->getTargetVel().z);

    nav->updatePVA(scalarProduct(0.001,vectorMinus(eye->getCurrentPoint(),shiftOrigin)),eye->getTargetPos(),scalarProduct(0.001,eye->getCurrentVel()),eye->getTargetVel(),0);


    //ROS_DEBUG("%.3f %.3f %.3f",vectorMinus(eye->getCurrentPoint(),shiftOrigin).x,vectorMinus(eye->getCurrentPoint(),shiftOrigin).y,vectorMinus(eye->getCurrentPoint(),shiftOrigin).z);
    //check whether arrived at start point
    //checkStartPoint();

    //hover to points
    //hoverFlight();

    //check landing condition
    land();

    //check out range condition
    //safeOutRange();

    //ROS_INFO("DISTANCE %f",norm(vectorMinus(eye->getCurrentPoint(), shiftOrigin)));
    //ROS_INFO("Target %f %f %f", targetPoint.x, targetPoint.y, targetPoint.z);
    if (norm(vectorMinus(eye->getCurrentPoint(), shiftOrigin)) < 150 && !landing && visual_feedback && !start_visual)
    {
        ROS_INFO("VISUAL GUIDANCE Initiated");
        start_visual = true;
        double secs =ros::Time::now().toSec();
        timeTable.push_back(secs);
    }

    if (start_visual && !visualBuffer.empty() && !landing && !hover)
    {
        ROS_INFO("VISUAL GUIDANCE In Effect");
        double secs =ros::Time::now().toSec();
        timeTable.push_back(secs);
        switchHover();
        //Notice that here switchHover is not used because we want to have z stabiled with integral feedback
    }

    //call hover controller or path controller according to (bool hover)
    invokeController();
    visualTarget.push_back(targetPoint);
    double secs =ros::Time::now().toSec();
    timeLog.push_back(secs);

    counter ++;
}
Exemple #21
0
ml_art *ml_read_land_art(int land_id)
{
    assert(ml_inited);

    assert(land_id >= 0 && land_id < art_idx->entry_count);

    int offset = art_idx->entries[land_id].offset;
    int length = art_idx->entries[land_id].length;

    ml_art *art = NULL;
    land(art_idx->entries[land_id].offset, art_idx->entries[land_id].length, &art, true);

    return art;
}
Exemple #22
0
void FlightControl::flightPlan() {
	static unsigned long start = 0;
	static bool isFirstRun = true;
	static uint8_t step = 0;

	if (!isExecutingFlightPlan)
		return;

	if (isFirstRun) {
		step = 0;
		start = millis();
		isFirstRun = false;
	}

	unsigned long elapsedTime = millis() - start;

	switch(step) {
	case 0:
		if (elapsedTime <  6000)
			break;
		turn(180);
		step++;
		break;
//	case 1:
//		if (elapsedTime <  12000)
//			break;
//		turn(90);
//		step++;
//		break;
//	case 2:
//		if (elapsedTime <  18000)
//			break;
//		turn(90);
//		step++;
//		break;
	case 1:
		if (elapsedTime < 12000)
			break;
		land();
		step++;
		break;
	case 2:
		step = 0;
		start = 0;
		isFirstRun = true;
		isExecutingFlightPlan = false;
		break;
	}
}
Exemple #23
0
CharmListZR stringToInt(PairingGroup & group, string strID, int z, int l)
{
    /* 1. hash string. */
    CharmListZR zrlist; // = new CharmListZR;
    ZR intval;
    Big mask( pow(Big(2), l) - 1 );
    ZR id = group.hashListToZR(strID);

    /* 2. cut up result into zz pieces of ll size */
    for(int i = 0; i < z; i++) {
        intval = land(id, mask);
        zrlist.append(intval);
        id = id >> l; // shift to the right by ll bits
    }
    return zrlist;
}
Exemple #24
0
int main ()
{
   // ----- Required Code -------------------------
   //Create new control thread
   pthread_t ControlThread;
   if(pthread_create(&ControlThread, NULL, DroneControl, NULL)) {
      fprintf(stderr, "Error creating thread\n");
      return 1;
   }
   // ---------------------------------------------


   // The Following is an example of a basic flight
   // Currently speeds have to be +/- 0.05,0.1,0.2 or 0.5
   
   takeOff();     //take off
   sleep(5);      //Allows time for takeoff and settle before commands come in

   rotateRight(0.5); //Rotate Right at 50% speed
   sleep(2);         //For 2 Seconds

   hover();         //Hover in place
   sleep(3);        //For 3 Seconds

   land();          //Land

   // End Basic Flight Plan


   // ---- Recommended Code ------------------------

   terminateThread();   //Terminate Control Thread (should be called ONLY
                        //after landing for the last time)

   // Stops Program terminating early by waiting for control thread 
   // to terminate properly.
   if(pthread_join(ControlThread, NULL)) {
      return 1;
   }
   //---------------------------------------------

   return 0;
}
Exemple #25
0
void *run_airplane(void *parameters)
{
    thread_args_t *args;
    int airplane_id;

    args = (thread_args_t *) parameters;
    airplane_id = args->airplane_id;

    while(1) {
        request_landing(airplane_id);
        land(airplane_id);
        stop(airplane_id);
        request_start(airplane_id);
        start(airplane_id);
        fly(airplane_id);
    }

    return NULL;
}
Exemple #26
0
int main(int argc, char *argv[])
{
    double elapsedTime;
    double finalVelocity;
    int optionLetter;
    options.maxThrust = setDefaultDouble("MAX_THRUST", MAX_THRUST_DEFAULT);
    options.initialVelocity = setDefaultDouble("INITIAL_VELOCITY", INITIAL_VELOCITY_DEFAULT);
    options.initialFuel = setDefaultDouble("INITIAL_FUEL", INITIAL_FUEL_DEFAULT);
    options.gravity = setDefaultDouble("GRAVITY", GRAVITY_DEFAULT);
    options.initialHeight = setDefaultDouble("INITIAL_HEIGHT", INITIAL_HEIGHT_DEFAULT);

    while((optionLetter = getopt(argc, argv, "t:,v:,f:,g:,h:")) != -1) {
        switch(optionLetter){

            case 't':
                options.maxThrust = strtod(optarg, NULL);
                break;
            case 'v':
                options.initialVelocity = strtod(optarg, NULL);
                break;
            case 'f':
                options.initialFuel = strtod(optarg, NULL);
                break;
            case 'g':
                options.gravity = strtod(optarg, NULL);
                break;
            case 'h':
                options.initialHeight = strtod(optarg, NULL);
                break; 

            default:
                assert(0);
        }
    }
    land(&finalVelocity, &elapsedTime);
    printf("final velocity: %.1f m/s\n", finalVelocity);
    if (fabs(finalVelocity) > 2.0)
        printf("you crashed!\n");
    else
        printf("safe landing\n");
    printf("  elapsed time: %.2f s\n", elapsedTime);
    return 0;
}
Exemple #27
0
int main(){
    int size = 8;
    int arr[size];
    int arr1[8]={1,2,3,4,5,6,7,8};
    int arr2[8]={11,12,13,14,15,16,17,18};
    int res[8];

    int index;
    int i;
    srand(time(NULL));
        fillRand1(arr, size);
    for (i=0;i<size;i++)
        printf("%d\t", arr[i]);
        checkRand1(arr, size);
    printf("\n CheckRand = %d\n",checkRand1(arr, size));
        meanValue(arr, size);
    printf("Average value = %.3f\n",meanValue(arr, size));
        minValue(arr, size);
    printf("Min value = %d\n", minValue(arr, size));
        meanIndex(arr, size);
    printf("Index values near the average value = %d\n", meanIndex(arr, size));
        minIndex(arr, size);
    printf("Min index = %i \n ", minIndex(arr,size));
        maxOccurance(arr, size);
    printf("Value, which is most common in the array = %d\n", maxOccurance(arr, size));
        diff(arr1, arr2, res, size);
    printf("Diff = %d\n", diff(arr1, arr2, res, size));
       mult(arr1,arr2,res,size);
    printf("Mult\n");
    for (i=0;i<size;i++)
        printf("%d\t", res[i]);
        printf("\n");
        lt(arr1,arr2,size);
    printf("Less than = %d\n", lt(arr1, arr2, size));
        land(arr1,arr2,res,size);
    for (i=0;i<size;i++)
        printf("%d\t", res[i]);

    return 0;

}
Exemple #28
0
 vector<int> numIslands2(int m, int n, vector<pair<int, int>>& positions) {
     
     vector<int> res;
     
     vector<int> parent(m*n,0);
     vector<int> size(m*n,1);
     vector<bool> land(m*n,0);
     
     for(int i = 0; i < parent.size(); ++i) parent[i] = i;
     
     int total = 0;
     
     for(auto pos: positions) {
         
         ++total;
         
         int index = pos.first*n + pos.second;
         
         land[index] = true;
         
         if(pos.second && land[index-1]) {
             Union(index, index-1, parent, size, total);
         }
         
         if(pos.second < n - 1 && land[index+1]){
             Union(index, index+1, parent, size, total);
         }
         
         if(pos.first && land[index-n]) {
             Union(index, index-n, parent, size, total);
         }
         
         if(pos.first < m - 1 && land[index+n]){
             Union(index, index+n, parent, size, total);
         }
         
         res.push_back(total);
     }
     
     return res;
 }
Exemple #29
0
LPCTSTR CGrayMapBlockState::GetTileName( DWORD dwID )	// static
{
	ADDTOCALLSTACK("CGrayMapBlockState::GetTileName");
	if ( dwID == 0 )
	{
		return( "<null>" );
	}
	TCHAR * pStr = Str_GetTemp();
	if ( dwID < TERRAIN_QTY )
	{
		CGrayTerrainInfo land( static_cast<WORD>(dwID) );
		strcpy( pStr, land.m_name );
	}
	else
	{
		dwID -= TERRAIN_QTY;
		CGrayItemInfo item(static_cast<ITEMID_TYPE>(dwID));
		strcpy( pStr, item.m_name );
	}
	return( pStr );
}
Exemple #30
0
literalt z3_propt::land(const bvt &bv)
{
  if(bv.size()==0) return const_literal(true);
  if(bv.size()==1) return bv[0];
  if(bv.size()==2) return land(bv[0], bv[1]);

  for(unsigned i=0; i<bv.size(); i++)
    if(bv[i]==const_literal(false))
      return const_literal(false);

  if(is_all(bv, const_literal(true)))
    return const_literal(true);

  bvt new_bv;

  eliminate_duplicates(bv, new_bv);

  literalt literal=new_variable();

  for(unsigned int i=0; i<new_bv.size(); ++i)
  {
    bvt lits;
    lits.reserve(2);
    lits.push_back(pos(new_bv[i]));
    lits.push_back(neg(literal));
    lcnf(lits);
  }

  bvt lits;
  lits.reserve(new_bv.size()+1);

  for(unsigned int i=0; i<new_bv.size(); ++i)
    lits.push_back(neg(new_bv[i]));

  lits.push_back(pos(literal));
  lcnf(lits);

  return literal;
}