Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="e">
        /// </param>
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            // Ok, let's start to build our virtual robot arm !
            this.model = new DenavitHartenbergModel(new Vector3(0, 0, 0));

            // Add the first joint
            this.model.Joints.Add(alpha: 0, theta: Math.PI / 4, radius: 35, offset: 0);

            // Add the second joint
            this.model.Joints.Add(alpha: 0, theta: -Math.PI / 3, radius: 35, offset: 0);

            // Create the top finger
            this.model_tgripper = new DenavitHartenbergModel();
            this.model_tgripper.Joints.Add(alpha: 0, theta: Math.PI / 4, radius: 20, offset: 0);
            this.model_tgripper.Joints.Add(alpha: 0, theta: -Math.PI / 3, radius: 20, offset: 0);

            // Create the bottom finger
            this.model_bgripper = new DenavitHartenbergModel();
            this.model_bgripper.Joints.Add(alpha: 0, theta: -Math.PI / 4, radius: 20, offset: 0);
            this.model_bgripper.Joints.Add(alpha: 0, theta: Math.PI / 3, radius: 20, offset: 0);

            // Create the model combinator from the parent model
            this.arm = new DenavitHartenbergNode(this.model);

            // Add the top finger
            this.arm.Children.Add(this.model_tgripper);

            // Add the bottom finger
            this.arm.Children.Add(this.model_bgripper);

            // Calculate the whole model (parent model + children models)
            this.arm.Compute();

            // Create the model visualizer
            this.viewer = new DenavitHartenbergViewer(300, 300)
            {
                JointRadius = 4f
            };

            // Assign each projection image of the model to a picture box
            this.pictureBox1.Source = this.viewer.PlaneXY;
            this.pictureBox2.Source = this.viewer.PlaneXZ;
            this.pictureBox3.Source = this.viewer.PlaneYZ;

            // Start the animation
            timer1          = new DispatcherTimer();
            timer1.Interval = new TimeSpan(0, 0, 0, 0, 40);
            timer1.Tick    += this.timer1_Tick;
            timer1.Start();
        }
Esempio n. 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Ok, let's start to build our virtual robot arm !

            model = new DenavitHartenbergModel(new Vector3(0, 0, 0));

            // Add the first joint 
            model.Joints.Add(alpha: 0, theta: Math.PI / 4, radius: 35, offset: 0);

            // Add the second joint
            model.Joints.Add(alpha: 0, theta: -Math.PI / 3, radius: 35, offset: 0);

            // Create the top finger
            model_tgripper = new DenavitHartenbergModel();
            model_tgripper.Joints.Add(alpha: 0, theta: Math.PI / 4, radius: 20, offset: 0);
            model_tgripper.Joints.Add(alpha: 0, theta: -Math.PI / 3, radius: 20, offset: 0);

            // Create the bottom finger
            model_bgripper = new DenavitHartenbergModel();
            model_bgripper.Joints.Add(alpha: 0, theta: -Math.PI / 4, radius: 20, offset: 0);
            model_bgripper.Joints.Add(alpha: 0, theta: Math.PI / 3, radius: 20, offset: 0);

            // Create the model combinator from the parent model
            arm = new DenavitHartenbergNode(model);

            // Add the top finger
            arm.Children.Add(model_tgripper);

            // Add the bottom finger
            arm.Children.Add(model_bgripper);

            // Calculate the whole model (parent model + children models)
            arm.Compute();

            // Create the model visualizer
            viewer = new DenavitHartenbergViewer(pictureBox1.Width, pictureBox1.Height);

            // Assign each projection image of the model to a picture box
            pictureBox1.Image = viewer.PlaneXY;
            pictureBox2.Image = viewer.PlaneXZ;
            pictureBox3.Image = viewer.PlaneYZ;

            // Start the animation
            timer1.Interval = 40;
            timer1.Enabled = true;
        }
