Beispiel #1
0
task autonomous()
{
  // .....................................................................................
  // Insert user code here.
  // .....................................................................................
	while(true)
	{
			if(SensorValue[leftBackBumper] == 1)
			{
					currentX = 12;
					currentY= 18;
					goTo(24,48);
					pickup();
					goTo(12, 18);
					break;
			}
			else if (SensorValue[rightBackBumper] == 1)
			{
					currentX = 36;
					currentY= 18;
					goTo(24,48);
					pickup();
					goTo(36, 18);
					break;
			}
	}
}
Beispiel #2
0
_WCRTLINK extern void _makepath( char *path, const char *volume,
                const char *dir, const char *fname, const char *ext )
{
    char first_pc = NULLCHAR;

    if( volume != NULL ) {
        if( *volume != NULLCHAR ) {
            do {
                *path++ = *volume++;
            } while( *volume != NULLCHAR );
            if( path[-1] != DRV_SEP ) {
                *path++ = DRV_SEP;
            }
        }
    }
    *path = NULLCHAR;
    if( dir != NULL ) {
        if( *dir != NULLCHAR ) {
            do {
                *path++ = pickup( *dir++, &first_pc );
            } while( *dir != NULLCHAR );
            /* if no path separator was specified then pick a default */
            if( first_pc == NULLCHAR )
                first_pc = DIR_SEP;
            /* if dir did not end in path sep then put in a provisional one */
            if( path[-1] == first_pc ) {
                path--;
            } else {
                *path = first_pc;
            }
        }
    }
    /* if no path separator was specified thus far then pick a default */
    if( first_pc == NULLCHAR )
        first_pc = DIR_SEP;
    if( fname != NULL ) {
        if( ( pickup( *fname, &first_pc ) != first_pc ) && ( *path == first_pc ) )
            path++;
        while( *fname != NULLCHAR ) {
            *path++ = pickup( *fname++, &first_pc );
        }
    } else {
        if( *path == first_pc ) {
            path++;
        }
    }
    if( ext != NULL ) {
        if( *ext != NULLCHAR ) {
            if( *ext != EXT_SEP )
                *path++ = EXT_SEP;
            while( *ext != NULLCHAR ) {
                *path++ = *ext++;
            }
        }
    }
    *path = NULLCHAR;
}
bool Level15::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event)
{
    CCPoint touchLocation = touch->getLocationInView();
    touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
    if (spSun->boundingBox().containsPoint(touchLocation)) {
        spSun->stopAllActions();
        SimpleAudioEngine::sharedEngine()->stopAllEffects();
        SimpleAudioEngine::sharedEngine()->playEffect("sun.wav");

        spSun->runAction(CCRotateBy::create(1.0f, 360.f));
        return false;
    }
    
    if (spBucket->boundingBox().containsPoint(touchLocation)) {
        spBucket->stopAllActions();
        //        spFeather->runAction(CCRotateBy::create(1.0f, 360.f));
        //        this->unscheduleAllSelectors();
        //        pickup();
        //        this->setTouchEnabled(false);
        SimpleAudioEngine::sharedEngine()->stopAllEffects();
        SimpleAudioEngine::sharedEngine()->playEffect("bucket.wav");
        return false;
    }
    
    if (spRock->boundingBox().containsPoint(touchLocation)) {
        spRock->stopAllActions();
        spRock->setPosition(ccp(getXForLession1(410), G_SHEIGHT/2));
        SimpleAudioEngine::sharedEngine()->stopAllEffects();
        SimpleAudioEngine::sharedEngine()->playEffect("rock.wav");
        spRockShadow->setVisible(false);
        spRock->runAction(CCSequence::create(CCJumpBy::create(1.f, ccp(0, 0), 150*G_SCALEY, 1),CCCallFunc::create(this, callfunc_selector(Level15::showShadow)), NULL));
        return false;
    }
    
    
    if (star1->boundingBox().containsPoint(touchLocation)){
        shadowStar1->setVisible(false);
        this->setTouchEnabled(false);
        bStar1 = true;
        pickup(star1);
        return false;
    }
    if (star2->boundingBox().containsPoint(touchLocation)) {
        shadowStar2->setVisible(false);
        this->setTouchEnabled(false);
        bStar2 = true;
        pickup(star2);
        return false;
    }
    if (spHitBox->boundingBox().containsPoint(touchLocation)) {
        SimpleAudioEngine::sharedEngine()->stopAllEffects();
        SimpleAudioEngine::sharedEngine()->playEffect("water.wav");
    }
    return false;
}
Beispiel #4
0
void
World::createPickup( sf::Vector2f position, Pickup::Type type ) {
    std::unique_ptr<Pickup> pickup( new Pickup( type, mTextures ) );
    pickup->setPosition( position );
    pickup->SetVelocity( 0.0f, 1.0f );
    mSceneLayers[UpperAir]->AttachChild( std::move( pickup ) );
}
Beispiel #5
0
	bool pickup_callback(std_srvs::Empty::Request &request,
			std_srvs::Empty::Response &response) {
		if (pickup()) {
			return false;
		}
		return true;
	}
