質問編集履歴

5

写真の追加

2017/12/20 05:57

投稿

daityann
daityann

スコア7

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ![イメージ説明](485d0016ee5645babed77e903fcc4588.png)
1
+ ![イメージ説明](6f407d0f3e67122029efa4794cf976fd.png)![イメージ説明](485d0016ee5645babed77e903fcc4588.png)
2
2
 
3
3
  ボタンがクリックされたら、csvに書き込むようにしたいのですができなくて困っています。
4
4
 

4

プログラムの追加

2017/12/20 05:57

投稿

daityann
daityann

スコア7

test CHANGED
File without changes
test CHANGED
@@ -247,3 +247,237 @@
247
247
  }
248
248
 
249
249
  ```
250
+
251
+
252
+
253
+ ```c#
254
+
255
+ using System.Collections;
256
+
257
+ using System.Collections.Generic;
258
+
259
+ using UnityEngine;
260
+
261
+ using Enflux.SDK.Core;
262
+
263
+ using UnityEngine.UI;
264
+
265
+ using System;
266
+
267
+ using System.Linq;
268
+
269
+ using Enflux.Common.DataTypes;
270
+
271
+ using Enflux.SDK.Core.Devices;
272
+
273
+ using Enflux.SDK.DataTypes;
274
+
275
+ using Enflux.SDK.Extensions;
276
+
277
+ using Enflux.SDK.Utils;
278
+
279
+ using Enflux.Shim.Utils;
280
+
281
+ using System.IO;
282
+
283
+
284
+
285
+ public class math : MonoBehaviour
286
+
287
+ {
288
+
289
+ // Assign these in the editor.
290
+
291
+ public EnfluxManager EnfluxManager;
292
+
293
+ public Humanoid Humanoid;
294
+
295
+ // Retrieve limb orientations as Unity local space quaternions.
296
+
297
+ private void GetLocalSpaceOrientations()
298
+
299
+ {
300
+
301
+ var chest = Humanoid.LocalOrientations.Chest.Orientation;
302
+
303
+ var leftUpperArm = Humanoid.LocalOrientations.LeftUpperArm.Orientation;
304
+
305
+ var leftLowerArm = Humanoid.LocalOrientations.LeftLowerArm.Orientation;
306
+
307
+ var rightUpperArm = Humanoid.LocalOrientations.RightUpperArm.Orientation;
308
+
309
+ var rightLowerArm = Humanoid.LocalOrientations.RightLowerArm.Orientation;
310
+
311
+ var pelvis = Humanoid.LocalOrientations.Pelvis.Orientation;
312
+
313
+ var leftUpperLeg = Humanoid.LocalOrientations.LeftUpperLeg.Orientation;
314
+
315
+ var leftLowerLeg = Humanoid.LocalOrientations.LeftLowerLeg.Orientation;
316
+
317
+ var rightUpperLeg = Humanoid.LocalOrientations.RightUpperLeg.Orientation;
318
+
319
+ var rightLowerLeg = Humanoid.LocalOrientations.RightLowerLeg.Orientation;
320
+
321
+ }
322
+
323
+
324
+
325
+ // Retrieve limb orientations as real world NED (North-East-Down) space quaternions.
326
+
327
+ private string GetNedSpaceOrientations()
328
+
329
+ {
330
+
331
+ var chest = EnfluxManager.NedOrientations.Chest.Orientation;
332
+
333
+ var leftUpperArm = EnfluxManager.NedOrientations.LeftUpperArm.Orientation;
334
+
335
+ var leftLowerArm = EnfluxManager.NedOrientations.LeftLowerArm.Orientation;
336
+
337
+ var rightUpperArm = EnfluxManager.NedOrientations.RightUpperArm.Orientation;
338
+
339
+ var rightLowerArm = EnfluxManager.NedOrientations.RightLowerArm.Orientation;
340
+
341
+ var pelvis = EnfluxManager.NedOrientations.Pelvis.Orientation;
342
+
343
+ var leftUpperLeg = EnfluxManager.NedOrientations.LeftUpperLeg.Orientation;
344
+
345
+ var leftLowerLeg = EnfluxManager.NedOrientations.LeftLowerLeg.Orientation;
346
+
347
+ var rightUpperLeg = EnfluxManager.NedOrientations.RightUpperLeg.Orientation;
348
+
349
+ var rightLowerLeg = EnfluxManager.NedOrientations.RightLowerLeg.Orientation;
350
+
351
+
352
+
353
+
354
+
355
+ return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm +
356
+
357
+ "\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg + "\n\n";
358
+
359
+ }
360
+
361
+
362
+
363
+ //時間
364
+
365
+ void FindSundayOfTheWeek()
366
+
367
+ {
368
+
369
+ System.DateTime work = System.DateTime.Now;
370
+
371
+ Debug.Log(work.ToString());
372
+
373
+ }
374
+
375
+
376
+
377
+ //書き出し準備
378
+
379
+ private int i = 1;
380
+
381
+ StreamWriter sw;
382
+
383
+ FileInfo fi;
384
+
385
+
386
+
387
+ int x = 0;
388
+
389
+ public void OnClick()
390
+
391
+ {
392
+
393
+ x++;
394
+
395
+ Debug.Log(x);
396
+
397
+ Debug.Log("Button click!");
398
+
399
+ }
400
+
401
+
402
+
403
+ void Start()
404
+
405
+ {
406
+
407
+
408
+
409
+ FindSundayOfTheWeek();
410
+
411
+
412
+
413
+ //ファイル準備
414
+
415
+ fi = new FileInfo(Application.dataPath + "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv");
416
+
417
+ sw = fi.AppendText();
418
+
419
+
420
+
421
+ }
422
+
423
+
424
+
425
+ private float timeleft;
426
+
427
+ int log;
428
+
429
+
430
+
431
+ void Update()
432
+
433
+ {
434
+
435
+ if (i > 10000)
436
+
437
+ {
438
+
439
+ sw.Close();
440
+
441
+ return;
442
+
443
+ }
444
+
445
+ timeleft -= Time.deltaTime;
446
+
447
+ if (timeleft <= 0.0)
448
+
449
+ {
450
+
451
+ timeleft = 1.0f;
452
+
453
+
454
+
455
+ //処理
456
+
457
+ Debug.Log(GetNedSpaceOrientations());
458
+
459
+ this.GetComponent<Text>().text = GetNedSpaceOrientations();
460
+
461
+
462
+
463
+ //書き出す
464
+
465
+
466
+
467
+ sw.WriteLine(GetNedSpaceOrientations());
468
+
469
+ sw.Flush();
470
+
471
+
472
+
473
+ i++;
474
+
475
+ }
476
+
477
+ }
478
+
479
+ }
480
+
481
+
482
+
483
+ ```

3

プログラムの変更

2017/12/20 05:55

投稿

daityann
daityann

スコア7

test CHANGED
File without changes
test CHANGED
@@ -10,8 +10,6 @@
10
10
 
11
11
  ```c#
