TheoPierne / spot-sdk-js

Develop applications and payloads for Spot using the unofficial Boston Dynamics Spot Node.js SDK.
Other
4 stars 2 forks source link

Help getting this going #1

Open kaspesla opened 2 years ago

kaspesla commented 2 years ago

Hello Theo, This module looks awesome and we're excited to try this out here at Code & Circuit. I've got it installed but we're running into a grpc error running hello_spot.js. Do you have any ideas what this means? Thanks! -Ken

Pensez à retirer le log du catch
Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
at Object.callErrorFromStatus (/Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
at Object.onReceiveStatus (/Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/client.js:195:52)
at Object.onReceiveStatus (/Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
at Object.onReceiveStatus (/Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
at /Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/call-stream.js:188:78
at processTicksAndRejections (node:internal/process/task_queues:78:11)
for call at
at ServiceClientImpl.makeUnaryRequest (/Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/client.js:163:34)
at ServiceClientImpl.getAuthToken (/Users/ken/Downloads/spot-sdk-js-main 2/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
at /Users/ken/Downloads/spot-sdk-js-main 2/bosdyn-client/common.js:281:9
at new Promise (<anonymous>)
at AuthClient.#make (/Users/ken/Downloads/spot-sdk-js-main 2/bosdyn-client/common.js:278:12)
at AuthClient.call (/Users/ken/Downloads/spot-sdk-js-main 2/bosdyn-client/common.js:332:34)
at AuthClient.auth (/Users/ken/Downloads/spot-sdk-js-main 2/bosdyn-client/auth.js:128:17)
at Robot.authenticate (/Users/ken/Downloads/spot-sdk-js-main 2/bosdyn-client/robot.js:302:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async hello_spot (/Users/ken/Downloads/spot-sdk-js-main 2/examples/hello_spot/hello_spot.js:25:3) {
  code: 13,
details: 'Received RST_STREAM with code 2 triggered by internal client error: Protocol error',
metadata: Metadata { internalRepr: Map(0) {}, options: {} 
}
}
TheoPierne commented 2 years ago

Hello 👋, I'm glad that you have an interest in this module!

Do you have any ideas what this means?

After some research I found out this error can throw when an internal error occurred with the server (spot), in our case I think it's just an error in the code :

https://github.com/TheoPierne/spot-sdk-js/blob/cdde8b9f7de823b2968d00bbb9691bead9fb86ba/bosdyn-client/robot.js#L300

For testing purpose I used ensure_insecure_channel but we would use ensure_secure_channel instead. ensure_insecure_channel don't create the required credentials to communicate with the robot, so basically maybe the connection cannot be correctly established between the client and the robot.

I will patch it soon, if you have any other problem let me know!

P.S.: Sorry if my English isn't good.

TheoPierne commented 2 years ago

It's now fixed (I hope), tell me if this fix the problem!

kaspesla commented 2 years ago

Thanks! I’ll give it a try next week. Regards, Ken

On Oct 15, 2022, at 3:29 PM, Théo Pierné @.***> wrote:

It's now fixed (I hope), tell me if this fix the problem!

— Reply to this email directly, view it on GitHub https://github.com/TheoPierne/spot-sdk-js/issues/1#issuecomment-1279816224, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADS2PHONIQ47QYRJMTL5A3WDMAZTANCNFSM6AAAAAARFKSPXY. You are receiving this because you authored the thread.

kaspesla commented 2 years ago

Unfortunately, it's still getting the same error. At least I think it is the same. Here is the whole output. Let me know if I can help troubleshoot. Best Regards, Ken

ken@lll spot-sdk-js % node examples/hello_spot/hello_spot.js --username spot --password my password -v 192.168.80.3
[2022-10-17 10:46:38] [debug] [SDK]: [SDK] Creating standard Sdk, cert glob: "undefined" 
Pensez à modifier authenticate dans le fichier robot.js
[2022-10-17 10:46:38] [debug] [HelloSpotClient]: [ROBOT] Created channel to 192.168.80.3 at port 443 with authority auth.spot.robot 
[2022-10-17 10:46:38] [debug] [HelloSpotClient]: [ROBOT] Created client for auth 
Pensez à modif common.js pour retirer insecure credentials
[2022-10-17 10:46:38] [debug] [HelloSpotClient]: [COMMON] blocking request: /bosdyn.api.AuthService/GetAuthToken 
{"header":{"requestTimestamp":{"seconds":1666017998,"nanos":686000128},"clientName":"HelloSpotClientlll.local:sdk.js-46882","disableRpcLogging":false},"username":"spot","password":"mypassword","token":"","applicationToken":""}

Pensez à retirer le log du catch
Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
    at Object.callErrorFromStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client.js:195:52)
    at Object.onReceiveStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
    at Object.onReceiveStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
    at /Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/call-stream.js:188:78
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client.js:163:34)
    at ServiceClientImpl.getAuthToken (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at /Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:281:9
    at new Promise (<anonymous>)
    at AuthClient.#make (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:278:12)
    at AuthClient.call (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:332:34)
    at AuthClient.auth (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/auth.js:128:17)
    at Robot.authenticate (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/robot.js:296:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async hello_spot (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:25:3) {
  code: 13,
  details: 'Received RST_STREAM with code 2 triggered by internal client error: Protocol error',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}
Unclassified exception: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/channel.js:196
  return new RpcError(msg);
         ^

RpcError: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
    at translate_exception (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/channel.js:196:10)
    at AuthClient.call (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:341:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Robot.authenticate (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/robot.js:296:24)
    at async hello_spot (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:25:3)
    at async main (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:129:3)
TheoPierne commented 2 years ago

I made some research and I found out that can be a problem with the SSL encryption caused by a bad using of the SSL certificate in the code, I started working on a fix but I don't know when I'll be done.

I'll let you know when I finish it!

TheoPierne commented 2 years ago

Hello,

I just made some fixes, let me know if this changes anything. If you encounter bugs let me know and send me in this issue, the version of his software.

Have a good day!

kaspesla commented 2 years ago

Good morning! I'm getting a different error now. Let me know if there's anything you want me to try on this end.

One of the students here is trying to do a similar thing but with C#. He has not got it completely working yet but he's gotten beyond the GPRC authentication steps so maybe he can look at your code and provide some suggestions as far as how to create the authentication channels and provide the certificates properly. I'l ask him on Wednesday.

[2022-10-21 10:12:54] [debug] [SDK]: [SDK] Creating standard Sdk, cert glob: "undefined" 
[2022-10-21 10:12:54] [debug] [HelloSpotClient]: [ROBOT] Created channel to 192.168.80.3 at port 443 with authority auth.spot.robot 
[2022-10-21 10:12:54] [debug] [HelloSpotClient]: [ROBOT] Created client for auth 
[2022-10-21 10:12:54] [debug] [HelloSpotClient]: [COMMON] blocking request: /bosdyn.api.AuthService/GetAuthToken 
{"header":{"requestTimestamp":{"seconds":1666361574,"nanos":696000000},"clientName":"HelloSpotClientlll.local:sdk.js-60476","disableRpcLogging":false},"username":"spot","password":"mypassword","token":"","applicationToken":""}

(node:60476) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.
(Use `node --trace-deprecation ...` to show where the warning was created)
Pensez à retirer le log du catch
Error: 14 UNAVAILABLE: No connection established
    at Object.callErrorFromStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client.js:195:52)
    at Object.onReceiveStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
    at Object.onReceiveStatus (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
    at /Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/call-stream.js:188:78
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/client.js:163:34)
    at ServiceClientImpl.getAuthToken (/Users/ken/Sandbox/spot-sdk-js/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at /Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:279:9
    at new Promise (<anonymous>)
    at AuthClient.#make (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:276:12)
    at AuthClient.call (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:330:34)
    at AuthClient.auth (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/auth.js:128:17)
    at Robot.authenticate (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/robot.js:296:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async hello_spot (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:25:3) {
  code: 14,
  details: 'No connection established',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}
/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/channel.js:202
    return new UnableToConnectToRobotError(msg);
           ^

UnableToConnectToRobotError: No connection established
    at translate_exception (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/channel.js:202:12)
    at AuthClient.call (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/common.js:339:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Robot.authenticate (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/robot.js:296:24)
    at async hello_spot (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:25:3)
    at async main (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:129:3)
TheoPierne commented 2 years ago

Hey !

I notice I didn't pass the good credentials and options to the stub constructor

https://github.com/TheoPierne/spot-sdk-js/blob/47edcfc3649ad8c5f998a52b49be6467dab91365/bosdyn-client/common.js#L215-L221

I think it should work now 🤞

https://github.com/TheoPierne/spot-sdk-js/blob/51c93ef1675efb9c2aae3737c710e5da8a194c52/bosdyn-client/common.js#L215-L222

In case my modification didn't fix it, add this to the environment variables, rerun hello_spot.js and copy paste the terminal in this issue, it will provide me more details logs from GRPC.

export GRPC_HELLO_SECURE=Y
export GRPC_TRACE=subchannel
export GRPC_VERBOSITY=DEBUG
set GRPC_HELLO_SECURE=Y
set GRPC_TRACE=subchannel
set GRPC_VERBOSITY=DEBUG

One of the students here is trying to do a similar thing but with C#. He has not got it completely working yet but he's gotten beyond the GPRC authentication steps so maybe he can look at your code and provide some suggestions as far as how to create the authentication channels and provide the certificates properly. I'l ask him on Wednesday.

No problem, I appreciate your help !

kaspesla commented 2 years ago

Hey we have some progress. It gets the channels connected! auth, e_stop and power. The motor fans power on now and it sounds like it's starting up, but then after a few seconds it gets this error:

lots of output repeating the PowerCommandFeedback messages over and over again and then it throws. It must be getting null back from the power_command_feedback


-91
[2022-10-26 17:58:05] [debug] [HelloSpotClient]: [COMMON] blocking request: /bosdyn.api.PowerService/PowerCommandFeedback 
{"header":{"requestTimestamp":{"seconds":1666821485,"nanos":349999872},"clientName":"HelloSpotClientlll.local:sdk.js-78339","disableRpcLogging":false},"powerCommandId":6}

[2022-10-26 17:58:05] [debug] [HelloSpotClient]: [COMMON] response: /bosdyn.api.PowerService/PowerCommandFeedback 
{"header":{"requestHeader":{"requestTimestamp":{"seconds":1666821485,"nanos":349999872},"clientName":"HelloSpotClientlll.local:sdk.js-78339","disableRpcLogging":false},"requestReceivedTimestamp":{"seconds":1666821772,"nanos":962526274},"responseTimestamp":{"seconds":1666821773,"nanos":62624314},"error":{"code":1,"message":""},"request":{"typeUrl":"type.googleapis.com/bosdyn.api.PowerCommandFeedbackRequest","value":"CjUKDAjt2uaaBhCApvKmARIlSGVsbG9TcG90Q2xpZW50bGxsLmxvY2FsOnNkay5qcy03ODMzORAG"}},"status":11,"blockingFaultsList":[]}

CommandTimedOutError: TypeError: Cannot read properties of undefined (reading '0')
    at _power_command (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/power.js:439:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async power_on_motors (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/power.js:248:3)
    at async power_on (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/power.js:226:3)
    at async Robot.power_on (/Users/ken/Sandbox/spot-sdk-js/bosdyn-client/robot.js:456:5)
    at async hello_spot (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:40:5)
    at async main (/Users/ken/Sandbox/spot-sdk-js/examples/hello_spot/hello_spot.js:129:3) {
  response: null
}
[2022-10-26 17:58:05] [debug] [HelloSpotClient]: [COMMON] blocking request: /bosdyn.api.LeaseService/ReturnLease 
{"header":{"requestTimestamp":{"seconds":1666821485,"nanos":470000128},"clientName":"HelloSpotClientlll.local:sdk.js-78339","disableRpcLogging":false},"lease":{"resource":"body","epoch":"WTScUxIROJsvXnlo","sequenceList":[10],"clientNamesList":["root"]}}

[2022-10-26 17:58:05] [debug] [HelloSpotClient]: [COMMON] response: /bosdyn.api.LeaseService/ReturnLease 
{"header":{"requestHeader":{"requestTimestamp":{"seconds":1666821485,"nanos":470000128},"clientName":"HelloSpotClientlll.local:sdk.js-78339","disableRpcLogging":false},"requestReceivedTimestamp":{"seconds":1666821773,"nanos":79762367},"responseTimestamp":{"seconds":1666821773,"nanos":79975119},"error":{"code":1,"message":""},"request":{"typeUrl":"type.googleapis.com/bosdyn.api.ReturnLeaseRequest","value":"CjUKDAjt2uaaBhCAxI7gARIlSGVsbG9TcG90Q2xpZW50bGxsLmxvY2FsOnNkay5qcy03ODMzORIhCgRib2R5EhBXVFNjVXhJUk9Kc3ZYbmxvGgEKIgRyb290"}},"status":1}

oui time sync
oui token
TheoPierne commented 2 years ago

Hey, I'm glad my previous fix is working!

I pushed a fix for the TypeError in power.js : https://github.com/TheoPierne/spot-sdk-js/commit/bc1b89633d2b9802ff5c4c893ea1641a44f6c5ec

If you find any other bug, let me know! (Maybe close this issue and create others one if needed)

kaspesla commented 2 years ago

Will try it as soon as possible. Spot is out on a trip today :)

TheoPierne commented 2 years ago

Also don't forget to run an estop when running hello_spot.js (https://github.com/TheoPierne/spot-sdk-js/tree/main/examples/hello_spot#common-problems)

Maybe use the official one, my version of the estop doesn't work well.

Spot is out on a trip today :)

Well have a good trip Spot!