phyphox Forums
New Editor code error Puck.js - Printable Version

+- phyphox Forums (https://phyphox.org/forums)
+-- Forum: App-Feedback (https://phyphox.org/forums/forumdisplay.php?fid=6)
+--- Forum: Experiment editor (new Blockly-based version) (https://phyphox.org/forums/forumdisplay.php?fid=15)
+--- Thread: New Editor code error Puck.js (/showthread.php?tid=1954)



New Editor code error Puck.js - jahuber - 09-09-2024

Hi.   
I am trying to append a Puck.js experiment to add a View that displays the angle of inclination of the Puck assuming the x-axis of the Puck.  After fiddling with the initial experiment, I am able to Generate an experiment QR code, but Phyphox on my phone gives an exception "Line 27: Tag needs a conversion attribute."

What is wrong?

Code:
<phyphox xmlns="https://phyphox.org/xml" version="1.18">
  <title>Accelerometer and Gyroscope w/angle</title>
  <category>puck.js</category>
  <color>green</color>
  <description>Read the accelerometer and gyroscope of a puck with angle report.js.</description>
  <data-containers>
    <container size="0">preAngle</container>
    <container size="0">angle</container>
    <container size="0">accXRaw</container>
    <container size="0">accYRaw</container>
    <container size="0">accZRaw</container>
    <container size="0">accXCal</container>
    <container size="0">accYCal</container>
    <container size="0">accZCal</container>
    <container size="0">gyrXRaw</container>
    <container size="0">gyrYRaw</container>
    <container size="0">gyrZRaw</container>
    <container size="0">gyrXCal</container>
    <container size="0">gyrYCal</container>
    <container size="0">gyrZCal</container>
    <container size="0">t</container>
    <container>t0</container>
    <container size="0">tout</container>
  </data-containers>
  <input>
    <bluetooth id="puck.js" uuid="6e400001-b5a3-f393-e0a9-e50e24dcca9e" mtu="53" mode="notification">
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">reset();                                                    </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e" conversion="hexadecimal">0d</config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">echo(false);                                                </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">function directOut(s) {                                     </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">    NRF.updateServices({                                    </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">        "6e400001-b5a3-f393-e0a9-e50e24dcca9e" : {          </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">            "6e400003-b5a3-f393-e0a9-e50e24dcca9e" : {      </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">                value : s,                                  </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">                notify : true,                              </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">    }}});                                                   </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">}                                                           </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">let t0 = Date.now();                                        </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">Puck.on("accel", function(data) {                           </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">    let t = Math.round(Date.now() - t0);                    </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">    directOut(t                                             </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">         +","+data.acc.x+","+data.acc.y+","+data.acc.z      </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">         +","+data.gyro.x+","+data.gyro.y+","+data.gyro.z); </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">});                                                         </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e">Puck.accelOn();                                             </config>
      <config char="6e400002-b5a3-f393-e0a9-e50e24dcca9e" conversion="hexadecimal">0d</config>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="0">t</output>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="1">accXRaw</output>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="2">accYRaw</output>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="3">accZRaw</output>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="4">gyrXRaw</output>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="5">gyrYRaw</output>
      <output char="6e400003-b5a3-f393-e0a9-e50e24dcca9e" conversion="formattedString" separator="," index="6">gyrZRaw</output>
    </bluetooth>
  </input>
  <analysis>
    <first>
      <input as="value" keep="true">t</input>
      <output as="first">t0</output>
    </first>
    <formula formula="([1_]-[2])/1000">
      <input keep="true">t</input>
      <input keep="true">t0</input>
      <output>tout</output>
    </formula>
    <multiply>
      <input keep="true">accXRaw</input>
      <input type="value">0.00119751</input>
      <output>accXCal</output>
    </multiply>
    <divide>
      <input keep="true">accXCal</input>
      <input type="value">9.81</input>
      <output>preAngle</output>
    </divide>
    <asin>
      <input as="value">preAngle</input>
      <output>angle</output>
    </asin>
    <multiply>
      <input keep="true">accYRaw</input>
      <input type="value">0.00119751</input>
      <output>accYCal</output>
    </multiply>
    <multiply>
      <input keep="true">accZRaw</input>
      <input type="value">0.00119751</input>
      <output>accZCal</output>
    </multiply>
    <multiply>
      <input keep="true">gyrXRaw</input>
      <input type="value">0.000130495</input>
      <output>gyrXCal</output>
    </multiply>
    <multiply>
      <input keep="true">gyrYRaw</input>
      <input type="value">0.000130495</input>
      <output>gyrYCal</output>
    </multiply>
    <multiply>
      <input keep="true">gyrZRaw</input>
      <input type="value">0.000130495</input>
      <output>gyrZCal</output>
    </multiply>
  </analysis>
  <views>
    <view label="Accelerometer">
      <value label="Inclination (X-axis)">
        <input>angle</input>
      </value>
      <graph label="Acceleration x" partialUpdate="true" labelX="[[quantity_short_time]]" labelY="[[quantity_short_acceleration]]" unitX="[[unit_short_second]]" unitY="[[unit_short_meter_per_square_second]]" unitYperX="m/s³" timeOnX="true" color="green">
        <input axis="x">tout</input>
        <input axis="y">accXCal</input>
      </graph>
      <graph label="Acceleration y" partialUpdate="true" labelX="[[quantity_short_time]]" labelY="[[quantity_short_acceleration]]" unitX="[[unit_short_second]]" unitY="[[unit_short_meter_per_square_second]]" unitYperX="m/s³" timeOnX="true" color="blue">
        <input axis="x">tout</input>
        <input axis="y">accYCal</input>
      </graph>
      <graph label="Acceleration z" partialUpdate="true" labelX="[[quantity_short_time]]" labelY="[[quantity_short_acceleration]]" unitX="[[unit_short_second]]" unitY="[[unit_short_meter_per_square_second]]" unitYperX="m/s³" timeOnX="true" color="yellow">
        <input axis="x">tout</input>
        <input axis="y">accZCal</input>
      </graph>
    </view>
    <view label="Gyroscope">
      <graph label="Angular velocity x" partialUpdate="true" labelX="[[quantity_short_time]]" labelY="[[quantity_short_angular_velocity]]" unitX="[[unit_short_second]]" unitY="[[unit_short_radian_per_second]]" unitYperX="rad/s²" timeOnX="true" color="green">
        <input axis="x">tout</input>
        <input axis="y">gyrXCal</input>
      </graph>
      <graph label="Angular velocity y" partialUpdate="true" labelX="[[quantity_short_time]]" labelY="[[quantity_short_angular_velocity]]" unitX="[[unit_short_second]]" unitY="[[unit_short_radian_per_second]]" unitYperX="rad/s²" timeOnX="true" color="blue">
        <input axis="x">tout</input>
        <input axis="y">gyrYCal</input>
      </graph>
      <graph label="Angular velocity z" partialUpdate="true" labelX="[[quantity_short_time]]" labelY="[[quantity_short_angular_velocity]]" unitX="[[unit_short_second]]" unitY="[[unit_short_radian_per_second]]" unitYperX="rad/s²" timeOnX="true" color="yellow">
        <input axis="x">tout</input>
        <input axis="y">gyrZCal</input>
      </graph>
    </view>
    <view label="Angle (x)">
      <value label="Inclination (x-axis)">
        <input>angle</input>
      </value>
    </view>
  </views>
  <export>
    <set name="Accelerometer and Gyroscope">
      <data name="Time (s)">tout</data>
      <data name="Acceleration x (m/s²)">accXCal</data>
      <data name="Acceleration y (m/s²)">accYCal</data>
      <data name="Acceleration z (m/s²)">accZCal</data>
      <data name="Angular velocity x (rad/s)">gyrXCal</data>
      <data name="Angular velocity y (rad/s)">gyrYCal</data>
      <data name="Angular velocity z (rad/s)">gyrZCal</data>
    </set>
  </export>
</phyphox>



RE: New Editor code error Puck.js - Jens Noriʇzsɔɥ - 09-09-2024

Thanks for your report. The new editor apparently omits the “conversion="string"” attributes in the generated file that are present in the original files. We are working on a fix.

For the time being you need to manually add it to those “config” elements that do not have the mandatory “conversion” attribute.