示例#1
0
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
    // create your scene here :)

	/* Create a new simulator instance. */
	RVO::RVOSimulator *sim = new RVO::RVOSimulator();
	
	Visualizer vis( sim );

	/* Set up the scenario. */
	setupScenario(sim);

	
    // Set the scene's ambient light
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.0f, 0.5f, 1.0f));
 
    // Create an Entity
    Ogre::Entity* sphere1_entity = mSceneMgr->createEntity("sphere1", "sphere.mesh");
 
    // Create a SceneNode and attach the Entity to it
    Ogre::SceneNode* sphere1_scene = mSceneMgr->getRootSceneNode()->createChildSceneNode("sphere1");
    sphere1_scene->attachObject(sphere1_entity);
 
	//another head
	Ogre::Entity* sphere2_entity = mSceneMgr->createEntity( "sphere2", "sphere.mesh" );
	Ogre::SceneNode* sphere2_scene = mSceneMgr->getRootSceneNode()->createChildSceneNode( "sphere2", Ogre::Vector3( 600, 0, 0 ) );
	sphere2_scene->attachObject( sphere2_entity );

    // Create a Light and set its position
    Ogre::Light* light = mSceneMgr->createLight("MainLight");
    light->setPosition(20.0f, 80.0f, 50.0f);

}
示例#2
0
int main(int argc, char* argv[]) {
	ros::init(argc, argv, "rvo_example");
	ros::NodeHandle nh("rvo_example");

	/* Create a new simulator instance. */
	RVO::RVOSimulator* sim = new RVO::RVOSimulator();

	/* Set up the scenario. */
	setupScenario(sim);

	/* Perform (and manipulate) the simulation. */
	ROS_INFO("Iteration");
	do {
#if RVO_OUTPUT_TIME_AND_POSITIONS
		updateVisualization(sim);
#endif
		setPreferredVelocities(sim);
		sim->doStep();
	} while (!reachedGoal(sim));
	ROS_INFO("End");

	delete sim;

	return 0;
}
AgentClass::AgentClass(ros::NodeHandle handle)
{
//Definicija konstruktora klase

	//const std::string cmd_vel = "/cmd_vel";
	pub_ = handle.advertise<geometry_msgs::Twist>("/pioneer1/cmd_vel",1000,false); //Postavljanje publishera
	//const std::string cmd_vel_pref = "/cmd_vel_pref";	
	sub[0] = handle.subscribe("/pioneer1/cmd_vel_pref",1000,&AgentClass::callback_function_main,this); //Postavljanje glavnog subscribera
	sub[1] = handle.subscribe("/pioneer2/cmd_vel_pref",1000,&AgentClass::callback_function_2,this); //Preferirana brzina drugog pioneera
	//Pracenje pozicije robota iz Gazeba
	pozicija_ = handle.serviceClient<gazebo_msgs::GetModelState>("gazebo/get_model_state");
	//Rezervacija memorije za novu instancu simulatora
	simulator = new RVO::RVOSimulator();
	setupScenario();
	addAgent1True_ = true;
	addAgent2True_ = true;
	theta_prije = 0.0; //Primjena u AgentClas::Run() za izračun kutne brzine
}
示例#4
0
int main(int argc, const char* argv[])
{
    /* Create a new simulator instance. */
    RVO::RVOSimulator* sim = new RVO::RVOSimulator();

    /* Set up the scenario. */
    setupScenario(sim);

    /* Perform (and manipulate) the simulation. */
    do {
        updateVisualization(sim);
        setPreferredVelocities(sim);
        sim->doStep();
    } while (!reachedGoal(sim));

    delete sim;

    return 0;
}