예제 #1
0
        public static List <DHParameter> GetDhParameterForRobot(RobotModels model)
        {
            if (!_factoriesInitialized)
            {
                InitializeFactories();
            }

            var parameter = new List <DHParameter>();


            //TODO: Implement other robot models
            switch (model)
            {
            case RobotModels.Kuka_KR300_R2500:
                throw new NotImplementedException();

            case RobotModels.Kuka_KR270_R2700:
                parameter = KukaRobotModelFactory.GetDHForKR270R2700();
                break;

            case RobotModels.Kuka_KR240_R2900:
                throw new NotImplementedException();

            case RobotModels.Kuka_KR210_R3100:
                throw new NotImplementedException();

            default:
                break;
            }

            return(parameter);
        }
예제 #2
0
        public Robot(string name, RobotManufacturer robotBrand, RobotModels robotModel)
        {
            ModelName = name;
            Joints    = new SortedList <int, Joint>();

            var dhParams = DHParameterFactory.GetDhParameterForRobot(robotModel);

            for (int i = 0; i < dhParams.Count; i++)
            {
                Joints.Add(i, new RotationalJoint(0, 360, dhParams[i]));
            }

            Kinematic = new RobotKinematics(dhParams);

            InitializeMember();
            Joint6ToFlangeTrafo = RobotBaseDataProvider.GetJoint6ToFlangeTransformation(robotBrand);
        }
예제 #3
0
        public MainViewModel()
        {
            EffectsManager = new DefaultEffectsManager();
            // camera setup
            Camera = new PerspectiveCamera
            {
                Position         = new Point3D(0, -2000, 400),
                LookDirection    = new Vector3D(0, 2000, 0),
                UpDirection      = UpDirection,
                FarPlaneDistance = 5000000,
            };


            // setup lighting
            //SkyboxTexture = LoadFileToMemory("Cubemap_Grandcanyon.dds");
            LightDirection = new Vector3D(0, -0.5, -1);
            LightDirection.Normalize();
            SetHeadLight();

            AmbientLightColor     = Colors.White * 1000;
            DirectionalLightColor = Color.FromScRgb(1, 10, 10, 10);
            BackgroundColor       = Color.FromRgb(40, 40, 40);

            // model transform
            ModelTransform = Transform3D.Identity;
            //var r = new System.Windows.Media.Media3D.AxisAngleRotation3D(new Vector3D(0, 0, 1), 90);
            //EnvironmentTransform = new System.Windows.Media.Media3D.RotateTransform3D(r);

            // model materials
            var material = new PBRMaterial();

            material.AlbedoColor            = new Color4(0.8f, 0.4f, 0.05f, 1f);
            material.MetallicFactor         = 0.2;
            material.ReflectanceFactor      = 0.8;
            material.RenderEnvironmentMap   = false;
            material.AmbientOcclusionFactor = 1;

            // floor plane grid
            Grid          = LineBuilder.GenerateGrid(new Vector3(0, 0, 1), -10, 10, -10, 10);
            GridColor     = Color.FromRgb(100, 100, 100);
            GridTransform = new System.Windows.Media.Media3D.ScaleTransform3D(100, 100, 100);

            // commands
            UpZCommand = new RelayCommand(_ => { Log = "test switch"; });

            // robot program
            var test = new TestProgram();

            Program = test.Program;
            Log     = Program.Errors.Count == 0 ? Program.RobotSystem.Name : string.Join(" ", Program.Errors);

            // make robot
            var cell   = Program.RobotSystem as Robots.RobotCell;
            var group  = cell.MechanicalGroups.First();
            var meshes = group.Joints.Select(j => j.Mesh).Prepend(group.Robot.BaseMesh);

            _origins = group.Joints.Select(j => j.Plane).Prepend(group.Robot.BasePlane).ToArray();

            foreach (var joint in meshes)
            {
                var model = new MeshGeometryModel3D();
                model.Geometry         = joint.ToWPF();
                model.Material         = material;
                model.Transform        = Transform3D.Identity;
                model.IsThrowingShadow = true;
                RobotModels.Add(model);
            }

            // timer
            _timer = new Timer(Tick, null, Timeout.Infinite, 0);
        }