Skip to content

Connect

connectRobot(req) -> {Promise}

Connect the robot

Parameters

Name Data Type Description
req ReqConnect connection parameters

Return value Promise

none

Example

connectRobot
TypeScript
  // Typically used to connect to the robot over WAN
  ...
  if (initSuccess) {
    try {
      const res = await axRobot.connectRobot({
          robotId: "<robotId>"
      });

      console.log("connect success: " + res.robotId);
      // do something
      } catch(err) {
      console.log(err.errText);
    }
  }
TypeScript
  // Typically used to connect to the robot over LAN
  ...
  if (initSuccess) {
    try {
      const res = await axRobot.connectRobot({
          robotIp: "<robotIp>"
      });

      console.log("connect success: " + robotIp);
      // do something
      } catch(err) {
      console.log(err.errText);
    }
  }

ReqConnect

TypeScript
1
2
3
4
5
6
...
ReqConnect {
    robotId?: string, // Robot SN: typically used for WAN connection; choose either robotId or robotIp
    robotIp?: string, // Robot IP: typically used for LAN connection; choose either robotId or robotIp
    timeOut?: number // Optional, connection timeout in seconds
}

Example

ReqConnect
Note

The robot connects to the internet via 4G or wifi. robotId is a required field.

TypeScript
// Initialize robot operation instance
...
this.axRobot = new AXRobot(
    "<appId>", 
    "<appSecret>",
    AppMode.WAN_APP) // dev

try {
    let isOk = await this.axRobot.init()
    //console.log(isOk)
    if (isOk === true) {
        let res = await this.axRobot.connectRobot({
            robotId: '81822013xxxx', // Robot SN
        })
    }
} catch (e) {
    console.log(e)
}
Note

The upper computer connects to the robot chassis via a wired connection.

TypeScript
// Initialize robot operation instance
...
this.axRobot = new AXRobot(
    "<appId>", 
    "<appSecret>",
    AppMode.LOCAL_APP) // dev

try {
    let isOk = await this.axRobot.init()
    //console.log(isOk)
    if (isOk === true) {
        let res = await this.axRobot.connectRobot({})
    }
} catch (e) {
    console.log(e)
}
Note

Connect to the robot via the robot chassis WiFi AP.

TypeScript
// Initialize robot operation instance
...
this.axRobot = new AXRobot(
    "<appId>", 
    "<appSecret>",
    AppMode.LAN_APP) // dev

try {
    let isOk = await this.axRobot.init()
    //console.log(isOk)
    if (isOk === true) {
        let res = await this.axRobot.connectRobot({})
    }
} catch (e) {
    console.log(e)
}
Note

The robot chassis connects to the local network. Replace with the actual IP of the robot chassis on the local network.

TypeScript
// Initialize robot operation instance
...
this.axRobot = new AXRobot(
    "<appId>", 
    "<appSecret>",
    AppMode.LAN_APP) // dev

try {
    let isOk = await this.axRobot.init()
    //console.log(isOk)
    if (isOk === true) {
        let res = await this.axRobot.connectRobot({
            robotIp: '192.168.0.122' // Actual IP on the local network
        })
    }
} catch (e) {
    console.log(e)
}