Beispiel #6
0
//-------------------------------------------------------****MAIN FUNCTION ****------------------------------------------------
int main()
{
	
	init_devices();
	lcd_set_4bit();
	lcd_init();
    lcd_cursor(1,1);
	lcd_string("START");
	_delay_ms(rand());
//--*** GRIPPER INITAL POSITION ***---
	S2 = 0x73;
	cli();
	timer0_init();
	TIMSK |= (1 << OCIE0) | (1 << TOIE0); // timer 0 compare match and overflow interrupt enable 
	sei();
	pickup();
	
	while(1)
	{
	if( bot_id_set == 1)
	{	
	
		init_devices2();
		init_grid();
		dispersion();
		localize();
		region_division();
		break;
	}
	
 }
 }
Beispiel #7
0
void World::CreatePickup( sf::Vector2f position, Pickup::Type type )
{
	b2Body * body = pImpl->CreateBody( b2_dynamicBody, position, sf::Vector2f( 1.f, 1.f ) );

	std::unique_ptr<Pickup> pickup( new Pickup( type, pImpl->mTextures, body ) );
	pickup->setPosition( position );
	pickup->SetVelocity( 0.f, 1.f );
	pImpl->mSceneLayers[ Impl::Layer::UpperAir ]->AttachChild( std::move( pickup ) );
}
Beispiel #8
0
void Aircraft::createPickup(SceneNode& node, const TextureHolder& textures) const
{
	auto type = static_cast<Pickup::Type>(randomInt(Pickup::TypeCount));

	std::unique_ptr<Pickup> pickup(new Pickup(type, textures));
	pickup->setPosition(getWorldPosition());
	pickup->setVelocity(0.f, 1.f);
	node.attachChild(std::move(pickup));
}
Beispiel #9
0
  void callback(const tum_os::Clusters::ConstPtr& c)
  {
    clusters_ = c->clusters;

    arm_navigation_msgs::GetPlanningScene

    createGraspableObject(clusters_[0]);
    pickup();
  };
