x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Get wheel odometry?

I want to trigger an event every time a wheel passed a certain rotation value. How can I accomplish this? Can I get the amount of rotations for a wheel at a certain timepoint?

Product Version: UE 4.21
Tags:
more ▼

asked Feb 11 '19 at 03:03 PM in Blueprint Scripting

avatar image

cpi.ivu
1 1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Are your wheels using physics? (They probably are.) If so, you should be able to use Get Physics Angular Velocity in Degrees to find out how fast your wheel is rotating each frame. Here's how I would try setting it up:

  1. Create a float variable in your Blueprint that will keep track of wheel rotations (call it something like "WheelRotationDegrees")

  2. Find out whichever channel (X, Y, or Z) represents the rotation axis of your wheel

  3. Each frame, add the value of this channel to your "WheelRotationDegrees" variable

  4. Each frame, if the updated value of your "WheelRotationDegrees" variable is greater than 360, subtract 360 and call up whatever event functions you want

Additional thoughts:

  • If you want your event functions to be able to be called up more than once per frame if the wheel is rotating extremely quickly, you'll want to divide your "WheelRotationDegrees" value by 360 and fire off your event functions that many times; e.g., a value of 823.8 degrees would cause your functions to be called up twice (823.8 / 360 = 2.2883, which floors down to 2)

  • Make sure you use the Absolute (float) on the value of your wheel's rotation to make sure you fire off events no matter which way (forward or backward) the wheel is rotating

Hopefully that makes sense! If you think you'll need example screenshots of how it would look in Blueprint, let me know and I'll upload something as soon as I can.

more ▼

answered Feb 11 '19 at 04:34 PM

avatar image

the_batch
1.1k 4 5 8

avatar image cpi.ivu Feb 12 '19 at 07:06 AM

Thanks very much for your detailed answer! I did unterstand your thoughts with one remaining point. How can I fire an event twice a frame, if the wheel rotates for. e.g. 721° in one frame? I'm aksing that because I'm sending chars to a comport out of the game to an external device to use the odometry

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question