Example #1
0
        void AddGround()
        {
            // create a large horizontal plane, at zero elevation.
            HeightFieldEntity ground = new HeightFieldEntity(
                "simple ground",             // name
                "03RamieSc.dds",             // texture image
                new MaterialProperties("ground",
                                       0.2f, // restitution
                                       0.5f, // dynamic friction
                                       0.5f) // static friction
                );

            SimulationEngine.GlobalInstancePort.Insert(ground);
        }
        /// <summary>
        /// 加上地面
        /// </summary>
        void AddGround()
        {
            // 产生一个宽广的地面
            HeightFieldEntity ground = new HeightFieldEntity(
                "simple ground",
                "03RamieSc.dds",
                new MaterialProperties("ground",
                                       0.2f, // restitution
                                       0.5f, // dynamic friction
                                       0.5f) // static friction
                );

            SimulationEngine.GlobalInstancePort.Insert(ground);
        }
Example #3
0
        private void AddGround()
        {
            HeightFieldEntity ground = new HeightFieldEntity("Simple Ground ", "03RamieSc.dds", new MaterialProperties("ground", .2f, .99f, .99f));

            SimulationEngine.GlobalInstancePort.Insert(ground);
        }
Example #4
0
        private VisualEntity CreateEntity(Vector3 entityPosition, VisualEntity entityParent, Entities entityType)
        {
            VisualEntity e = null;

            #region Create Entity
            switch (entityType)
            {
            case Entities.HeightFieldEntity:
            {
                e = new HeightFieldEntity("ground", "03RamieSc.dds", new
                                          MaterialProperties("ground", 0.8f, 0.5f, 0.8f));
            } break;

            case Entities.SkyDomeEntity:
            {
                e = new SkyDomeEntity("skydome.dds", "sky_diff.dds");
                SimulationEngine.GlobalInstancePort.Insert(e);
            } break;

            case Entities.LightSourceEntity:
            {
                var lightEntity = new LightSourceEntity();
                e = lightEntity;
                lightEntity.State.Name          = "LightSourceEntity";
                lightEntity.Type                = LightSourceEntityType.Directional;
                lightEntity.Color               = new Vector4(.8f, .8f, .8f, 1);
                lightEntity.State.Pose.Position = new Vector3(0, 1, 0);
                lightEntity.Direction           = new Vector3(0, -1, 0);
                e.Flags = e.Flags | VisualEntityProperties.DisableRendering;
            } break;

            case Entities.MotorBaseWithDrive:
            {
                e            = new MotorBaseWithDrive(entityPosition);
                e.State.Name = "MotorBaseWithDrive";
                MakeNameUnique(e);
            } break;

            case Entities.SimulatedBrightnessSensorEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e            = new SimulatedBrightnessSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                    e.State.Name = "SimulatedBrightnessSensorEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedColorSensorEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e            = new SimulatedColorSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                    e.State.Name = "SimulatedColorSensorEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedCompassEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }

                else
                {
                    e            = new SimulatedCompassEntity();
                    e.State.Name = "SimulatedCompassEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedGPSEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }

                else
                {
                    e            = new SimulatedGPSEntity();
                    e.State.Name = "SimulatedGPSEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedIREntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }

                else
                {
                    e              = new SimulatedIREntity(new Pose(entityPosition));
                    e.State.Name   = "SimulatedIREntity";
                    e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedLRFEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e              = new SimulatedLRFEntity(new Pose(entityPosition));
                    e.State.Name   = "SimulatedLRFEntity";
                    e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedSonarEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e              = new SimulatedSonarEntity(new Pose(entityPosition));
                    e.State.Name   = "SimulatedSonarEntity";
                    e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;

            case Entities.SimulatedWebcamEntity:
            {
                if (entityParent == null)
                {
                    ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                }
                else
                {
                    e = new SimulatedWebcamEntity(entityPosition,
                                                  320, 240, 45.0f * (float)Math.PI / 180.0f);
                    e.State.Name = "SimulatedWebcamEntity";
                    MakeNameUnique(e);
                    entityParent.InsertEntity(e);
                }
            } break;
            }
            #endregion

            return(e);
        }
Example #5
0
        public VisualEntity CreateEntity(Vector3 entityPosition, VisualEntity entityParent, Entities entityType)
        {
            VisualEntity e = null;

            #region Create Entity
            switch (entityType)
            {
                case Entities.HeightFieldEntity:
                    {
                        e = new HeightFieldEntity("ground", "03RamieSc.dds", new
                            MaterialProperties("ground", 0.8f, 0.5f, 0.8f));

                    } break;
                case Entities.SkyDomeEntity:
                    {
                        e = new SkyDomeEntity("skydome.dds", "sky_diff.dds");
                        SimulationEngine.GlobalInstancePort.Insert(e);
                    } break;
                case Entities.LightSourceEntity:
                    {
                        var lightEntity = new LightSourceEntity();
                        e = lightEntity;
                        lightEntity.State.Name = "LightSourceEntity";
                        lightEntity.Type = LightSourceEntityType.Directional;
                        lightEntity.Color = new Vector4(.8f, .8f, .8f, 1);
                        lightEntity.State.Pose.Position = new Vector3(0, 1, 0);
                        lightEntity.Direction = new Vector3(0, -1, 0);
                        e.Flags = e.Flags | VisualEntityProperties.DisableRendering;

                    } break;
                case Entities.MotorBaseWithDrive:
                    {
                        e = new MotorBaseWithDrive(entityPosition);
                        e.State.Name = "MotorBaseWithDrive";
                        MakeNameUnique(e);

                        //Inserting Actual Rover instead of Simple Simulatd Robot.
                        //Needs to be tested

                        /*ColladaToMSRS e = new ColladaToMSRS(@"C:\.....\collada\rover.dae");
                        foreach (VisualEntity entity in e.Entities)
                        {
                            SimulationEngine.GlobalInstancePort.Insert(entity);
                        }*/

                    } break;
                case Entities.SimulatedBrightnessSensorEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedBrightnessSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                            e.State.Name = "SimulatedBrightnessSensorEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedColorSensorEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedColorSensorEntity(32, 32, 2.0f * (float)Math.PI / 180.0f);
                            e.State.Name = "SimulatedColorSensorEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedCompassEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }

                        else
                        {
                            e = new SimulatedCompassEntity();
                            e.State.Name = "SimulatedCompassEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;

                case Entities.SimulatedGPSEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }

                        else
                        {
                            e = new SimulatedGPSEntity();
                            e.State.Name = "SimulatedGPSEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;

                case Entities.SimulatedIREntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }

                        else
                        {
                            e = new SimulatedIREntity(new Pose(entityPosition));
                            e.State.Name = "SimulatedIREntity";
                            e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedLRFEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedLRFEntity(new Pose(entityPosition));
                            e.State.Name = "SimulatedLRFEntity";
                            e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                            MakeNameUnique(e);
                            //EntityUIService newservice = new EntityUIService();
                            //newservice.AddBoeBot(new Vector3(1,0,1));
                            //CreateService(laserrangefinder.Contract.Identifier,
                                //Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/" + e.State.Name));
                            entityParent.InsertEntity(e);

                        }

                    } break;
                case Entities.SimulatedSonarEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedSonarEntity(new Pose(entityPosition));
                            e.State.Name = "SimulatedSonarEntity";
                            e.State.Flags |= EntitySimulationModifiers.DisableCollisions;
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);
                        }

                    } break;
                case Entities.SimulatedWebcamEntity:
                    {
                        if (entityParent == null)
                        {
                            ShowEntityRequiresParentError(entityType.ToString() + " requires parent");
                        }
                        else
                        {
                            e = new SimulatedWebcamEntity(entityPosition,
                                320, 240, 45.0f * (float)Math.PI / 180.0f);
                            e.State.Name = "SimulatedWebcamEntity";
                            MakeNameUnique(e);
                            entityParent.InsertEntity(e);

                        }

                    } break;
            }
            #endregion

            return e;
        }
