koalazak / dorita980

Unofficial iRobot Roomba and Braava (i7/i7+, 980, 960, 900, e5, 690, 675, m6, etc) node.js library (SDK) to control your robot
MIT License
931 stars 147 forks source link

route tracking coordinates record #143

Closed 2D closed 2 years ago

2D commented 2 years ago

Is that possible to record the movement as a path as a *.csv file as you did in your video https://www.youtube.com/watch?v=XILvHFEX7TM ?

I need it for research reasons on space utilization topic — https://twitter.com/deminism/status/1432832730245521409 — some info about the background

basically would be great to have some files for analysis — what floor-plan is suitable for what cleaning algorithm.

Also, I would like to ask a question if someone could share such data with me?

koalazak commented 2 years ago

Hello @2D, yes it is possible. Here you have a script to generate the csv file:

test.js file

const dorita980 = require('dorita980');

const myRobotViaLocal = new dorita980.Local('robo_id', 'robot_passowrd', 'robot_ip'); //fill with ypur data

myRobotViaLocal.on('connect', getState);

let printedHeaders = false;
function getState () {
   myRobotViaLocal.getRobotState(['pose', 'cleanMissionStatus', 'utctime']).then(s => {
    if (printedHeaders === false) {
        printedHeaders = true;
        const headers = ['localdatetime', 'utctime', 'pose.theta', 'pose.x', 'pose.y'].concat(Object.keys(s.cleanMissionStatus));
        console.log(headers.join(','));
    }
    const dataLine = [new Date().getTime(), s.utctime, s.pose.theta, s.pose.point.x, s.pose.point.y].concat([].concat.apply([], Object.values(s.cleanMissionStatus)));
    console.log(dataLine.join(','));
    setTimeout(getState, 500);
   });
}

install doirta980 lib and run the script:

$ npm install dorita980
$ node test.js
localdatetime,utctime,pose.theta,pose.x,pose.y,cycle,phase,expireM,rechrgM,error,notReady,mssnM,mssnStrtTm,expireTm,rechrgTm,sqft,initiator,nMssn
1631537429198,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430
1631537429805,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430
1631537430414,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430
1631537431022,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430
1631537431630,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430
1631537432235,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430
1631537432844,1631537424,-159,244,-360,none,charge,0,0,0,0,0,0,0,0,0,manual,1430

The output is a valid csv file with headers. Robot do not expose paths, it expose positions in x,y points and where the "head" is pointing (theta). You can infer the path linking two consecutive points.

regards,