read motor state into lms_motor
This commit is contained in:
parent
aa031036ee
commit
c8ac770983
@ -15,11 +15,13 @@ namespace pxsim {
|
|||||||
MMapMethods.register("/dev/lms_motor", {
|
MMapMethods.register("/dev/lms_motor", {
|
||||||
data,
|
data,
|
||||||
beforeMemRead: () => {
|
beforeMemRead: () => {
|
||||||
|
const outputs = ev3board().outputNodes;
|
||||||
console.log("motor before read");
|
console.log("motor before read");
|
||||||
for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) {
|
for (let port = 0; port < DAL.NUM_OUTPUTS; ++port) {
|
||||||
data[MotorDataOff.TachoCounts * port] = 0; // Tacho count
|
const output = outputs[port];
|
||||||
data[MotorDataOff.Speed * port] = 50; // Speed
|
data[MotorDataOff.TachoCounts + port * MotorDataOff.Size] = 0; // Tacho count
|
||||||
data[MotorDataOff.TachoSensor * port] = 0; // Count
|
data[MotorDataOff.Speed + port * MotorDataOff.Size] = output ? outputs[port].getSpeed() : 0; // Speed
|
||||||
|
data[MotorDataOff.TachoSensor + port * MotorDataOff.Size] = output ? outputs[port].getAngle() : 0; // Count
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
read: buf => {
|
read: buf => {
|
||||||
|
Loading…
Reference in New Issue
Block a user