Skip to content

ファイル整理 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/scripts/sync_scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#/bin/bash -eu

SRC_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../../; pwd)
echo "Run sync script in $SRC_DIR"
rsync -av --delete $SRC_DIR/MobileRobotUITutorialProject/Assets/Scripts/ $SRC_DIR/UnityScripts/Scripts
rsync -av --delete $SRC_DIR/MobileRobotUITutorialProject/Assets/OdometryViewer/ $SRC_DIR/UnityScripts/OdometryViewer
rsync -av --delete $SRC_DIR/MobileRobotUITutorialProject/Assets/PointCloud/ $SRC_DIR/UnityScripts/PointCloud
18 changes: 18 additions & 0 deletions .github/workflows/check_tutorial_files.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check for the tutorial update

on:
pull_request:
paths:
- "MobileRobotUITutorialProject/**"
- "UnityScripts/**"

jobs:
check-tutorial-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: File sync
run: |
./.github/scripts/sync_scripts.sh
git status | grep "working tree clean" && exit 0 || git status; exit 1;
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ void ProcessMessage()
/// </summary>
class CameraImage
{
public byte[] imageData { get; set; }
public byte[] imageData { get; set; }
}
4 changes: 2 additions & 2 deletions UnityScripts/PointCloud/Prefabs/Sphere.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ MeshRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2278637883144382342}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
Expand Down
31 changes: 22 additions & 9 deletions UnityScripts/Scripts/ImageSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
using CompressedImageMsg = RosMessageTypes.Sensor.CompressedImageMsg;

/// <summary>
/// LiDARスキャンデータ(LaserScanMsg)を受信するためのクラス
/// 主にスキャンデータの取得および座標変換に使い、描画は別のスクリプトを用意することを想定
/// カメラデータ(CompressedImageMsg)を受信し、描画するためのクラス
/// </summary>
public class ImageSubscriber : MonoBehaviour
{
Expand All @@ -17,7 +16,7 @@ public class ImageSubscriber : MonoBehaviour
[SerializeField] RawImage rawImage;

private Texture2D texture2D;
private byte[] imageData;
private CameraImage cameraImage = new CameraImage();
private bool isMessageReceived;

/// <summary>
Expand Down Expand Up @@ -47,22 +46,36 @@ void Update()
/// </summary>
void ImageMsgUpdate(CompressedImageMsg rawImage)
{
imageData = rawImage.data;
isMessageReceived = true;
if (isDebugMode)
lock (cameraImage)
{
Debug.Log("rawImage recieved. length :" + System.Buffer.ByteLength(imageData));
cameraImage.imageData = rawImage.data;
if (isDebugMode)
{
Debug.Log("rawImage recieved. length :" + System.Buffer.ByteLength(cameraImage.imageData));
}
}
isMessageReceived = true;
}

/// <summary>
/// ImageMsgのデータをTextureに反映する関数
/// </summary>
void ProcessMessage()
{
texture2D.LoadImage(imageData);
texture2D.Apply();
lock (cameraImage)
{
texture2D.LoadImage(cameraImage.imageData);
texture2D.Apply();
}
rawImage.texture = texture2D;
isMessageReceived = false;
}
}

/// <summary>
/// アクセス制限用のカメライメージデータ格納配列
/// </summary>
class CameraImage
{
public byte[] imageData { get; set; }
}