• 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 /
avatar image
Question by manvsrice · Oct 23, 2017 at 08:12 PM · physicstransformpositionvelocitysimulation

Help around an approach to a "Virtual Motion Table" in Unity

Hello there,

I am testing possibillites for having Unity generate test input for simulation of a software component needing yaw, pitch and roll input. And it seems I am having some problems with fetching the right data, especially I have problems with the correlation between position and speed using Rigidbody objects.

The idea so far has been to make a cube as a table, and then place another cube on top of that one as the object to generate movement for. I add a rigidbody object to both of them, and connect them with a fixed joint with infinite "bindings". I remove all drag, and I freeze their position to only do rotations as the first test. I then try to read angular velocity data and position rotation from the test cube on the top. This data I then send into and DLL I have built waiting for interesting data.

In a FixedUpdate()-function I generate a sinus signal to rotate the the table. I use the RigidBody.AddRelativeTorque() to update the physics. This torque is added to the main table. As mentioned I then try to fetch cool data to input into my software that I want to test.

This is the data I have tried grabbing:

             currentInputPlatformData.YawLocalPos = Mathf.Deg2Rad * ObjectOnTableTransform.localRotation.eulerAngles.y;
             currentInputPlatformData.YawPos = Mathf.Deg2Rad * ObjectOnTableTransform.rotation.eulerAngles.y;
             currentInputPlatformData.YawSpeed = ObjectOnTablePhysics.angularVelocity.y;
             
     
             currentInputPlatformData.PitchLocalPos = Mathf.Deg2Rad * ObjectOnTableTransform.localRotation.eulerAngles.x;
             currentInputPlatformData.PitchPos = Mathf.Deg2Rad * ObjectOnTableTransform.rotation.eulerAngles.x;
             currentInputPlatformData.PitchSpeed = ObjectOnTablePhysics.angularVelocity.x;
     
             currentInputPlatformData.RollLocalPos = Mathf.Deg2Rad * ObjectOnTableTransform.localRotation.eulerAngles.z;
             currentInputPlatformData.RollPos = Mathf.Deg2Rad * ObjectOnTableTransform.rotation.eulerAngles.z;
             currentInputPlatformData.RollSpeed = ObjectOnTablePhysics.angularVelocity.z;
 
 

When only doing rotation in "Yaw", meaning around the Y-axis in Unity everything works great! :) I integrate the currentInputPlatformData.YawSpeed and it matches perfectly the currentInputPlatformData.YawPos over time.

However, when I start doing rotations in pitch or roll nothing matches up. I wonder if I am mixing up what I am comparing? Something local and something in world coordinates perhaps? Is the approach for getting angular velocity and rotation position a sensible one in context for yaw, roll, pitch?

On a side note I have also tried to get translations in the same manner, and this seem to work well. I get the Heave, Sway and Surge I am expecting.

Best regards,

Comment

People who like this

0 Show 0
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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

140 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

Related Questions

how to CORRECTLY position and rotate a gameobject in unity 2 Answers

transform position to moving object too slow 1 Answer

transform postion trigger problem HELP! 0 Answers

Transform.position.x jumps to high numbers after collision 1 Answer

Imparting Physics in only certain planes of motion 1 Answer


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