Beispiel #10
0
jboolean nhjni_run() {
  windowprocs = _nhjni_proxy_procs;
  _nhjni_proxy_init();
  int fd = create_levelfile(0, (char *)0);
  if (fd < 0) {
    raw_print("Cannot create lock file");
  } else {
    hackpid = 1;
    write(fd, (genericptr_t) &hackpid, sizeof(hackpid));
    close(fd);
  }
  
  iflags.news = TRUE;
  int argc=1;
  char *argv[]={"nethack",NULL};
  
  initoptions();
  init_nhwindows(&argc,argv);
  dlb_init();
  vision_init();
  display_gamewindows();
  
  if ((fd = restore_saved_game()) >= 0) {
    const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);

    pline("Restoring save file...");
    mark_synch();	/* flush output */
    if(!dorecover(fd))
      goto not_recovered;

    check_special_room(FALSE);
    //wd_message();

    if (discover || wizard) {
      if(yn("Do you want to keep the save file?") == 'n')
          (void) delete_savefile();
      else {
          (void) chmod(fq_save,FCMASK); /* back to readable */
          compress(fq_save);
      }
    }
    flags.move = 0;
  } else {
not_recovered:
    player_selection();
    newgame();
    flags.move = 0;
    set_wear();
    (void) pickup(1);
  }

  moveloop();
  
  return JNI_TRUE;
}
Beispiel #11
0
void *philosopher(void *v)
{
  Phil_struct *ps;
  long st;
  long t;

  ps = (Phil_struct *) v;

  while(1) {

    /* First the philosopher thinks for a random number of seconds */

    st = (random()%ps->ms) + 1;
    printf("%3d Philosopher %d thinking for %d second%s\n", 
                time(0)-ps->t0, ps->id, st, (st == 1) ? "" : "s");
    fflush(stdout);
    sleep(st);

    /* Now, the philosopher wakes up and wants to eat.  He calls pickup
       to pick up the chopsticks */

    printf("%3d Philosopher %d no longer thinking -- calling pickup()\n", 
            time(0)-ps->t0, ps->id);
    fflush(stdout);
    t = time(0);
    pthread_mutex_lock(ps->blockmon);
    ps->blockstarting[ps->id] = t;
    pthread_mutex_unlock(ps->blockmon);

    pickup(ps);

    pthread_mutex_lock(ps->blockmon);
    ps->blocktime[ps->id] += (time(0) - t);
    ps->blockstarting[ps->id] = -1;
    pthread_mutex_unlock(ps->blockmon);

    /* When pickup returns, the philosopher can eat for a random number of
       seconds */

    st = (random()%ps->ms) + 1;
    printf("%3d Philosopher %d eating for %d second%s\n", 
                time(0)-ps->t0, ps->id, st, (st == 1) ? "" : "s");
    fflush(stdout);
    sleep(st);

    /* Finally, the philosopher is done eating, and calls putdown to
       put down the chopsticks */

    printf("%3d Philosopher %d no longer eating -- calling putdown()\n", 
            time(0)-ps->t0, ps->id);
    fflush(stdout);
    putdown(ps);
  }
}
Beispiel #12
0
int main()
{
	int i=0;
	init_devices();
	lcd_set_4bit();
	lcd_init();
	color_sensor_scaling();
	/*
	//variable 'i' scales at 13,14 for sharp sensor for velocitty 240 240
	//u turn 1600ms at 200,200 velocity
	velocity(200,200);
	left();
	_delay_ms(1600);
	stop();
	while(1);
	
	threshold=6000;
	
	right();
	while(ADC_Conversion(11)<65)
	{
		i++;
		lcd_print(1,11,i,3);
	}
	stop();
	lcd_print(2,11,scan(),1);
	stop();
	while(1);
	*/
	setIndicatorAndColor();
	threshold=6000;
	ct = 0; adj = 2;
	//lcd("Begin");
	while (sorted<total)
	{
		canDrop();
		//buzzer_on();
		//_delay_ms(500);
		//buzzer_off();
		if (visitedCount == 3)
			predict();
		if (sorted == total)
			break;
		pickup();
		traverseToSort(ct, ct % 2 + 4);
		sortCheck();
	}
	for (i = 0; i<4; i++);
		//..printf("%d %d\n", term[i][0], term[i][1]);
	//..printf("Sort 0=%dSort 1=%d\nArm 0=%dArm 1=%d\n", sort[0], sort[1], arm[0], arm[1]);
	//..printf("Cost=%d\nSORTED!!!!!\n", cost + 7);
	//getch();
	return 0;
}
Beispiel #13
0
	void pick_and_place() {

		//Sets the kinects tilt angle
		set_kinect_ptu("kurtana_pitch_joint", 0.85);

		if (move_arm_out_of_the_way()) {

			if (move_arm_out_of_the_way()) {
				return;
			}

		}

		if (pickup()) {

			if (pickup()) {
				//don't place if pickup failed
				return;
			}
		}

		if (place()) {

			if (place()) {

				return;
			}
			place();
		}

		if (move_arm_out_of_the_way()) {

			if (move_arm_out_of_the_way()) {
				return;
			}

		}

		return;

	}