Example #6
0
 void AddGround()
 {
     // create a large horizontal plane, at zero elevation.
     HeightFieldEntity ground = new HeightFieldEntity(
         "simple ground", // name
         "Wood_cherry.jpg", // texture image
         new MaterialProperties("ground",
             0.2f, // restitution
             0.5f, // dynamic friction
             0.5f) // static friction
         );
     SimulationEngine.GlobalInstancePort.Insert(ground);
 }
Example #7
0
        public void AddGround(float WidthLength)
        {
            HeightFieldShapeProperties hf = new HeightFieldShapeProperties("height field",
               100, // number of rows
               WidthLength, // distance in meters, between rows
               100, // number of columns
               WidthLength, // distance in meters, between columns
               1, // scale factor to multiple height values
               -1000); // vertical extent of the height field. Should be set to large negative values

            // create a material for the entire field. We could also specify material per sample.
            hf.Material = new MaterialProperties("ground", 0.2f, 0.5f, 0.5f);
            hf.Dimensions = new Vector3(5f, 5f, 5f);
            // insert ground entity in simulation and specify a texture
            HeightFieldEntity ground = new HeightFieldEntity(hf, "03RamieSc.dds");
            this.Ground = ground;
            SimulationEngine.GlobalInstancePort.Insert(ground);
        }