12
12
 
13
-
14
-
15
13
  using System.Collections;
16
14
 
17
15
  using System.Collections.Generic;
@@ -112,11 +110,11 @@
112
110
 
113
111
 
114
112
 
115
-
116
-
113
+
114
+
117
- return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm + "\n\n"+
115
+ return "胸 " + chest + "\n左肘 " + leftUpperArm + "\n左手首 " + leftLowerArm + "\n右肘 " + rightUpperArm + "\n右手首 " + rightLowerArm +
118
-
116
+
119
- "\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg;
117
+ "\n腰 " + pelvis + "\n左膝 " + leftUpperLeg + "\n左足首 " + leftLowerLeg + "\n右膝 " + rightUpperLeg + "\n右足首 " + rightLowerLeg + "\n\n";
120
118
 
121
119
  }
122
120
 
@@ -138,8 +136,6 @@
138
136
 
139
137
  //書き出し準備
140
138
 
141
- private GameObject cube;
142
-
143
139
  private int i = 1;
144
140
 
145
141
  StreamWriter sw;
@@ -148,7 +144,7 @@
148
144
 
149
145
 
150
146
 
151
- ここ↓
147
+
152
148
 
153
149
  bool aa;
154
150
 
@@ -180,8 +176,6 @@
180
176
 