Esempio n. 3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Ok, let's start to build our virtual robot arm !

            model = new DenavitHartenbergModel(new Vector3(0, 0, 0));

            // Add the first joint
            model.Joints.Add(alpha: 0, theta: Math.PI / 4, radius: 35, offset: 0);

            // Add the second joint
            model.Joints.Add(alpha: 0, theta: -Math.PI / 3, radius: 35, offset: 0);

            // Create the top finger
            model_tgripper = new DenavitHartenbergModel();
            model_tgripper.Joints.Add(alpha: 0, theta: Math.PI / 4, radius: 20, offset: 0);
            model_tgripper.Joints.Add(alpha: 0, theta: -Math.PI / 3, radius: 20, offset: 0);

            // Create the bottom finger
            model_bgripper = new DenavitHartenbergModel();
            model_bgripper.Joints.Add(alpha: 0, theta: -Math.PI / 4, radius: 20, offset: 0);
            model_bgripper.Joints.Add(alpha: 0, theta: Math.PI / 3, radius: 20, offset: 0);

            // Create the model combinator from the parent model
            arm = new DenavitHartenbergNode(model);

            // Add the top finger
            arm.Children.Add(model_tgripper);

            // Add the bottom finger
            arm.Children.Add(model_bgripper);

            // Calculate the whole model (parent model + children models)
            arm.Compute();

            // Create the model visualizer
            viewer = new DenavitHartenbergViewer(pictureBox1.Width, pictureBox1.Height);

            // Assign each projection image of the model to a picture box
            pictureBox1.Image = viewer.PlaneXY;
            pictureBox2.Image = viewer.PlaneXZ;
            pictureBox3.Image = viewer.PlaneYZ;

            // Start the animation
            timer1.Interval = 40;
            timer1.Enabled  = true;
        }
Esempio n. 4
0
        /// <summary>
        ///   Makes a list of all the models contained on a
        ///   ModelCombinator. This function is recursive.
        /// </summary>
        ///
        /// <param name="model">
        ///   ModelCombinator model in which to extract all the models. </param>
        /// <param name="models">
        ///   List of already extracted models. It accumulates all the
        ///   models at each call of this function.</param>
        ///
        /// <returns>Returns a list of all the models contained in the
        /// ModelCombinator 'model' plus all previously extracted models</returns>
        ///
        private List <DenavitHartenbergModel> GetAllModels(DenavitHartenbergNode model,
                                                           List <DenavitHartenbergModel> models)
        {
            // If it's the first call
            if (models == null)
            {
                // Create the models list
                models = new List <DenavitHartenbergModel>();
            }

            // Add the model contained in the ModelCombinator
            models.Add(model.Model);

            // For all the children of the ModelCombinator
            foreach (DenavitHartenbergNode child in model.Children)
            {
                // Execute recursively this function
                models = GetAllModels(child, models);
            }

            // Return the models list
            return(models);
        }
        /// <summary>
        ///   Makes a list of all the models contained on a
        ///   ModelCombinator. This function is recursive.
        /// </summary>
        /// 
        /// <param name="model">
        ///   ModelCombinator model in which to extract all the models. </param>
        /// <param name="models">
        ///   List of already extracted models. It accumulates all the 
        ///   models at each call of this function.</param>
        ///   
        /// <returns>Returns a list of all the models contained in the 
        /// ModelCombinator 'model' plus all previously extracted models</returns>
        /// 
        private List<DenavitHartenbergModel> GetAllModels(DenavitHartenbergNode model,
            List<DenavitHartenbergModel> models)
        {
            // If it's the first call
            if (models == null)
            {
                // Create the models list
                models = new List<DenavitHartenbergModel>();
            }

            // Add the model contained in the ModelCombinator
            models.Add(model.Model);

            // For all the children of the ModelCombinator
            foreach (DenavitHartenbergNode child in model.Children)
            {
                // Execute recursively this function 
                models = GetAllModels(child, models);
            }

            // Return the models list
            return models;
        }