Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/TelemetryGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const TelemetryGraph: React.FC<Props> = ({ topic, label, color = '#4da3ff' }) =>
<option value={30}>30 samples</option>
<option value={60}>60 samples</option>
<option value={120}>120 samples</option>
<option value={240}>240 samples</option>
</select>

<button onClick={downloadPNG}>PNG</button>
Expand Down
59 changes: 59 additions & 0 deletions src/components/panels/ArmControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const ArmControlPanel: React.FC = () => {

const [poseNames, setPoseNames] = useState<string[]>([]);
const [selectedPose, setSelectedPose] = useState('');
const [distance, setDistance] = useState<number | null>(null);
const [distanceStatus, setDistanceStatus] = useState<number | null>(null);
const [response, setResponse] = useState<{ success: boolean; message: string } | null>(null);

const refreshPoseNames = () => {
Expand Down Expand Up @@ -36,6 +38,38 @@ const ArmControlPanel: React.FC = () => {
refreshPoseNames();
}, [ros]);

useEffect(() => {
if (!ros) return;

const distanceTopic = new ROSLIB.Topic({
ros,
name: '/eef_distance',
messageType: 'interfaces/msg/Distance',
});

const handleDistance = (msg: any) => {
setDistance(msg.distance);
setDistanceStatus(msg.status);
};
Comment on lines +50 to +53

distanceTopic.subscribe(handleDistance);

return () => {
distanceTopic.unsubscribe(handleDistance);
};
}, [ros]);

const getDistanceDisplay = () => {
const GRIPPER_OFFSET = 0.18;
if (distance === null) return 'No data';
const distance_with_offset = distance - GRIPPER_OFFSET;

if (distanceStatus === 1) return `Error (${distance_with_offset.toFixed(3)})`;
if (distanceStatus === 2) return `Invalid (${distance_with_offset.toFixed(3)})`;

Comment on lines +62 to +69
return distance_with_offset.toFixed(3);
Comment on lines +65 to +70
};

const handleGo = () => {
if (!ros) {
alert('ROS is not connected');
Expand Down Expand Up @@ -108,6 +142,11 @@ const ArmControlPanel: React.FC = () => {
</select>
</div>

<div className="display-row">
<span>Distance:</span>
<strong>{getDistanceDisplay()}</strong>
</div>

<button onClick={handleGo} disabled={!selectedPose}>
Go
</button>
Expand Down Expand Up @@ -152,6 +191,26 @@ const ArmControlPanel: React.FC = () => {
color: #f1f1f1;
}

.display-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.75rem;
padding: 0.5rem;
border: 1px solid #333;
border-radius: 4px;
background: #2b2b2b;
}

.display-row span {
color: #ccc;
}

.display-row strong {
color: #f1f1f1;
font-weight: 600;
}

button {
background: #0070f3;
color: #f1f1f1;
Expand Down
8 changes: 4 additions & 4 deletions src/components/panels/MosaicDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function buildDefaultLayout(makeTileId: (type: TileType) => TileId): MosaicNode<
},
second: makeTileId('networkHealthMonitor'),
},
second: makeTileId('rosMonitor'),
second: makeTileId('waypointList'),
splitPercentage: 55,
},
splitPercentage: 55,
Expand All @@ -141,11 +141,11 @@ function buildDefaultLayout(makeTileId: (type: TileType) => TileId): MosaicNode<
first: makeTileId('videoControls'),
second: {
direction: 'row',
first: makeTileId('waypointList'),
first: makeTileId('pdbRails'),
second: {
direction: 'row',
first: makeTileId('gasSensor'),
second: makeTileId('goalSetter'),
first: makeTileId('espSensorPanel'),
second: makeTileId('armControlPanel'),
},
splitPercentage: 50,
},
Expand Down
Loading