Beispiel #14
0
void checkitems(void) {
  if (edit::mode()) return;
  loopv(ents) {
    entity &e = ents[i];
    if (e.type==NOTUSED) continue;
    if (!ents[i].spawned && e.type!=TELEPORT && e.type!=JUMPPAD) continue;
    const vec3f v(float(e.x), float(e.y), player1->eyeheight);
    const float dist = distance(player1->o, v);
    if (dist<(e.type==TELEPORT ? 4 : 2.5))
      pickup(i, player1);
  }
}
Beispiel #15
0
bool PickupItem::collide(GameObject *otherObject)
{
   if(mIsVisible && !isGhost() && otherObject->getObjectTypeMask() & ShipType)
   {  
      if(pickup((Ship *) otherObject))
      {
         setMaskBits(PickupMask);
         mRepopTimer.reset(getRepopDelay());
         mIsVisible = false;
      }
   }
   return false;
}
Beispiel #16
0
void *philosophy(void *arg)
{
	int me = (int)arg;
	
	while(1)
	{
		printf("%d is thinking...\n", me);
		usleep(rand()%10);
		pickup(me);
		printf("%d is eating...\n", me);
		usleep(rand()%10);
		drop(me);
	}
}
void Level15::onTimer()
{
    nCnt++;
    if(bStar1 && bStar2){
        lbSecond->runAction(CCSequence::create(CCDelayTime::create(1.0f),CCCallFunc::create(this, callfunc_selector(Level15::playEffect2)), CCFadeIn::create(1.0f), NULL));
//        this->setTouchEnabled(false);
        unscheduleAllSelectors();
        return;
    }
    if(!g_bAuto) return;
    
    if (!bStar1  && nCnt >= 100) {
        nCnt = 0;
        shadowStar1->setVisible(false);
        bStar1 = true;
        pickup(star1);
    }
    if (!bStar2  && nCnt >= 100) {
        nCnt = 0;
        bStar2 = true;
        shadowStar2->setVisible(false);
        pickup(star2);
    }
}
Beispiel #18
0
static void *philosopher(void *_who)
{
    unsigned int *who = (unsigned int *)_who;

    /* For simplicity, all philosophers eat for the same amount of time
       and think for a time that is simply related to their position at
       the table. The parameter who identifies the philosopher: 0,1,2,.. */
    for (;;) {
        pth_sleep((*who) + 1);
        pickup((*who));
        pth_sleep(1);
        putdown((*who));
    }
    return NULL;
}
bool Level19::ccTouchBegan(cocos2d::CCTouch *touch, cocos2d::CCEvent *event)
{
    CCPoint touchLocation = touch->getLocationInView();
    touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
    for (int i = 0; i < 5; i++) {
        if(spThing[i]->boundingBox().containsPoint(touchLocation)){
//            pickup(spThing[i]);
            this->setTouchEnabled(false);
            shadowThing[i]->setScale(1.5*G_SCALEY);
            pickup(spThing[i], i);
            return true;
        }
    }
    
    return false;
}
Beispiel #20
0
void float_down()
{
  trap_t *trap;
  message("You float gently to the ground.");
  trap = trap_at(you.ux, you.uy);
  if (trap)
    switch(get_trap_type(trap->trap_info)) {
    case PIERC:
      break;
    case TRAPDOOR:
      if (!xdnstair || you.ustuck) break;
      /* fall into next case */
    default:
      do_trap(trap);
    }
  pickup(true);
}
   main()
  {
   int ch,a,n,i;
   printf("\nDINING PHILOSOPHERS PROBLEM :");
   for(i=0;i<5;i++)
    {
    state[i]='t';
    self[i]='s';
    spoon[i]='s';
     }
    printf("\nInitial state of each philosopher :");
    printf("\nPHIL NO:\tTHINK\tSTATUS\t\tSPOON");
                 for(i=0;i<5;i++)
    printf("\n%d\t\t%c\t\t%c\t\t%c",i+1,state[i],self[i],spoon[i]);
    printf("\n1.EXIT\n2.HUNGRY\n3.THINKING");
    printf("\nEnter your choice :");
    scanf("%d",&ch);
    while(ch!=1)
     {
    switch(ch)


   {
 case 1:
 return 0;
 case 2:
 printf("\nEnter which philosopher is hungry :");
scanf("%d",&n);
 pickup(n-1);
 break;
 case 3:
 printf("\nEnter which philosopher is thinking :");
 scanf("%d",&n);
 putdown(n-1);
 break;
 }
 printf("State of each philosopher :");
 printf("\nPHIL NO:\tTHINK/EAT\tSTATUS\t\tSPOON");
 for(i=0;i<5;i++)
printf("\n%d\t\t%c\t\t%c\t\t%c",i+1,state[i],self[i],spoon[i]);
printf("\n1.EXIT\n2.HUNGRY\n3.THINKING");
 printf("\nEnter your choice :");
 scanf("%d",&ch);
 }
 }
