//--------------------------------------------------------------
void ofxBulletWorldSoft::setGravity( ofVec3f a_g ) {
	if(!checkWorld()) return;
	world->setGravity( btVector3(a_g.x, a_g.y, a_g.z) );
	world->getWorldInfo().m_gravity.setValue(a_g.x, a_g.y, a_g.z);
	//	clientResetScene();
	

}
ICommand::Handle UserRequestBuilder::buildActivateEpochRequest() const {
    checkCredentials();
    checkWorld();
    return mReqBuilder->buildActivateEpochRequest(
        mUsername, mPassword,
        mWorld
    );
}
//--------------------------------------------------------------
void ofxBulletWorldRigid::update( float aDeltaTimef, int aNumIterations ) {
    if(!checkWorld()) return;
    world->stepSimulation( aDeltaTimef, aNumIterations );

    if(bDispatchCollisionEvents) {
        world->performDiscreteCollisionDetection();
        checkCollisions();
    }
}
ICommand::Handle UserRequestBuilder::buildCreateEpochRequest (
    const std::string a_epoch_name ) const {
    checkCredentials();
    checkWorld();
    return mReqBuilder->buildCreateEpochRequest(
        mUsername, mPassword,
        mWorld,
        a_epoch_name
    );
}
//--------------------------------------------------------------
void chinoWorld::update() {
	if(!checkWorld()) return;
	// should this run on delta time? //
    world->stepSimulation(1.0f/60.0f, 6, 1./60.);
	
	if(bDispatchCollisionEvents) {
		world->performDiscreteCollisionDetection();
		checkCollisions();
	}
}
Exemple #6
0
/*******************************************************************
* Function:			void map (void)
* Input Variables:	none
* Output Return:	none
* Overview:			Makes the robot map the world
********************************************************************/
void map (void)
{
	// Initialize State
	isMapping = 1;
	
	// Mapping Loop
	while(isMapping)
	{	
		//Sense
		checkIR();	
		checkWorld();
		
		//Record
		setGateways();
				
		//Plan using the Map
		planMap();
		
		//Act on the Map
		moveMap();
		
		//Shift the Map
		currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation);
		
		//Break?
		isMapping = !((currentCellWorldStart == currentCellWorld)&&(currentOrientationStart == currentOrientation));
		if(!isMapping){			
			break;
		}
		
		//Print Map
		LCD_clear();
		LCD_printf("      Move"BYTETOBINARYPATTERN"\n      Cell"BYTETOBINARYPATTERN"\n      Ornt"BYTETOBINARYPATTERN"\n\n",BYTETOBINARY(currentMove),BYTETOBINARY(currentCellWorld),BYTETOBINARY(currentOrientation));
		printMap(currentOrientation,currentCellWorld,RESET);
		TMRSRVC_delay(500);//wait 3 seconds
	}
	
}
Exemple #7
0
void CBOT_main( void )
{
	// initialize the robot
	initializeRobot();
	currentOrientation = NORTH;
	
	// Ask for Goal
	char isDone = 0;
	unsigned char btnHolder = UNPRESSED;
	LCD_clear();
	LCD_printf("      Goal?\n\n\n\n");
	while(!isDone){
		btnHolder = EnterTopoCommand();
		switch(btnHolder){
			case MOVE_LEFT:
				currentGoalWorld--;
				currentGoalWorld = currentGoalWorld&0b1111;
				break;
			case MOVE_FORWARD:
				isDone = 1;
				break;
			case MOVE_RIGHT:
				currentGoalWorld++;
				currentGoalWorld = currentGoalWorld&0b1111;
				break;
			default:
				break;
		}
		printMap(currentOrientation,currentGoalWorld,RESET);
		TMRSRVC_delay(100);//wait .1 seconds
	}
	
	// Ask for starting orentation
	isDone = 0;
	btnHolder = UNPRESSED;
	LCD_clear();
	LCD_printf("      Orient?\n\n\n\n");
	while(!isDone){
		btnHolder = EnterTopoCommand();
		switch(btnHolder){
			case MOVE_LEFT:
				// If we move left
				// shift our oriention CCW
				currentOrientation--;
				currentOrientation = currentOrientation&0b11;
				break;
			case MOVE_FORWARD:
				isDone = 1;
				break;
			case MOVE_RIGHT:
				// If we move right
				// shift our oriention CW
				currentOrientation++;
				currentOrientation = currentOrientation&0b11;
				break;
			default:
				break;
		}
		printMap(currentOrientation,currentGoalWorld,RESET);
		TMRSRVC_delay(100);//wait .1 seconds
	}
	
	// Ask to start
	isDone = 0;
	btnHolder = UNPRESSED;
	LCD_clear();
	LCD_printf("      Start?\n\n\n\n");
	while(!isDone){
		btnHolder = EnterTopoCommand();
		switch(btnHolder){
			case MOVE_LEFT:
				break;
			case MOVE_FORWARD:
				isDone = 1;
				break;
			case MOVE_RIGHT:
				break;
			default:
				break;
		}
		printMap(currentOrientation,currentGoalWorld,RESET);
		TMRSRVC_delay(100);//wait .1 seconds
	}
	
	// Locilize the Robot
	// localize();
	
	// Initialize State
	isLost = 1;
	oldMove = MOVE_STOP;
	
	// Localization Loop 
	while(isLost)
	{	
		// Break if not isLost
		if(!isLost){
			break;
		}
		
		//Sense Gateway
		checkIR();	
		checkWorld();
		
		//Plan using the Gateway
		planGateway();
		
		//Localize from Gateways?
		isLost = localizeGateway();
		
		//Act on the Gateway
		moveMap();
	}
		
	// Update the currentOrientation using currentMove
	switch(currentMove){
		// case MOVE_LEFT:
			// // If we move left
			// // shift our oriention CCW
			// currentOrientation--;
			// currentOrientation = currentOrientation&0b11;
			// break;
		case MOVE_FORWARD:
			break;
		// case MOVE_RIGHT:
			// // If we move right
			// // shift our oriention CW
			// currentOrientation++;
			// currentOrientation = currentOrientation&0b11;
			// break;
		default:
			LCD_printf("Whatz2?!");
			break;
	}
	
		SPKR_beep(500);	
		// LCD_clear();
		// LCD_printf("LOLZ\nI'm found!");
		// TMRSRVC_delay(3000);//wait 3 seconds
		
		LCD_clear();
		LCD_printf("      New Map\n\n\n\n");
		printMap(currentOrientation,currentCellWorld,RESET);
		TMRSRVC_delay(1000);//wait 1 seconds
		SPKR_beep(0);
		
		
	// currentCellWorld = 0;
	isFire = 0;
	
	// Go firefight
	while(!isFire){
		//Sense Gateway
		checkIR();	
		checkWorld();
		
		isFire = checkFire();
		if(isFire){
			break;
		}
		
		// Plan using Map
		planMap();
		
		// Shift the map
		currentCellWorld = shiftMap(currentCellWorld, currentMove, currentOrientation);
		
		// Act on the Map
		moveMap();
	}
	
	// // Beep for the fire SIREN
	// int ii;
	// for (ii=0; ii<=3; ii++){
		// SPKR_beep(250);	
		// TMRSRVC_delay(1000);
		// SPKR_beep(500);	
		// TMRSRVC_delay(1000);
	// }
	// SPKR_beep(0);
	
	// // Print the fire cell location
	// LCD_clear();
	// LCD_printf("Fire = %i\n\n\n\n", currentFireCell);
	// TMRSRVC_delay(5000);
	
	// Moves the Robot to the goal
	metric();
	
		
		// Print that you are at home and the fire cell location
		LCD_clear();
		LCD_printf("LOLZ\nI'm HOME\nFire at Cell: %i\n\n",currentFireCell);
		// Stop when home is reached
		STEPPER_stop(STEPPER_BOTH, STEPPER_BRK_OFF);
		// Beep when home is reached
		SPKR_beep(500);
		TMRSRVC_delay(3000);//wait 3 seconds
		SPKR_beep(0);
		TMRSRVC_delay(7000);//wait 7 seconds
		
	/**
	
	// Enter the robot's current (starting) position
	LCD_printf("START Map/nlocation\n\n\n");	
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	worldInput();
	TMRSRVC_delay(1000);//wait 3 seconds
	LCD_clear();
	
	// Enter the robot's current (starting) orientation
	LCD_printf("START Map/norientation\n\n\n");	
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	orientationInput();
	TMRSRVC_delay(1000);//wait 3 seconds
	LCD_clear();
	
	// Print the map
	LCD_clear();	
	printMap(currentOrientation,currentCellWorld,RESET);
	TMRSRVC_delay(10000);//wait 10 seconds
	LCD_clear();	
	
	// Enter the robot's current (starting) position
	LCD_printf("START Path\nlocation\n\n\n");	
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	worldInput();
	TMRSRVC_delay(1000);//wait 3 seconds
	LCD_clear();
	
	// Enter the robot's current (starting) orientation
	LCD_printf("START Path\norientation\n\n\n");
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	orientationInput();
	TMRSRVC_delay(1000);//wait 3 seconds
	LCD_clear();
	
	// Enter the robot topological commands
	LCD_printf("ENTER Path\ncommands\n\n\n");
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	movesInput();
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	
	// Print the robot gateways
	LCD_printf("Robot Gateways:\n\n\n\n");
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
	getGateways();
	TMRSRVC_delay(1000);//wait 1 seconds
	LCD_clear();
		
		
	// Goal loop
	while (1)
    {
		checkIR();	
		checkWorld();
		moveWorld();
		//Test arc function
		// LCD_printf("Move Arc\n\n\n\n");
		// TMRSRVC_delay(1000);//wait 1 seconds
		// move_arc_stwt(POINT_TURN, LEFT_TURN, 10, 10, 0);
			
		// //Test contact Sensors
		// LCD_printf("Right Contact: %i\nLeft Contact: %i\n\n\n",rightContact,leftContact);
		// TMRSRVC_delay(1000);//wait 1 seconds
		
		// // Test IR Sensors
		// LCD_clear();
		// LCD_printf("FrontIR = %3.2f\nBackIR = %3.2f\nLeftIR = %3.2f\nRightIR = %3.2f\n", ftIR,bkIR,ltIR,rtIR);
		// TMRSRVC_delay(1000);//wait 1 seconds
    }
	**/

}// end the CBOT_main()
//--------------------------------------------------------------
ofVec3f ofxBulletWorldSoft::getGravity() {
	if(!checkWorld()) return ofVec3f(0,0,0);
	btVector3 g = world->getGravity();
	return ofVec3f(g.getX(), g.getY(), g.getZ());
}
//--------------------------------------------------------------
void ofxBulletWorldRigid::setGravity( ofVec3f a_g ) {
    if(!checkWorld()) return;
    world->setGravity( btVector3(a_g.x, a_g.y, a_g.z) );
}