microsoft / pxt-robotis

Microsoft MakeCode for ROBOTIS
https://5d8c71b7-aa36-4a68-a9cb-288b989efb08.pxt.io/
MIT License
3 stars 7 forks source link

[Error] Cannot read property #26

Closed OpusK closed 4 years ago

OpusK commented 4 years ago

@pelikhan,

The issue below (#23) has not been resolved. And even though it is declared as below in shims.d.ts, it still shows 'of undefined', not 'of dynamixel' ... Strangely, despite this error, the board works fine.

declare namespace dynamixel {
    /**
     * Opens a DYNAMIXEL communication driver
     */
    //% shim=dynamixel::internalCreateDXLDevice
    function internalCreateDXLDevice(tx: DigitalInOutPin, rx: DigitalInOutPin, dir: DigitalInOutPin, id: int32): DynamixelDevice;
}

image

And, the below .png file is the example code with the above error.

ROBOTIS-DYNAMIXEL-Velocity


Originally posted by @OpusK in https://github.com/microsoft/pxt-robotis/pull/23

What you need to do is to implement a javascript version of the C++ call.

I think I wrote a shim through the code above as per the manual.

See serial shim: https://github.com/microsoft/pxt-common-packages/blob/76fe391800fd44825839573da32cdca3ca5076ed/libs/core/sim/serial.ts#L40

Your link is not a shim, but a sim file (for simulation). Isn't it right to refer to shims.d.ts for shim? Of course, I haven't implemented simulation yet, so when implementing sim it's right to refer to the file you gave the link to. I've also seen errors related to simulation, so I know I need to implement sim someday. However, the current error is about shim.

I think it was implemented properly except for simulation, isn't it? Like docs, should it be uploaded to the cloud to be recognized as a namespace called dynamixel, not undefined? If so, please merge. I will implement the simulator later.

Originally posted by @OpusK in https://github.com/microsoft/pxt-robotis/pull/23

pelikhan commented 4 years ago

Peli will put the skeleton code to unblock you.

pelikhan commented 4 years ago

Sorry i haven't been looking at it yet.

pelikhan commented 4 years ago

Fixed, see dynamixel/sim/*.ts

pelikhan commented 4 years ago

You'll need to implement a "dynamixel" simulator in javascript.

OpusK commented 4 years ago

Thanks for your support :)