Muscat app — Automatically finds our robots on the same network so you can connect and control them right away. PC · Mac · MobileGet the app
Muscat PK
Log in
Development

UI SDK

@rainbow-robotics/plugin-ui

importContents
.../plugin-ui/reactDesign components (RBLabelButton, RBSlider, RBSwitch, RBTextInput, RBSelectBox …)
.../plugin-ui/sdkuseRb(), useRbFormData(), useRbSave()
rb methodBehavior
rb.pub(topic, payload)Fire and forget
rb.sub(topic, handler)Subscribe
await rb.action(topic, payload)Request and wait for the response (10 s)
rb.toast · alert · confirm · promptMuscat notifications · dialogs

Component list: muscat-pk storybook

Example — call the backend from a button

ui/content.tsx
import { useState } from "react";
import { RBLabelButton, RBSlider }
  from "@rainbow-robotics/plugin-ui/react";
import { useRb } from "@rainbow-robotics/plugin-ui/sdk";

export default function App() {
  const rb = useRb();
  const [width, setWidth] = useState(20);

  const grip = async () => {
    await rb.action("grip", { width });
    rb.toast({ type: "success", message: `grip ${width}mm` });
  };

  return (<>
    <RBSlider value={[width]} min={0} max={100}
      onValueChange={(v) => setWidth(v[0] ?? 0)} />
    <RBLabelButton onClick={grip}>Grip</RBLabelButton>
  </>);
}
UI of the muscat-pk new default template
Actual screen (muscat-pk new default template)

Notifications · dialogs

rb.toast screen
rb.toast
rb.alert screen
rb.alert
rb.confirm screen
rb.confirm
rb.prompt screen
rb.prompt
rb.toast({ type: "success", message: "grip 24mm" });
// type: info | success | warning | caution | danger

await rb.alert({ title: "Notice", message: "Done" });

const ok = await rb.confirm({ message: "Send it?",
  buttonText: { yes: "Send", no: "Cancel" } });     // → true | false

const name = await rb.prompt({
  message: "Enter a name", placeholder: "target" });  // → string | undefined