kling-26-motion-control

A robust Elixir library for precise motion control, enabling smooth and coordinated movements in robotic and animation applications. This package provides a set of tools for generating and managing motion profiles.

Installation

Add kling_26_motion_control to your list of dependencies in mix.exs: elixir def deps do [

{:kling_26_motion_control, "~> 0.1.0"}

] end

Then run mix deps.get to fetch the dependency.

Usage

Here are a few examples demonstrating how to use kling-26-motion-control in your Elixir projects.

Example 1: Generating a Simple Trapezoidal Motion Profile elixir alias Kling26MotionControl.Profile

profile = Profile.new(

max_velocity: 100,
max_acceleration: 50,
distance: 500

)

IO.puts("Profile Duration: #{Profile.duration(profile)}") IO.puts("Profile Distance: #{Profile.distance(profile)}")

Sample position at time t = 2

position = Profile.position(profile, 2) IO.puts("Position at t=2: #{position}")

Example 2: Calculating Velocity at a Specific Time elixir alias Kling26MotionControl.Profile

profile = Profile.new(

max_velocity: 80,
max_acceleration: 40,
distance: 400

)

velocity = Profile.velocity(profile, 1.5) IO.puts("Velocity at t=1.5: #{velocity}")

Example 3: Using Pattern Matching to Handle Profile Stages elixir alias Kling26MotionControl.Profile

profile = Profile.new(

max_velocity: 120,
max_acceleration: 60,
distance: 600

)

time = 3

case Profile.stage(profile, time) do :acceleration ->

IO.puts("The profile is in the acceleration stage at time #{time}")

:constant_velocity ->

IO.puts("The profile is in the constant velocity stage at time #{time}")

:deceleration ->

IO.puts("The profile is in the deceleration stage at time #{time}")

:stopped ->

IO.puts("The profile has stopped at time #{time}")

end

Example 4: Chaining Motion Profile Calculations with Pipes elixir alias Kling26MotionControl.Profile

profile = Profile.new(

max_velocity: 90,
max_acceleration: 45,
distance: 450

)

time = 2.7

profile |> Profile.position(time) |> Float.round(2) |> IO.puts("Position at t=2.7 (rounded): ")

Example 5: Combining Profiles for Complex Movements elixir alias Kling26MotionControl.Profile

profile1 = Profile.new(

max_velocity: 70,
max_acceleration: 35,
distance: 350

)

profile2 = Profile.new(

max_velocity: 60,
max_acceleration: 30,
distance: 300

)

total_distance = Profile.distance(profile1) + Profile.distance(profile2)

IO.puts("Total Distance (Profile 1 + Profile 2): #{total_distance}")

Features

License

MIT

This package is part of the kling-26-motion-control ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/how-to-use-kling-26-motion-control-ai-free-full-tutorial-ai-baby-dance-guide/