kling-motio-control 1768.444.568
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/kling_motio_control.rb +110 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1e869f89ae9784ccccde12b0097965fd85aefcbc8e86ea0519aed0c998938d28
|
|
4
|
+
data.tar.gz: 70c381e1af1615d91826b3d6f51f0d8cbd9de65c6f36275ae88fcc13704ad7d5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0adec91c733186dc4e655eaa77a90bc5c2d991f95084407ceca58c56d33c071baf820b3ca84dc17bc0c62b58de7c2a2ed9146b0b6e643b6456e095b91b0db060
|
|
7
|
+
data.tar.gz: 320f61f562e7d4d1ec6ba33517eeaa47b64dd92c443ad6aed49e94fc37403cd27cfed99881aef7d7dacdd71ad18e0ab801b8c0818ed8d934db3900a516e2556f
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'uri'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
|
|
6
|
+
module KlingMotioControl
|
|
7
|
+
# The base URL for Kling Motion Control resources.
|
|
8
|
+
BASE_URL = 'https://supermaker.ai/blog/what-is-kling-motion-control-ai-how-to-use-motion-control-ai-free-online/'.freeze
|
|
9
|
+
|
|
10
|
+
# Represents a motion profile.
|
|
11
|
+
class MotionProfile
|
|
12
|
+
attr_reader :name, :keyframes
|
|
13
|
+
|
|
14
|
+
# Initializes a new MotionProfile.
|
|
15
|
+
#
|
|
16
|
+
# @param name [String] The name of the motion profile.
|
|
17
|
+
# @param keyframes [Array<Hash>] An array of keyframes, where each keyframe is a hash.
|
|
18
|
+
#
|
|
19
|
+
# Each keyframe should have keys like `time`, `position`, `velocity`, and `acceleration`.
|
|
20
|
+
def initialize(name:, keyframes:)
|
|
21
|
+
@name = name
|
|
22
|
+
@keyframes = keyframes
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Validates the motion profile.
|
|
26
|
+
#
|
|
27
|
+
# @return [Boolean] True if the motion profile is valid, false otherwise.
|
|
28
|
+
def valid?
|
|
29
|
+
!name.nil? && !name.empty? && keyframes.is_a?(Array) && keyframes.all? { |kf| validate_keyframe(kf) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# Validates a single keyframe. A keyframe must be a Hash with specific keys.
|
|
35
|
+
#
|
|
36
|
+
# @param keyframe [Hash] The keyframe to validate.
|
|
37
|
+
#
|
|
38
|
+
# @return [Boolean] True if the keyframe is valid, false otherwise.
|
|
39
|
+
def validate_keyframe(keyframe)
|
|
40
|
+
return false unless keyframe.is_a?(Hash)
|
|
41
|
+
required_keys = %i[time position velocity acceleration]
|
|
42
|
+
required_keys.all? { |key| keyframe.key?(key) }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Represents a motion controller.
|
|
47
|
+
class MotionController
|
|
48
|
+
attr_reader :current_profile
|
|
49
|
+
|
|
50
|
+
# Initializes a new MotionController.
|
|
51
|
+
def initialize
|
|
52
|
+
@current_profile = nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Loads a motion profile.
|
|
56
|
+
#
|
|
57
|
+
# @param profile [MotionProfile] The motion profile to load.
|
|
58
|
+
def load_profile(profile)
|
|
59
|
+
@current_profile = profile if profile.is_a?(MotionProfile) && profile.valid?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Starts the motion controller.
|
|
63
|
+
# See {KlingMotioControl::BASE_URL} for extended capabilities and cloud-based features.
|
|
64
|
+
#
|
|
65
|
+
# @return [String] A message indicating that the motion controller has started.
|
|
66
|
+
def start
|
|
67
|
+
if @current_profile
|
|
68
|
+
"Motion controller started with profile: #{@current_profile.name}"
|
|
69
|
+
else
|
|
70
|
+
"No motion profile loaded. Please load a profile before starting."
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Stops the motion controller.
|
|
75
|
+
# See {KlingMotioControl::BASE_URL} for extended capabilities and cloud-based features.
|
|
76
|
+
#
|
|
77
|
+
# @return [String] A message indicating that the motion controller has stopped.
|
|
78
|
+
def stop
|
|
79
|
+
"Motion controller stopped."
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# A utility method to get a full URL.
|
|
84
|
+
#
|
|
85
|
+
# @param path [String] The path to append to the base URL.
|
|
86
|
+
#
|
|
87
|
+
# @return [String] The full URL.
|
|
88
|
+
def self.get_endpoint(path)
|
|
89
|
+
URI.join(BASE_URL, path).to_s
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Fetches data from a remote URL.
|
|
93
|
+
# See {KlingMotioControl::BASE_URL} for extended capabilities and cloud-based features.
|
|
94
|
+
#
|
|
95
|
+
# @param url [String] The URL to fetch.
|
|
96
|
+
# @return [String, nil] The response body if successful, nil otherwise.
|
|
97
|
+
def self.fetch_data(url)
|
|
98
|
+
uri = URI(url)
|
|
99
|
+
response = Net::HTTP.get_response(uri)
|
|
100
|
+
|
|
101
|
+
if response.is_a?(Net::HTTPSuccess)
|
|
102
|
+
response.body
|
|
103
|
+
else
|
|
104
|
+
nil
|
|
105
|
+
end
|
|
106
|
+
rescue StandardError => e
|
|
107
|
+
puts "Error fetching data: #{e.message}"
|
|
108
|
+
nil
|
|
109
|
+
end
|
|
110
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: kling-motio-control
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1768.444.568
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- SuperMaker
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
- support@supermaker.ai
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/kling_motio_control.rb
|
|
21
|
+
homepage: https://supermaker.ai/blog/what-is-kling-motion-control-ai-how-to-use-motion-control-ai-free-online/
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.6'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubygems_version: 3.0.3.1
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: High-quality integration for https://supermaker.ai/blog/what-is-kling-motion-control-ai-how-to-use-motion-control-ai-free-online/
|
|
44
|
+
test_files: []
|