@holoscript/robotics-plugin 1.0.0 → 2.0.1

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.
@@ -1,199 +0,0 @@
1
- /**
2
- * Complete Robotics Example: 2-DOF Robot Arm
3
- * Demonstrates compile-time (USD/URDF) + runtime (ROS2/VR control)
4
- *
5
- * Features:
6
- * - @ros_node: ROS2 runtime integration
7
- * - @gazebo_sim: Gazebo physics simulation
8
- * - @urdf_export: Export to URDF format
9
- * - @robot_joint: Articulated joints with limits
10
- * - VR teleoperation: Control robot with VR controllers
11
- */
12
-
13
- scene "Robotics Lab" {
14
- background: "#1a1a2e";
15
- lighting: "industrial";
16
- camera_position: [2, 1.5, 3];
17
- }
18
-
19
- // 2-DOF Robot Arm with ROS2 integration
20
- object "TwoLinkArm" @ros_node @gazebo_sim @urdf_export {
21
- // ROS2 configuration
22
- ros_bridge_url: "ws://localhost:9090",
23
- namespace: "/robot_arm",
24
- tf_prefix: "arm_",
25
-
26
- // Gazebo simulation
27
- gazebo_world: "empty.world",
28
- physics_engine: "ode",
29
- gravity: [0, 0, -9.81],
30
-
31
- // Robot structure
32
- links: [
33
- {
34
- name: "base_link",
35
- visual: {
36
- geometry: "cylinder",
37
- dimensions: [0.1, 0.05],
38
- material: "steel",
39
- },
40
- collision: { geometry: "cylinder", dimensions: [0.1, 0.05] },
41
- inertial: { mass: 1.0, inertia: [0.01, 0.01, 0.01, 0, 0, 0] },
42
- position: [0, 0, 0],
43
- },
44
- {
45
- name: "link1",
46
- visual: {
47
- geometry: "box",
48
- dimensions: [0.05, 0.05, 0.5],
49
- material: "aluminum",
50
- },
51
- collision: { geometry: "box", dimensions: [0.05, 0.05, 0.5] },
52
- inertial: { mass: 0.5, inertia: [0.01, 0.01, 0.001, 0, 0, 0] },
53
- },
54
- {
55
- name: "link2",
56
- visual: {
57
- geometry: "box",
58
- dimensions: [0.05, 0.05, 0.4],
59
- material: "carbon_fiber",
60
- },
61
- collision: { geometry: "box", dimensions: [0.05, 0.05, 0.4] },
62
- inertial: { mass: 0.3, inertia: [0.005, 0.005, 0.001, 0, 0, 0] },
63
- },
64
- ],
65
-
66
- // Joints with actuators
67
- joints: [
68
- {
69
- name: "shoulder_joint",
70
- type: "revolute",
71
- parent: "base_link",
72
- child: "link1",
73
- axis: [0, 0, 1],
74
- origin: { position: [0, 0, 0.05], rotation: [0, 0, 0] },
75
- limits: { lower: -3.14, upper: 3.14, effort: 10.0, velocity: 2.0 },
76
- actuator: {
77
- type: "position",
78
- kp: 100.0,
79
- kd: 10.0,
80
- },
81
- },
82
- {
83
- name: "elbow_joint",
84
- type: "revolute",
85
- parent: "link1",
86
- child: "link2",
87
- axis: [0, 1, 0],
88
- origin: { position: [0, 0, 0.5], rotation: [0, 0, 0] },
89
- limits: { lower: -2.0, upper: 2.0, effort: 5.0, velocity: 1.5 },
90
- actuator: {
91
- type: "position",
92
- kp: 50.0,
93
- kd: 5.0,
94
- },
95
- },
96
- ],
97
-
98
- // VR teleoperation
99
- vr_control: {
100
- enabled: true,
101
- controller_mapping: {
102
- left_hand: "shoulder_joint", // Left VR controller → shoulder
103
- right_hand: "elbow_joint", // Right VR controller → elbow
104
- },
105
- force_feedback: true, // Haptic feedback when robot hits limits
106
- inverse_kinematics: true, // IK solver for end-effector control
107
- },
108
-
109
- // Digital twin sync
110
- twin_sync: {
111
- enabled: true,
112
- sync_rate: 30, // 30 Hz (sync every 33ms)
113
- bidirectional: true, // Real robot ↔ VR twin
114
- sensors: [
115
- { type: "joint_states", topic: "/joint_states" },
116
- { type: "tf", topic: "/tf" },
117
- ],
118
- },
119
-
120
- // Export options
121
- export: {
122
- urdf: "build/two_link_arm.urdf",
123
- sdf: "build/two_link_arm.sdf",
124
- usd: "build/two_link_arm.usd", // For NVIDIA Isaac Sim
125
- mjcf: "build/two_link_arm.xml", // For MuJoCo
126
- },
127
- }
128
-
129
- // Example 2: Mobile robot (differential drive)
130
- object "MobileBot" @ros_node @gazebo_sim {
131
- ros_bridge_url: "ws://localhost:9090",
132
- namespace: "/mobile_bot",
133
-
134
- // Chassis
135
- links: [
136
- {
137
- name: "chassis",
138
- visual: { geometry: "box", dimensions: [0.4, 0.3, 0.1], material: "plastic" },
139
- inertial: { mass: 5.0 },
140
- },
141
- {
142
- name: "left_wheel",
143
- visual: { geometry: "cylinder", dimensions: [0.1, 0.05], material: "rubber" },
144
- inertial: { mass: 0.5 },
145
- },
146
- {
147
- name: "right_wheel",
148
- visual: { geometry: "cylinder", dimensions: [0.1, 0.05], material: "rubber" },
149
- inertial: { mass: 0.5 },
150
- },
151
- ],
152
-
153
- joints: [
154
- {
155
- name: "left_wheel_joint",
156
- type: "continuous",
157
- parent: "chassis",
158
- child: "left_wheel",
159
- axis: [0, 1, 0],
160
- actuator: { type: "velocity" },
161
- },
162
- {
163
- name: "right_wheel_joint",
164
- type: "continuous",
165
- parent: "chassis",
166
- child: "right_wheel",
167
- axis: [0, 1, 0],
168
- actuator: { type: "velocity" },
169
- },
170
- ],
171
-
172
- // Differential drive controller
173
- drive_controller: {
174
- type: "diff_drive",
175
- wheel_separation: 0.3,
176
- wheel_radius: 0.1,
177
- max_velocity: 1.0, // m/s
178
- max_angular_velocity: 2.0, // rad/s
179
- },
180
-
181
- // Sensors
182
- sensors: [
183
- {
184
- name: "lidar",
185
- type: "laser",
186
- update_rate: 10,
187
- topic: "/scan",
188
- range: { min: 0.1, max: 10.0 },
189
- fov: 360,
190
- },
191
- {
192
- name: "camera",
193
- type: "camera",
194
- update_rate: 30,
195
- topic: "/camera/image_raw",
196
- resolution: [640, 480],
197
- },
198
- ],
199
- }
@@ -1,77 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- ROS2 Bridge for HoloScript Robotics Plugin
4
- Runtime integration with ROS2 via rosbridge_server
5
-
6
- Requirements:
7
- pip install roslibpy
8
-
9
- Usage:
10
- from ros2_bridge import ROS2Bridge
11
-
12
- bridge = ROS2Bridge('ws://localhost:9090')
13
- bridge.connect()
14
- bridge.publish_joint_command('/joint_states', {...})
15
- """
16
-
17
- import sys
18
- import json
19
- from typing import Dict, Any, List
20
- import roslibpy
21
-
22
- class ROS2Bridge:
23
- """ROS2 runtime bridge for HoloScript robotics"""
24
-
25
- def __init__(self, ros_bridge_url: str = 'ws://localhost:9090'):
26
- self.ros_bridge_url = ros_bridge_url
27
- self.client = None
28
- self.subscribers = {}
29
- self.publishers = {}
30
-
31
- def connect(self) -> Dict[str, Any]:
32
- """Connect to ROS2 via rosbridge_server"""
33
- try:
34
- self.client = roslibpy.Ros(host=self.ros_bridge_url.replace('ws://', '').split(':')[0],
35
- port=int(self.ros_bridge_url.split(':')[-1]))
36
- self.client.run()
37
-
38
- return {
39
- 'status': 'success',
40
- 'connected': self.client.is_connected,
41
- 'url': self.ros_bridge_url,
42
- }
43
- except Exception as e:
44
- return {
45
- 'status': 'failed',
46
- 'error': str(e),
47
- }
48
-
49
- def publish_joint_command(self, topic: str, joint_positions: Dict[str, float]) -> Dict[str, Any]:
50
- """Publish joint command to ROS2 topic"""
51
- try:
52
- if topic not in self.publishers:
53
- self.publishers[topic] = roslibpy.Topic(self.client, topic, 'sensor_msgs/JointState')
54
-
55
- msg = {
56
- 'name': list(joint_positions.keys()),
57
- 'position': list(joint_positions.values()),
58
- }
59
-
60
- self.publishers[topic].publish(roslibpy.Message(msg))
61
-
62
- return {'status': 'success', 'topic': topic}
63
- except Exception as e:
64
- return {'status': 'failed', 'error': str(e)}
65
-
66
- def get_status(self) -> Dict[str, Any]:
67
- """Get bridge status"""
68
- return {
69
- 'connected': self.client.is_connected if self.client else False,
70
- 'url': self.ros_bridge_url,
71
- 'version': '1.0.0',
72
- }
73
-
74
- if __name__ == '__main__':
75
- bridge = ROS2Bridge()
76
- status = bridge.connect()
77
- print(f"ROS2 Bridge: {status}")