Datalogging the NXT sensors

Is there an example or tutorial that shows how to datalog to a file? The service tutorial comes close with the persisting of data, but it replaces the data in question. I'd like to log over time some sensor data. Thanks for any info.
[242 byte] By [Rexex] at [2008-1-4]
# 1

The service tutorials show how to persist service state and read it again but if you are looking for a logger of messages going in and out of the service then you can configure the runtime to log messages as described in [1] which is part of the MSRS online documentation starting at [2]

Henrik

[1] http://msdn2.microsoft.com/en-us/library/bb483069.aspx

[2] http://msdn2.microsoft.com/en-us/library/bb483104.aspx

HenrikFNielsen at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 2
Is there a sample that shows a way to log data to a file from one of the sensors. The service tutorials are close, but the state is always overwritten, not logged. Any help would be appreciated.
Rexex at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 3

check out the SImpleDashboard sample: It uses our file log service to record data.

In particular look for the code section that starts with the line sbelow, (about line 625)


Code Snippet

fs.FileStorePort _fileStorePort = null;
object _fspLock = new object();

void OnLogSettingHandler(OnLogSetting onLogSetting)
{
_state.Log = onLogSetting.Log;
_state.LogFile = onLogSetting.File;


GeorgeChrysanthakopoulos at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 4

Very tasty example. Thanks for the pointer. It did send me in the right direction, but I ran into a brick wall pretty quickly. I'm looking at a set file to go to everytime like so:

staticstring filename = "C:\\Microsoft Robotics Studio 1.5 (CTP May 2007)\\store\\babydoll.txt";

Uri file = newUri(filename);

But when I run the code that tries to open the log I get the following error:

A file path must be child of the instance store directory Parameter name: filePath

Any pointers would be appreciated.

Rexex at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 5

Hi, construct the path using our LayoutPaths static class, and that should guarantee the file is in the right place. The file store service will only let you write files to our "sandbox", which is why file shave to be under \store

try something like this:

filename = LayoutPaths.RootDir + LayoutPaths.StoreDir + "babydoll.txt";

GeorgeChrysanthakopoulos at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 6
I wrote a logger and player service. the logger service records encoder values and sick scans and writes it to a file with timestamps. the player service then reads the file and plays back the messages in real time. this is handy when you want to record a run with the robot, then use the data repeatedly for testing. i have not yet made the services publicly available, but i can if you want.

BenAxelrod at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 7

How can I put this delicately....oh, I know......Aaaaarrrrrrghhhh! First off thanks a bunch for the help! I am up and running now. I should have known from wording of the error...

filename = LayoutPaths.RootDir + LayoutPaths.StoreDir + "babydoll.txt";

Does not work, however creating a directory "baby" in the store directory then:

filename = LayoutPaths.RootDir + LayoutPaths.StoreDir + "baby\\babydoll.txt";

works like a charm. So in the error "A file path must be child of the instance store directory " child of the instance store directory means a sub directory in the store directory. Once again, thanks for the help!

Rexex at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 8

One final nit to pick. The code that I lifted from the simple dashboard uses the following snippet for initiating the write to file:

void LogObject(object data)

{

lock (_fspLock)

{

LogInfo("Writing something:" + data.ToString());

_fileStorePort.Post(new fs.WriteObject(data));

}

}

Which results in something like so being logged.....

<SonarState xmlnsTongue Tied="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlnsBig Smile="http://schemas.microsoft.com/xw/2004/10/dssp.html" xmlns="http://schemas.microsoft.com/robotics/2006/06/sonar.html">

<TimeStamp>2007-06-08T21:32:07.03125-07:00</TimeStamp>

<HardwareIdentifier>4</HardwareIdentifier>

<MaxDistance>2.5</MaxDistance>

<DistanceMeasurement>255</DistanceMeasurement>

<AngularRange>30</AngularRange>

<AngularResolution>0</AngularResolution>

<Pose>

<Position xmlns="http://schemas.microsoft.com/robotics/2006/07/physicalmodel.html">

<X>0</X>

<Y>0</Y>

<Z>0</Z>

<Yada><Yada><Yada>

I appears that the only argument that fs.WriteObject will take is the actual message body. Is there any way to limit what get's written to file. The case in question I'm looking to log the DistanceMeasurement value and have no interest in logging the pose or any other values. As always, any help would be appreciated.
Rexex at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...
# 9
Hi, you can write to the log any CLR type instance that is XML serializable. That is the only restriction... By default any types, with public fields, and optionally, any XML attributes, will serialize ok
GeorgeChrysanthakopoulos at 2007-10-11 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Decentralized Software Services (DSS)...

Microsoft Robotics Studio

Site Classified