Skip to content

Commit 34acb87

Browse files
committed
add namespace in topic/ service name
1 parent 1d6ef2b commit 34acb87

File tree

7 files changed

+79
-32
lines changed

7 files changed

+79
-32
lines changed

app/gamepad/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ export default function VirtualGamepad() {
6464
// Initialize cmd_vel topic
6565
cmdVelRef.current = new ROSLIB.Topic({
6666
ros: ros,
67-
name: "/cmd_vel",
67+
name: `/${robotNamespace}/cmd_vel`,
6868
messageType: "geometry_msgs/Twist",
6969
});
7070

7171
// Initialize kick topic
7272
kickRef.current = new ROSLIB.Topic({
7373
ros: ros,
74-
name: "/kick",
74+
name: `/${robotNamespace}/kick`,
7575
messageType: "std_msgs/Bool",
7676
});
7777
}, [isConnected, getRos]);

app/head_module/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function HeadModule() {
4040
const ros = getRos();
4141
const paramClient = new ROSLIB.Service({
4242
ros: ros,
43-
name: "/head_controller/get_parameters",
43+
name: `/${robotNamespace}/head_controller/get_parameters`,
4444
serviceType: "rcl_interfaces/srv/GetParameters",
4545
});
4646
const request = new ROSLIB.ServiceRequest({
@@ -78,7 +78,7 @@ export default function HeadModule() {
7878
const ros = getRos();
7979
const paramClient = new ROSLIB.Service({
8080
ros: ros,
81-
name: "/head_controller/set_parameters",
81+
name: `/${robotNamespace}/head_controller/set_parameters`,
8282
serviceType: "rcl_interfaces/srv/SetParameters",
8383
});
8484
const parameter = new ROSLIB.Message({
@@ -106,7 +106,7 @@ export default function HeadModule() {
106106
const ros = getRos();
107107
const paramClient = new ROSLIB.Service({
108108
ros: ros,
109-
name: "/head_controller/set_parameters",
109+
name: `/${robotNamespace}/head_controller/set_parameters`,
110110
serviceType: "rcl_interfaces/srv/SetParameters",
111111
});
112112
const parameter = new ROSLIB.Message({

app/map/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function RobotMapWithHeading() {
4242
const ros = getRos();
4343
const odom = new ROSLIB.Topic({
4444
ros: ros,
45-
name: "/walk_engine_odometry",
45+
name: `/${robotNamespace}/walk_engine_odometry`,
4646
messageType: "nav_msgs/Odometry",
4747
});
4848

app/tuning/page.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ConnectionManager from "@/components/ConnectionManager";
1313
import { useRos } from "@/contexts/RosContext";
1414

1515
export default function Home() {
16-
const { isConnected, getRos, robotNamespace, connectionStatus, ensureConnection } = useRos();
16+
const { isConnected, getRos, robotNamespace, walkPackage, setWalkPackage, connectionStatus, ensureConnection } = useRos();
1717

1818
const [parameters, setParameters] = useState({});
1919
const [editingParam, setEditingParam] = useState(null);
@@ -360,7 +360,7 @@ export default function Home() {
360360

361361
const paramClient = new ROSLIB.Service({
362362
ros: ros,
363-
name: `${robotNamespace}/get_parameters`,
363+
name: `${robotNamespace}/${walkPackage}/get_parameters`,
364364
serviceType: "rcl_interfaces/srv/GetParameters",
365365
});
366366

@@ -386,7 +386,7 @@ export default function Home() {
386386
}
387387
);
388388
},
389-
[isConnected, robotNamespace, getRos]
389+
[isConnected, robotNamespace, walkPackage, getRos]
390390
);
391391

392392
const getParameterDescriptions = useCallback(
@@ -398,7 +398,7 @@ export default function Home() {
398398

399399
const paramClient = new ROSLIB.Service({
400400
ros: ros,
401-
name: `${robotNamespace}/describe_parameters`,
401+
name: `${robotNamespace}/${walkPackage}/describe_parameters`,
402402
serviceType: "rcl_interfaces/srv/DescribeParameters",
403403
});
404404

@@ -422,7 +422,7 @@ export default function Home() {
422422
}
423423
);
424424
},
425-
[isConnected, robotNamespace, getRos]
425+
[isConnected, robotNamespace, walkPackage, getRos]
426426
);
427427

428428
// Function to fetch all parameters
@@ -435,7 +435,7 @@ export default function Home() {
435435

436436
const paramClient = new ROSLIB.Service({
437437
ros: ros,
438-
name: `${robotNamespace}/list_parameters`,
438+
name: `${robotNamespace}/${walkPackage}/list_parameters`,
439439
serviceType: "rcl_interfaces/srv/ListParameters",
440440
});
441441

@@ -455,7 +455,7 @@ export default function Home() {
455455
setShowModal(true);
456456
}
457457
);
458-
}, [isConnected, robotNamespace, getRos, getParameterValues, getParameterDescriptions]);
458+
}, [isConnected, robotNamespace, walkPackage, getRos, getParameterValues, getParameterDescriptions]);
459459

460460
const fetchROSParameters = useCallback(() => {
461461
const ros = getRos();
@@ -520,7 +520,7 @@ export default function Home() {
520520

521521
const paramClient = new ROSLIB.Service({
522522
ros: ros,
523-
name: `${robotNamespace}/set_parameters`,
523+
name: `${robotNamespace}/${walkPackage}/set_parameters`,
524524
serviceType: "rcl_interfaces/srv/SetParameters",
525525
});
526526

@@ -638,7 +638,7 @@ export default function Home() {
638638
// First publish the parameter list to save
639639
const paramListTopic = new ROSLIB.Topic({
640640
ros: ros,
641-
name: "/param_manager/params_to_save",
641+
name: `/${robotNamespace}/param_manager/params_to_save`,
642642
messageType: "std_msgs/String",
643643
});
644644

@@ -648,7 +648,7 @@ export default function Home() {
648648
setTimeout(() => {
649649
const paramClient = new ROSLIB.Service({
650650
ros: ros,
651-
name: "/param_manager/save_parameters",
651+
name: `/${robotNamespace}/param_manager/save_parameters`,
652652
serviceType: "std_srvs/srv/Trigger",
653653
});
654654

@@ -833,12 +833,12 @@ export default function Home() {
833833
}
834834

835835
console.log("Sending cmd_vel", { x, y, z });
836-
addLog(`Publishing to /cmd_vel topic`, "websocket");
836+
addLog(`Publishing to /${robotNamespace}/cmd_vel topic`, "websocket");
837837

838838
const ros = getRos();
839839
const cmdVel = new ROSLIB.Topic({
840840
ros: ros,
841-
name: "/cmd_vel",
841+
name: `/${robotNamespace}/cmd_vel`,
842842
messageType: "geometry_msgs/Twist",
843843
});
844844

@@ -856,7 +856,7 @@ export default function Home() {
856856
});
857857

858858
cmdVel.publish(twist);
859-
addLog(`Published twist message to /cmd_vel`, "success", {
859+
addLog(`Published twist message to /${robotNamespace}/cmd_vel`, "success", {
860860
linear: { x, y, z: 0.0 },
861861
angular: { x: 0.0, y: 0.0, z },
862862
});
@@ -879,12 +879,12 @@ export default function Home() {
879879
return;
880880
}
881881

882-
addLog(`Publishing stop command to /cmd_vel`, "websocket");
882+
addLog(`Publishing stop command to /${robotNamespace}/cmd_vel`, "websocket");
883883

884884
const ros = getRos();
885885
const cmdVel = new ROSLIB.Topic({
886886
ros: ros,
887-
name: "/cmd_vel",
887+
name: `/${robotNamespace}/cmd_vel`,
888888
messageType: "geometry_msgs/Twist",
889889
});
890890

@@ -902,7 +902,7 @@ export default function Home() {
902902
});
903903

904904
cmdVel.publish(twist);
905-
addLog(`Published stop message to /cmd_vel`, "success", {
905+
addLog(`Published stop message to /${robotNamespace}/cmd_vel`, "success", {
906906
linear: { x: 0.0, y: 0.0, z: 0.0 },
907907
angular: { x: -1.0, y: 0.0, z: 0.0 },
908908
});
@@ -929,12 +929,12 @@ export default function Home() {
929929
// handlePlayRobot(0, 0, 0);
930930

931931
// Publish kick command to the kick topic
932-
addLog(`Publishing kick command to /kick topic`, "websocket");
932+
addLog(`Publishing kick command to /${robotNamespace}/kick topic`, "websocket");
933933

934934
const ros = getRos();
935935
const kickTopic = new ROSLIB.Topic({
936936
ros: ros,
937-
name: "/kick",
937+
name: `/${robotNamespace}/kick`,
938938
messageType: "std_msgs/msg/Bool",
939939
});
940940

@@ -943,7 +943,7 @@ export default function Home() {
943943
});
944944

945945
kickTopic.publish(kick);
946-
addLog(`Published kick message to /kick`, "success", { data: true });
946+
addLog(`Published kick message to /${robotNamespace}/kick`, "success", { data: true });
947947

948948
// Wait for the kick action to complete before sending stop command
949949
// This prevents the stop command from interfering with the kick

components/ConnectionManager.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import React, { useState, useEffect } from "react";
33
export default function ConnectionManager({
44
currentUri,
55
currentNamespace,
6+
currentWalkPackage,
67
onApply,
78
onCancel,
89
}) {
910
const [connectionUri, setConnectionUri] = useState(currentUri);
1011
const [robotNamespace, setRobotNamespace] = useState(currentNamespace);
12+
const [walkPackage, setWalkPackage] = useState(currentWalkPackage || 'quintic_walk');
1113
const [savedConnections, setSavedConnections] = useState([]);
1214

1315
// Load saved connections from localStorage
@@ -25,7 +27,7 @@ export default function ConnectionManager({
2527
const saveConnection = () => {
2628
// Check if this connection already exists
2729
const existingIndex = savedConnections.findIndex(
28-
(conn) => conn.uri === connectionUri && conn.namespace === robotNamespace
30+
(conn) => conn.uri === connectionUri && conn.namespace === robotNamespace && conn.walkPackage === walkPackage
2931
);
3032

3133
if (existingIndex >= 0) {
@@ -36,6 +38,7 @@ export default function ConnectionManager({
3638
id: Date.now(),
3739
uri: connectionUri,
3840
namespace: robotNamespace,
41+
walkPackage: walkPackage,
3942
name: `Connection ${savedConnections.length + 1}`,
4043
};
4144

@@ -53,11 +56,14 @@ export default function ConnectionManager({
5356
const loadConnection = (connection) => {
5457
setConnectionUri(connection.uri);
5558
setRobotNamespace(connection.namespace);
59+
if (connection.walkPackage) {
60+
setWalkPackage(connection.walkPackage);
61+
}
5662
};
5763

5864
const handleSubmit = (e) => {
5965
e.preventDefault();
60-
onApply(connectionUri, robotNamespace);
66+
onApply(connectionUri, robotNamespace, walkPackage);
6167
};
6268

6369
return (
@@ -84,7 +90,7 @@ export default function ConnectionManager({
8490
</p>
8591
</div>
8692

87-
<div className="mb-8">
93+
<div className="mb-6">
8894
<label
8995
className="block text-gray-700 text-sm font-semibold mb-3"
9096
htmlFor="robotNamespace"
@@ -105,6 +111,27 @@ export default function ConnectionManager({
105111
</p>
106112
</div>
107113

114+
<div className="mb-8">
115+
<label
116+
className="block text-gray-700 text-sm font-semibold mb-3"
117+
htmlFor="walkPackage"
118+
>
119+
Walk Package
120+
</label>
121+
<input
122+
id="walkPackage"
123+
type="text"
124+
value={walkPackage}
125+
onChange={(e) => setWalkPackage(e.target.value)}
126+
className="w-full p-4 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200"
127+
placeholder="quintic_walk"
128+
required
129+
/>
130+
<p className="text-xs text-gray-600 mt-2 bg-gray-50 border border-gray-200 rounded-lg p-2">
131+
💡 ROS package name for walking parameters (e.g., quintic_walk)
132+
</p>
133+
</div>
134+
108135
<div className="flex justify-between mb-6">
109136
<button
110137
type="button"
@@ -176,9 +203,12 @@ export default function ConnectionManager({
176203
<div className="text-xs text-blue-700 font-mono bg-blue-50 px-2 py-1 rounded border border-blue-200 mb-1">
177204
{connection.uri}
178205
</div>
179-
<div className="text-xs text-purple-700 font-mono bg-purple-50 px-2 py-1 rounded border border-purple-200">
206+
<div className="text-xs text-purple-700 font-mono bg-purple-50 px-2 py-1 rounded border border-purple-200 mb-1">
180207
{connection.namespace}
181208
</div>
209+
<div className="text-xs text-green-700 font-mono bg-green-50 px-2 py-1 rounded border border-green-200">
210+
{connection.walkPackage || 'quintic_walk'}
211+
</div>
182212
</div>
183213
<div className="flex flex-col gap-2 ml-4">
184214
<button

components/ConnectionStatusBar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default function ConnectionStatusBar({ showFullControls = false }) {
1010
isConnected,
1111
connectionUri,
1212
robotNamespace,
13+
walkPackage,
1314
connectionStatus,
1415
isConnecting,
1516
lastError,
@@ -22,8 +23,8 @@ export default function ConnectionStatusBar({ showFullControls = false }) {
2223

2324
const [showConnectionManager, setShowConnectionManager] = useState(false);
2425

25-
const handleConnectionApply = (uri, namespace) => {
26-
updateConnection(uri, namespace);
26+
const handleConnectionApply = (uri, namespace, walkPkg) => {
27+
updateConnection(uri, namespace, walkPkg);
2728
setShowConnectionManager(false);
2829
};
2930

@@ -273,6 +274,7 @@ export default function ConnectionStatusBar({ showFullControls = false }) {
273274
<ConnectionManager
274275
currentUri={connectionUri}
275276
currentNamespace={robotNamespace}
277+
currentWalkPackage={walkPackage}
276278
onApply={handleConnectionApply}
277279
onCancel={() => setShowConnectionManager(false)}
278280
/>

0 commit comments

Comments
 (0)