Log to csv file on local install


#1

Hi there,

I am working on a locally installed nrp and trying to log data to a csv file.

Would that be possible using the MapCSVRecorder decorator?

I currently use this transfer function:

@nrp.MapRobotSubscriber(“joint_state”, Topic(’/joint_states’, sensor_msgs.msg.JointState))
@nrp.MapCSVRecorder(“recorder”, filename="/home/nrp/NRP/Experiments/tigrillo_experiment_Alexander/all_joints_positions.csv", headers=[“Name”, “time”, “Position”])
@nrp.Robot2Neuron()

def csv_joint_state_monitor(t, joint_state, recorder):
____recorder.record _entry(0, 1, 2)
___clientLogger.info(str(t))

though no csv file seems to be generated…

Thanks,

Alexander


#2

Hi Alexander,

Unfortunately that interface was originally designed to write CSV files to your storage in the collaboratory and doesn’t support local installs at all.

As a note you’ll want to change the: filename="/home/nrp/NRP/Experiments/tigrillo_experiment_Alexander/all_joints_positions.csv" to drop the absolute path just back to all_joints_positions.csv, it isn’t needed and may break stuff.

The VirtualCoach has a method to get this data programatically, but for your current scenario you’ll have to use this workaround to write the files:

rosservice list

Look for the service in the form (/ros_cle_simulation//get_CSV_recorders_file), where <id> depends on the simulation that you’ve launched. Then you can run:

rosservice call /ros_cle_simulation/<id>/get_CSV_recorders_file

It will print out something like:

files: 
  - 
    name: all_spikes.csv
    temporary_path: /tmp/tmpokUwth
  - 
    name: all_joints_positions.csv
    temporary_path: /tmp/tmpWS2MY8

where the temporary_path is the actual file that you want (the collab client downloads that file and renames it, but that doesn’t happen on your local install).

You can call that as many times as you want, and you can also call:

rosservice call /ros_cle_simulation/<id>/clean_CSV_recorders_file

to remove any temp files created during that session.

I’ll double check and make sure this is reported since it’s pretty awkward to have to do on a local install.

Let me know if that works,
Kenny


#3

Hi Kenny,

thanks for the workaround, it’s working,

Kind regards,

Alexander