Sending data between Windows Applications: Difference between revisions
Line 10: | Line 10: | ||
== Writing to the text-file == | == Writing to the text-file == | ||
This part of the code belongs to the application responsible for calculating the angles controlling the AMIGO's arms from input from the Kinect sensor. Additional information about this application's code can be found [cstwiki.wtb.tue.nl/index.php?title=Kinect_Angles_Calculation_Script here]. | |||
[[File:Write file.png|x420px]] | [[File:Write file.png|x420px]] |
Revision as of 20:07, 20 June 2016
This is a brief explanation of code used to send data between Windows applications using a simple text-file that is being written and read by the communicating programs.
This code is part of a project to create a robot technique that allows users to hug someone when separated by a disctance like a phone call.
We do realise that this is an ad hoc method and that there are better ways out there to do this, but it suffices for our prototype.
Data format
An example of the format of the data to be written to and read from the text file is as follows: 0:3.1415926
. The number before the :
is the index of the value in the data array. The number following the :
is the actual value of the data, in this case [math]\displaystyle{ \pi }[/math].
Writing to the text-file
This part of the code belongs to the application responsible for calculating the angles controlling the AMIGO's arms from input from the Kinect sensor. Additional information about this application's code can be found [cstwiki.wtb.tue.nl/index.php?title=Kinect_Angles_Calculation_Script here].
Reading the text file
This part of the code belongs to the application responsible for sending ROS messages to a Ubuntu machine from a Windows machine. Additional information about this application's code can be found here.
These lines are responsible for reading the data from the text-file with the absolute file path known to both applications. In this code, the absolute file path is "C:\\angles.txt"
(line 49). It should be replaced by the absolute file path of the file the user would like both applications to use. in
is an input stream intialized somewhere else in the code.
Per new line in the text-file, the position of the :
is found (line 56). In the lines 58-61, the index of the data and its value are stored in dataNr
and angle
respectively. These are then stored in the data
array created in a different part of the code.