181
177
 
182
178
 
183
- cube = GameObject.Find("Cube");
184
-
185
179
  //ファイル準備
186
180
 
187
181
  fi = new FileInfo(Application.dataPath + "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv");
@@ -200,63 +194,51 @@
200
194
 
201
195
 
202
196
 
203
- void Update()
197
+ void Update()
204
-
198
+
205
- {
199
+ {
206
-
207
- ここ↓
200
+
208
-
201
+
202
+
209
- if(true == aa)
203
+ if (i > 10000)
210
204
 
211
205
  {
212
206
 
207
+ sw.Close();
208
+
209
+ return;
210
+
211
+ }
212
+
213
+ timeleft -= Time.deltaTime;
214
+
215
+ if (timeleft <= 0.0)
216
+
217
+ {
218
+
219
+ timeleft = 1.0f;
220
+
221
+
222
+
223
+ //処理
224
+
213
225
  Debug.Log(GetNedSpaceOrientations());
214
226
 
215
- if (i > 10000)
216
-
217
- {
218
-
219
- sw.Close();
220
-
221
- return;
222
-
223
-
224
-
225
- timeleft -= Time.deltaTime;
226
-
227
- if (timeleft <= 0.0)
228
-
229
- {
230
-
231
- timeleft = 1.0f;
232
-
233
-
234
-
235
- //処理
236
-
237
- Debug.Log(GetNedSpaceOrientations());
238
-
239
- this.GetComponent<Text>().text = GetNedSpaceOrientations();
227
+ this.GetComponent<Text>().text = GetNedSpaceOrientations();
240
-
241
-
242
-
228
+
229
+
230
+
243
- //書き出す
231
+ //書き出す
244
-
245
-
246
-
232
+
233
+
234
+
247
- sw.WriteLine(GetNedSpaceOrientations());
235
+ sw.WriteLine(GetNedSpaceOrientations());
248
-
236
+
249
- sw.Flush();
237
+ sw.Flush();
250
-
251
-
252
-
238
+
239
+
240
+
253
- i++;
241
+ i++;
254
-
255
- }
256
-
257
-
258
-
259
- }
260
242
 
261
243
  }
262
244
 

2

マークダウン

2017/12/20 03:42

投稿

daityann
daityann

スコア7

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,11 @@
4
4
 
5
5
  ここ↓ と2か所書いた場所でできると思っていたのですが、なにがおかしいでしょうか?それとも、unityのボタンのほうに原因があるのでしょうか?
6
6
 
7
+
8
+
9
+
10
+
7
- ----------------------------------------------------------
11
+ ```c#
8
12
 
9
13
 
10
14
 
@@ -260,6 +264,4 @@
260
264
 
261
265
  }
262
266
 
263
-
264
-
265
- -----------------------------------------------------
267
+ ```

1

写真の追加

2017/12/19 18:13

投稿

daityann
daityann

スコア7

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,5 @@
1
+ ![イメージ説明](485d0016ee5645babed77e903fcc4588.png)
2
+
1
3
  ボタンがクリックされたら、csvに書き込むようにしたいのですができなくて困っています。
2
4
 
3
5
  ここ↓ と2か所書いた場所でできると思っていたのですが、なにがおかしいでしょうか?それとも、unityのボタンのほうに原因があるのでしょうか?