microsoft / pxt-robotis

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

Feature dynamixel #23

Closed kigateG closed 4 years ago

kigateG commented 4 years ago

Added some Dynamixel Lib for test.

msftclas commented 4 years ago

CLA assistant check
All CLA requirements met.

OpusK commented 4 years ago

Hi, @pelikhan

Are adding collaborations and agreeing to CLA independent of each other?

pelikhan commented 4 years ago

Yes separate bot. Please sign.

OpusK commented 4 years ago

@pelikhan

The following error is occurring. What should I add to solve this?

image

pelikhan commented 4 years ago

This is because you implemented the driver in c++ and you’ll need to write a JavaScript driver to mimic what happens in c++. Do you need the c++? Could you implement this in typescript?

pelikhan commented 4 years ago

Is there an app we can chat with? Maybe faster than GitHub messages

OpusK commented 4 years ago

This is because you implemented the driver in c++ and you’ll need to write a JavaScript driver to mimic what happens in c++. Do you need the c++? Could you implement this in typescript?

Oh, I understood. I will try to change to TS.

Is there an app we can chat with? Maybe faster than GitHub messages

We often use Google Hangout. Is there anything you want?

OpusK commented 4 years ago

This is because you implemented the driver in c++ and you’ll need to write a JavaScript driver to mimic what happens in c++. Do you need the c++? Could you implement this in typescript?

https://github.com/microsoft/pxt-common-packages/blob/master/libs/serial/serial-target.cpp#L6-L24

I did it by referring to the above link method. (Note, I started learning TS this time.) Is there a better way than the above?

+Update: I think you need some explanation related to this package. This is a package for controlling a motor actuator called DYNAMIXEL from ROBOTIS. Also, the DYNAMIXEL library is implemented in C/CPP. I want to use this as a block (like Serial and Accelerator). It is currently in codal-cm300, but I will move to this package folder later. Since this uses UART as the default communication interface, I implemented it by referring to the Serial package. Of course, I could also implement the DYNAMIXEL library with TS, but I would like to avoid it if possible.

Note, when using the network namespace, the above error did not occur (while there was an error about sim). However, the above error occurred when changing to dynamixel, a namespace that was not previously registered.

you’ll need to write a JavaScript driver to mimic what happens in c++.

I thought I connected TS and CPP using //% annotation for this, is there another way? The serial I referenced is the same structure as I did, except that it was additionally defined in the simulator.

+Update: When referring to other packages, when I changed the namespace dynamixel to pxt, the above error disappeared, but an additional error related to simulation occurred. image

Note, despite the two errors I mentioned, the program works fine on the board. (Of course, I'm asking because I don't want the error to appear at all.)

OpusK commented 4 years ago

@pelikhan

I would like to know if I can apply the same way as the serial package.

I would do that if I had to write it using TS, but if possible I would like to take the same method as the serial package and know how to do it.

If, by policy, you recommend using TS rather than CPP, after this PR is merged, I will re-implement the existing C/CPP code into TS code and PR.

pelikhan commented 4 years ago

you can keep the C++ but you'll need to write a javascript shim.

What you need to do is to implement a javascript version of the C++ call. The PXT linker will use javascript in the browser, and C++ for the ARM file (this is why it works in C++). Pointers: See serial shim: https://github.com/microsoft/pxt-common-packages/blob/76fe391800fd44825839573da32cdca3ca5076ed/libs/core/sim/serial.ts#L40 See https://makecode.com/simshim You can push this PR as is and the simulator part later on.