Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by MI_Ishraq · Dec 28, 2020 at 05:58 AM · positionquaternionrotatecoroutinelerp

Creating points for robot (End Effector) to go through them

Hi everyone.

I'm trying to create an environment, whereby the user would be able to save desired points (Button: Save Points) within the 3D space and once that is done, the end effector would go through said points (Button: Go). Somehow the issue I'm facing is that the robot's joint gets distorted after each iteration. Attached below is the image (Creating point 1-4) and code for the path teaching (To save points and go through them).

Would appreciate any help and thanks in advance.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
  
 public class simPTP : MonoBehaviour
 {
     public GameObject Part1, Part2, Part3, Part4, Part5, Part6;
     public float time = 1.0f;
     Quaternion[] memy1Array = new Quaternion[5];
     Quaternion[] memy2Array = new Quaternion[5];
     Quaternion[] memy3Array = new Quaternion[5];
     Quaternion[] memy4Array = new Quaternion[5];
     Quaternion[] memy5Array = new Quaternion[5];
     Quaternion[] memy6Array = new Quaternion[5];
     int memPoints = 0;
  
     public void SavePoint()
     {
         //saves position, up to a maximum of 5
         if (memPoints < 5)
         {
             memy1Array[memPoints] = Part1.transform.localRotation;
             memy2Array[memPoints] = Part2.transform.localRotation;
             memy3Array[memPoints] = Part3.transform.localRotation;
             memy4Array[memPoints] = Part4.transform.localRotation;
             memy5Array[memPoints] = Part5.transform.localRotation;
             memy6Array[memPoints] = Part6.transform.localRotation;
  
             memPoints++;
         }
     }
  
     public void GoThroughPoints()
     {
         /*if (time.text != null)
         {
             StartCoroutine(RotateMe(float.Parse(time.text)));
         }*/
         StartCoroutine(RotateMe(time));
     }
    
     IEnumerator RotateMe(float inTime)
     {
         for (int i = 0; i < memPoints; i++)
         {
             Quaternion Angle1 = Part1.transform.localRotation;
             Quaternion Angle2 = Part2.transform.localRotation;
             Quaternion Angle3 = Part3.transform.localRotation;
             Quaternion Angle4 = Part4.transform.localRotation;
             Quaternion Angle5 = Part5.transform.localRotation;
             Quaternion Angle6 = Part6.transform.localRotation;
  
             for (float t = 0f; t < 1f; t += Time.deltaTime / inTime)
             {
                 Part1.transform.localRotation = Quaternion.Lerp(Angle1, memy1Array[i], t);
                 Part2.transform.localRotation = Quaternion.Lerp(Angle2, memy2Array[i], t);
                 Part3.transform.localRotation = Quaternion.Lerp(Angle3, memy3Array[i], t);
                 Part4.transform.localRotation = Quaternion.Lerp(Angle4, memy1Array[i], t);
                 Part5.transform.localRotation = Quaternion.Lerp(Angle5, memy2Array[i], t);
                 Part6.transform.localRotation = Quaternion.Lerp(Angle6, memy3Array[i], t);
  
                 yield return null;
             }
         }
     }
  
     // Start is called before the first frame update
     void Start()
     {
        
     }
  
     // Update is called once per frame
     void Update()
     {
        
     }
 }

alt text

path-teaching.png (198.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

187 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotating to match surface normal (curved surface). 0 Answers

Can you make the player do a 180° / u-turn when a button is pressed? 0 Answers

Camera registering it is at correct position when it isn't 0 Answers

How can I limit rotate "missile gun" in global coordinates ? Java 0 Answers

How to rotate quaternion around local axis? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges