Skip to content

Commit b88514f

Browse files
Simplify spawning, add default config
1 parent 2a77696 commit b88514f

File tree

4 files changed

+105
-8
lines changed

4 files changed

+105
-8
lines changed

flowstate/aic_flowstate_services/taskboard_spawning_service/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ install(
4040
RUNTIME DESTINATION lib/${PROJECT_NAME}
4141
)
4242

43+
install(DIRECTORY config
44+
DESTINATION share/${PROJECT_NAME}
45+
)
46+
4347
#===============================================================================
4448
# Generate Solution Manifest
4549
intrinsic_sdk_generate_service_manifest(
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Sample configuration for Taskboard Spawner
2+
scene:
3+
task_board:
4+
# NIC Rails (Translate along X axis)
5+
nic_rail_0:
6+
entity_present: true
7+
entity_name: "nic_rail_0_instance"
8+
entity_pose:
9+
translation: 0.0 # Meters
10+
roll: 0.0
11+
pitch: 0.0
12+
yaw: 0.0
13+
nic_rail_1:
14+
entity_present: false # Will not be spawned
15+
nic_rail_2:
16+
entity_present: false
17+
18+
# SC Rails (Translate along X axis)
19+
sc_rail_0:
20+
entity_present: true
21+
entity_name: "sc_rail_0_instance"
22+
entity_pose:
23+
translation: 0.01
24+
roll: 0.0
25+
pitch: 0.0
26+
yaw: 0.0
27+
28+
# Mount Rails (Translate along Y axis)
29+
lc_mount_rail_0:
30+
entity_present: true
31+
entity_name: "lc_mount_rail_0_instance"
32+
entity_pose:
33+
translation: -0.02
34+
roll: 0.0
35+
pitch: 0.0
36+
yaw: 0.0
37+
38+
sfp_mount_rail_0:
39+
entity_present: false
40+
sc_mount_rail_0:
41+
entity_present: false
42+
43+
lc_mount_rail_1:
44+
entity_present: true
45+
entity_name: "lc_mount_rail_1_instance"
46+
entity_pose:
47+
translation: 0.02
48+
roll: 0.0
49+
pitch: 0.0
50+
yaw: 0.0

flowstate/aic_flowstate_services/taskboard_spawning_service/default_config.pbtxt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# proto-message: TaskboardSpawningServiceConfig
33
[type.googleapis.com/intrinsic.TaskboardSpawningServiceConfig] {
44
# Standard YAML file path used instead of proto parameters
5-
# This is a placeholder config to satisfy Solution Manifest requirements
5+
config_file_path: "/opt/ros/overlay/install/share/taskboard_spawning_service/config/sample_config.yaml"
66
}

flowstate/aic_flowstate_services/taskboard_spawning_service/src/taskboard_spawner_node.cpp

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,19 @@ void TaskboardSpawnerNode::SpawnFromConfig(const std::string& config_path) {
7474
const auto& components = logic_.GetComponents();
7575
for (const auto& [key, cfg] : components) {
7676
if (cfg.entity_present) {
77+
std::string asset_name = key;
78+
// Map config keys to actual asset names in the catalog
79+
if (key.find("nic_rail") != std::string::npos) {
80+
asset_name = "nic_card_mount";
81+
} else if (key.find("sc_rail") != std::string::npos) {
82+
asset_name = "sc_port";
83+
}
84+
7785
double x, y, z, qx, qy, qz, qw;
7886
if (logic_.ComputeRelativePose(key, x, y, z, qx, qy, qz, qw)) {
79-
RCLCPP_INFO(this->get_logger(), "COMPUTED RELATIVE POSE [%s]: (x=%f, y=%f, z=%f, qx=%f, qy=%f, qz=%f, qw=%f)",
80-
key.c_str(), x, y, z, qx, qy, qz, qw);
81-
SpawnComponent(key, cfg.entity_name, x, y, z, qx, qy, qz, qw, true, "task_board_base");
87+
RCLCPP_INFO(this->get_logger(), "COMPUTED RELATIVE POSE [%s] -> Asset: %s: (x=%f, y=%f, z=%f, qx=%f, qy=%f, qz=%f, qw=%f)",
88+
key.c_str(), asset_name.c_str(), x, y, z, qx, qy, qz, qw);
89+
SpawnComponent(asset_name, cfg.entity_name, x, y, z, qx, qy, qz, qw, true, "task_board_base");
8290
}
8391
}
8492
}
@@ -183,10 +191,45 @@ void TaskboardSpawnerNode::HandleUpdateComponent(
183191

184192
double x, y, z, qx, qy, qz, qw;
185193
if (logic_.ComputeRelativePose(request->component_name, x, y, z, qx, qy, qz, qw)) {
186-
187-
// Call UpdateTransform gRPC or similar
188-
response->success = true;
189-
response->message = "Successfully updated transform (Placeholder)";
194+
auto it = logic_.GetComponents().find(request->component_name);
195+
if (it == logic_.GetComponents().end()) {
196+
response->success = false;
197+
response->message = "Component not found in config";
198+
return;
199+
}
200+
std::string entity_name = it->second.entity_name;
201+
202+
intrinsic_proto::world::UpdateTransformRequest update_req;
203+
update_req.set_world_id("init_world");
204+
205+
auto* node_a = update_req.mutable_node_a();
206+
node_a->mutable_by_name()->mutable_object()->set_object_name("task_board_base");
207+
208+
auto* node_b = update_req.mutable_node_b();
209+
node_b->mutable_by_name()->mutable_object()->set_object_name(entity_name);
210+
211+
auto* pose = update_req.mutable_a_t_b();
212+
pose->mutable_position()->set_x(x);
213+
pose->mutable_position()->set_y(y);
214+
pose->mutable_position()->set_z(z);
215+
pose->mutable_orientation()->set_x(qx);
216+
pose->mutable_orientation()->set_y(qy);
217+
pose->mutable_orientation()->set_z(qz);
218+
pose->mutable_orientation()->set_w(qw);
219+
220+
update_req.set_view(intrinsic_proto::world::ObjectView::BASIC);
221+
222+
intrinsic_proto::world::UpdateTransformResponse update_resp;
223+
grpc::ClientContext context;
224+
grpc::Status status = object_world_stub_->UpdateTransform(&context, update_req, &update_resp);
225+
226+
if (status.ok()) {
227+
response->success = true;
228+
response->message = "Successfully updated transform";
229+
} else {
230+
response->success = false;
231+
response->message = "Failed to update transform: " + status.error_message();
232+
}
190233
} else {
191234
response->success = false;
192235
response->message = "Failed to compute relative pose";

0 commit comments

Comments
 (0)