Beispiel #22
0
void smoker(int * id){//i am using one big fucntion for all three smokers
  //you could have used seperate functions

  printf("smoker %d here\n",*id);
  while (1){
    /*
    pthread_mutex_lock(&table); 
    switch(*id){
    case 0:
      while(t != 1){
	pthread_cond_wait(&self, &table);
      }
      printf("smoker tobacco  smoking\n");
      t=0;
      agnt=1;
      break;
    case 1:
      while(m != 1){
	pthread_cond_wait(&self, &table);
      }
      
      m=0;
      agnt=1;
      printf("smoker matches  smoking\n");
      break;
    case 2:
      while(p != 1){
	pthread_cond_wait(&self, &table);
      }
      p=0;
      agnt=1;
      printf("smoker paper  smoking\n");
      break;
    }
    pthread_cond_broadcast(&self);
    pthread_mutex_unlock(&table);
    */
    pickup(*id);
    sleep(1);//smoke
  }
  exit(0);
}
Beispiel #23
0
Game::Game(string path, Highscores * highscores) : Screen(path)
{
	Game::highscores = highscores;
	Game::keyboard = keyboard;
	Map::init("Maps/map1.mta");
	msurf_MapSurface = Map::createMapSurface("map.png");
	msurf_Screen = 0;
	mui_TurnCounter = 0;

	player = shared_ptr<Player>(new Player("player_walk1.png", 1, 18, 32, true));
	m_Entities.push_front(player);
	for (auto i = 0; i < 1; i++)
	{
		shared_ptr<Pickup> pickup(new Pickup(32, true, TOME));
		shared_ptr<Enemy> enemy(new Enemy("enemy.png", 32, true));
		m_Entities.push_front(pickup);
		m_Entities.push_front(enemy);
		m_Enemies.push_back(enemy);
	}
}
Beispiel #24
0
void block_detect()
{
			stop();	
			ssss =SREG;
			cli();
			timer0_init();
			TIMSK |= (1 << OCIE0) | (1 << TOIE0); // timer 0 compare match and overflow interrupt enable 
			sei();
			SREG = ssss;
			drop_down();
			_delay_ms(2000);
			pickup();
			//drop_down();
			
			ssss =SREG;
			cli();
			timer2_init();
			sei();
			ssss = SREG;
			forward();	
}
int Natives::CreateDynamicPickup(int modelid, int type, float x, float y, float z, int worldid, int interiorid, int playerid, float streamdistance)
{
	if (core->getData()->getMaxItems(STREAMER_TYPE_PICKUP) == core->getData()->pickups.size())
	{
		return 0;
	}
	int pickupID = Item::Pickup::identifier.get();
	Item::SharedPickup pickup(new Item::Pickup);
	pickup->pickupID = pickupID;
	pickup->worldID = 0;
	pickup->modelID = modelid;
	pickup->type = type;
	pickup->position = Eigen::Vector3f(x, y, z);
	Utility::addToContainer(pickup->worlds, worldid);
	Utility::addToContainer(pickup->interiors, interiorid);
	Utility::addToContainer(pickup->players, playerid);
	pickup->streamDistance = streamdistance * streamdistance;
	core->getGrid()->addPickup(pickup);
	core->getData()->pickups.insert(std::make_pair(pickupID, pickup));
	return pickupID;
}
Beispiel #26
0
int main()
{
	int i;
	setIndicatorAndColor();
	ct=0;adj=2;
	while(sorted<total)
	{
		canDrop();
		if(visitedCount==3)
			predict();
		if(sorted==total)
			break;
		pickup();
		traverseToSort(ct,ct%2+4);
		sortCheck();
	}
	for(i=0;i<4;i++)
		printf("%d %d\n",term[i][0],term[i][1]);
	printf("Sort 0=%dSort 1=%d\nArm 0=%dArm 1=%d\n",sort[0],sort[1],arm[0],arm[1]);
	printf("Cost=%d\nSORTED!!!!!\n",cost+7);
	//getch();
	return 0;
}
Beispiel #27
0
static void teleds(Short nux, Short nuy)
{
  if (Punished) unplacebc();
  unsee();
  you.utrap = 0;
  you.ustuck = 0;
  you.ux = nux;
  you.uy = nuy;
  setsee();
  if (Punished) placebc(true);
  if (you.uswallow) {
    you.uswallowedtime = you.uswallow = 0;
    //    refresh(); //docrt();
  }
  move_visible_window(you.ux, you.uy, true);
  refresh();
  nomul(0);
  if (get_cell_type(floor_info[nux][nuy]) == POOL && !Levitation)
    drown();
  inshop();
  pickup(true);
  if (!Blind) read_engr_at(you.ux,you.uy);
}
cell AMX_NATIVE_CALL Natives::CreateDynamicPickup(AMX *amx, cell *params)
{
	CHECK_PARAMS(9, "CreateDynamicPickup");
	if (core->getData()->getGlobalMaxItems(STREAMER_TYPE_PICKUP) == core->getData()->pickups.size())
	{
		return 0;
	}
	int pickupID = Item::Pickup::identifier.get();
	Item::SharedPickup pickup(new Item::Pickup);
	pickup->amx = amx;
	pickup->pickupID = pickupID;
	pickup->originalStreamDistance = -1.0f;
	pickup->modelID = static_cast<int>(params[1]);
	pickup->type = static_cast<int>(params[2]);
	pickup->position = Eigen::Vector3f(amx_ctof(params[3]), amx_ctof(params[4]), amx_ctof(params[5]));
	Utility::addToContainer(pickup->worlds, static_cast<int>(params[6]));
	Utility::addToContainer(pickup->interiors, static_cast<int>(params[7]));
	Utility::addToContainer(pickup->players, static_cast<int>(params[8]));
	pickup->streamDistance = amx_ctof(params[9]) < STREAMER_STATIC_DISTANCE_CUTOFF ? amx_ctof(params[9]) : amx_ctof(params[9]) * amx_ctof(params[9]);
	core->getGrid()->addPickup(pickup);
	core->getData()->pickups.insert(std::make_pair(pickupID, pickup));
	return static_cast<cell>(pickupID);
}
Beispiel #29
0
void move_parcels(struct planning_state* state, struct goal* goal) {
  int truck_index = 0;
  int parcel;

  for (parcel = 0; parcel < NUMBER_OF_ENTITIES; parcel++) {
    int to = goal->pos[parcel];
    if (to == DONT_CARE) {
      continue;
    }
    if (state->pos[parcel] != to) {
      int truck = state->trucks[truck_index];
      int from = state->pos[parcel];
      route(state, truck, from);
      pickup(state, parcel, truck, from);
      route(state, truck, to);
      dropoff(state, parcel, truck, to);
      truck_index++;
      if (truck_index >= state->number_of_trucks) {
        truck_index = 0;
      }
    }
  }
}
Beispiel #30
0
	void receive_clicked_point_CB(
			const geometry_msgs::PointStamped::ConstPtr& msg) {
		ROS_INFO(
				"Point received: x: %f, y: %f, z: %f ", msg->point.x, msg->point.y, msg->point.z);

		/*
		 //Throw away old received clicked points
		 if ((ros::Time::now().sec - msg->header.stamp.sec)
		 > message_receive_dead_time_in_sec) {
		 return;
		 }
		 */

		set_pickup_point(*msg);

		clicked = true;

		ROS_INFO("Clicked!!!!");

		determine_normal_of_point_cloud_at_clicked_point();

		pickup();

	}