Virtual Store System using digital twins and oneM2M

We started with the idea of connecting real stores and virtual stores in the real world through the Mobius platform.

AdvancedWork in progressOver 3 days587
Virtual Store System using digital twins and oneM2M

Things used in this project

Hardware components

NVIDIA Jetson Nano Developer Kit
NVIDIA Jetson Nano Developer Kit
×1
Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×3
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×3
load cell 10Kg
×12
SparkFun Load Cell Amplifier - HX711
SparkFun Load Cell Amplifier - HX711
×12
Webcam, Logitech® HD Pro
Webcam, Logitech® HD Pro
×1

Software apps and online services

oneM2M
Unity
Unity
Android Studio
Android Studio

Story

Read more

Schematics

Circuit Diagram

connect Raspberry Pi 4 and Load cell

Code

ButtonEvent.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ButtonEvent : MonoBehaviour
{
    public class JsonData
    {
        public string ctname;
        public string con;


        public JsonData() { }

        public JsonData(string ctname, string con)
        {
            this.ctname = ctname;
            this.con = con;
        }

        public void Print()
        {
            Debug.Log("ctname = " + ctname);
            Debug.Log("con = " + con);
        }
    }
    static public string ObjectToJson(object obj)
    {
        return JsonUtility.ToJson(obj);
    }
    public void OnClickSend_water()
    {

        TCP_connection tcp = GameObject.Find("hand_line1").GetComponent<TCP_connection>();
        counting cnt = GameObject.Find("Count_txt_water").GetComponent<counting>();


        string cnt_string_water = cnt.count.ToString();
        JsonData jd = new JsonData("Virtual_water", cnt_string_water);
        string jsondata = ObjectToJson(jd);
        string conv_json = jsondata + "<EOF>";

        tcp.SendMessage_(conv_json);


    }
    public void OnClickSend_beer()
    {

        TCP_connection tcp = GameObject.Find("hand_line1").GetComponent<TCP_connection>();
        counting cnt = GameObject.Find("Count_txt_beer").GetComponent<counting>();


        string cnt_string_beer = cnt.count.ToString();
        JsonData jd = new JsonData("Virtual_beer", cnt_string_beer);
        string jsondata = ObjectToJson(jd);
        string conv_json = jsondata + "<EOF>";

        tcp.SendMessage_(conv_json);

    }
    public void OnClickSend_paper()
    {

        TCP_connection tcp = GameObject.Find("hand_line1").GetComponent<TCP_connection>();
        counting cnt = GameObject.Find("Count_txt_A4").GetComponent<counting>();


        string cnt_string_a4 = cnt.count.ToString();
        JsonData jd = new JsonData("Virtual_paper", cnt_string_a4);
        string jsondata = ObjectToJson(jd);
        string conv_json = jsondata + "<EOF>";

        tcp.SendMessage_(conv_json);
 
    }
}

num_script_a4.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class num_script_a4 : MonoBehaviour
{
    [SerializeField] Text num_txt;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        counting cnt = GameObject.Find("Count_txt_A4").GetComponent<counting>();
        string count_t = cnt.count.ToString();
        Debug.Log("a4 count : " + count_t);
        num_txt.text = count_t;
    }
}

num_script_beer.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class num_script_beer : MonoBehaviour
{
    [SerializeField] Text num_txt;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        counting cnt = GameObject.Find("Count_txt_beer").GetComponent<counting>();
        string count_t = cnt.count.ToString();
        num_txt.text = count_t;
    }
}

num_script_water.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class num_script_water : MonoBehaviour
{
    [SerializeField] Text num_txt;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        counting cnt = GameObject.Find("Count_txt_water").GetComponent<counting>();
        string count_t = cnt.count.ToString();
        num_txt.text = count_t;
    }
}

TCP_connection.cs

C#
No preview (download only).

counting.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class counting : MonoBehaviour
{
    [SerializeField] Text count_txt;
    public int count = 0;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        count_txt.text = count.ToString();
    }
    public void Click_plus()
    {
        count = count + 1;
    }
    public void Click_minus()
    {
        if (count > 0)
        {
            count = count - 1;
        }
        
    }
}

Get_line1_count.cs

C#
No preview (download only).

Get_line2_count.cs

C#
No preview (download only).

Get_line3_count.cs

C#
No preview (download only).

Get_UID.cs

C#
No preview (download only).

get_uid_http.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using System.IO;
using System.Net;
using System;

public class get_uid_http : MonoBehaviour
{
    [SerializeField] Text UID_TEXT;
    public class m2m
    {
        public m2m_2 m2m_cin;
    }

    [System.Serializable]

    public class m2m_2
    {
        public string pi;
        public string ri;
        public string ty;
        public string ct;
        public string st;
        public string rn;
        public string lt;
        public string et;
        public string cs;
        public string cr;
        public string con;
    }
    // Start is called before the first frame update
    void Start()
    {
        Download_uid("http://203.253.128.161:7579/Mobius/AISL_VirtualStore/Uid/la");
    }
    public void Download_uid(string url)
    {
        StartCoroutine(GetText_uid(url));
    }
    IEnumerator GetText_uid(string url)
    {
        UnityWebRequest www = new UnityWebRequest(url);
        DownloadHandlerBuffer text = new DownloadHandlerBuffer();
        www.SetRequestHeader("Accept", "application/json");
        www.SetRequestHeader("X-M2M-RI", "12345");
        www.SetRequestHeader("X-M2M-Origin", "SOrigin");

        www.downloadHandler = text;
        yield return www.SendWebRequest();

        if (!(www.isNetworkError || www.isHttpError))
        {
            Debug.Log("UID");
            string sensor_text = text.text;
            string convert_cin = sensor_text.Replace("m2m:cin", "m2m_cin");
            var con_data = JsonUtility.FromJson<m2m>(convert_cin);
            Debug.Log(con_data.m2m_cin.con);
            UID_TEXT.text = con_data.m2m_cin.con;
        }

    }
}

hand_move.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class hand_move : MonoBehaviour
{
    public GameObject parents;

    public GameObject WRIST;
    public GameObject THUMB_CMC;
    public GameObject THUMB_MCP;
    public GameObject THUMB_IP;
    public GameObject THUMB_TIP;
    public GameObject INDEX_FINGER_MCP;
    public GameObject INDEX_FINGER_PIP;
    public GameObject INDEX_FINGER_DIP;
    public GameObject INDEX_FINGER_TIP;
    public GameObject MIDDLE_FINGER_MCP;
    public GameObject MIDDLE_FINGER_PIP;
    public GameObject MIDDLE_FINGER_DIP;
    public GameObject MIDDLE_FINGER_TIP;
    public GameObject RING_FINGER_MCP;
    public GameObject RING_FINGER_PIP;
    public GameObject RING_FINGER_DIP;
    public GameObject RING_FINGER_TIP;
    public GameObject PINKY_MCP;
    public GameObject PINKY_PIP;
    public GameObject PINKY_DIP;
    public GameObject PINKY_TIP;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        float x_multiplex = -2.5f;
        float y_multiplex = -1.0f;
        float z_multiplex = 4.0f;
        Vector3 parents_vec = parents.transform.position;
        TCP_connection hand_vec = GameObject.Find("hand_line1").GetComponent<TCP_connection>();
        WRIST.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.WRIST.y, y_multiplex * hand_vec.hand_.WRIST.z, z_multiplex * hand_vec.hand_.WRIST.x);

        THUMB_CMC.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.THUMB_CMC.y, y_multiplex * hand_vec.hand_.THUMB_CMC.z, z_multiplex * hand_vec.hand_.THUMB_CMC.x);
        THUMB_MCP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.THUMB_MCP.y, y_multiplex * hand_vec.hand_.THUMB_MCP.z, z_multiplex * hand_vec.hand_.THUMB_MCP.x);
        THUMB_IP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.THUMB_IP.y, y_multiplex * hand_vec.hand_.THUMB_IP.z, z_multiplex * hand_vec.hand_.THUMB_IP.x);
        THUMB_TIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.THUMB_TIP.y, y_multiplex * hand_vec.hand_.THUMB_TIP.z, z_multiplex * hand_vec.hand_.THUMB_TIP.x);

        INDEX_FINGER_MCP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.INDEX_FINGER_MCP.y, y_multiplex * hand_vec.hand_.INDEX_FINGER_MCP.z, z_multiplex * hand_vec.hand_.INDEX_FINGER_MCP.x);
        INDEX_FINGER_PIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.INDEX_FINGER_PIP.y, y_multiplex * hand_vec.hand_.INDEX_FINGER_PIP.z, z_multiplex * hand_vec.hand_.INDEX_FINGER_PIP.x);
        INDEX_FINGER_DIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.INDEX_FINGER_DIP.y, y_multiplex * hand_vec.hand_.INDEX_FINGER_DIP.z, z_multiplex * hand_vec.hand_.INDEX_FINGER_DIP.x);
        INDEX_FINGER_TIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.INDEX_FINGER_TIP.y, y_multiplex * hand_vec.hand_.INDEX_FINGER_TIP.z, z_multiplex * hand_vec.hand_.INDEX_FINGER_TIP.x);

        MIDDLE_FINGER_MCP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.MIDDLE_FINGER_MCP.y, y_multiplex * hand_vec.hand_.MIDDLE_FINGER_MCP.z, z_multiplex * hand_vec.hand_.MIDDLE_FINGER_MCP.x);
        MIDDLE_FINGER_PIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.MIDDLE_FINGER_PIP.y, y_multiplex * hand_vec.hand_.MIDDLE_FINGER_PIP.z, z_multiplex * hand_vec.hand_.MIDDLE_FINGER_PIP.x);
        MIDDLE_FINGER_DIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.MIDDLE_FINGER_DIP.y, y_multiplex * hand_vec.hand_.MIDDLE_FINGER_DIP.z, z_multiplex * hand_vec.hand_.MIDDLE_FINGER_DIP.x);
        MIDDLE_FINGER_TIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.MIDDLE_FINGER_TIP.y, y_multiplex * hand_vec.hand_.MIDDLE_FINGER_TIP.z, z_multiplex * hand_vec.hand_.MIDDLE_FINGER_TIP.x);

        RING_FINGER_MCP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.RING_FINGER_MCP.y, y_multiplex * hand_vec.hand_.RING_FINGER_MCP.z, z_multiplex * hand_vec.hand_.RING_FINGER_MCP.x);
        RING_FINGER_PIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.RING_FINGER_PIP.y, y_multiplex * hand_vec.hand_.RING_FINGER_PIP.z, z_multiplex * hand_vec.hand_.RING_FINGER_PIP.x);
        RING_FINGER_DIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.RING_FINGER_DIP.y, y_multiplex * hand_vec.hand_.RING_FINGER_DIP.z, z_multiplex * hand_vec.hand_.RING_FINGER_DIP.x);
        RING_FINGER_TIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.RING_FINGER_TIP.y, y_multiplex * hand_vec.hand_.RING_FINGER_TIP.z, z_multiplex * hand_vec.hand_.RING_FINGER_TIP.x);

        PINKY_MCP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.PINKY_MCP.y, y_multiplex * hand_vec.hand_.PINKY_MCP.z, z_multiplex * hand_vec.hand_.PINKY_MCP.x);
        PINKY_PIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.PINKY_PIP.y, y_multiplex * hand_vec.hand_.PINKY_PIP.z, z_multiplex * hand_vec.hand_.PINKY_PIP.x);
        PINKY_DIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.PINKY_DIP.y, y_multiplex * hand_vec.hand_.PINKY_DIP.z, z_multiplex * hand_vec.hand_.PINKY_DIP.x);
        PINKY_TIP.transform.position = parents_vec + new Vector3(x_multiplex * hand_vec.hand_.PINKY_TIP.y, y_multiplex * hand_vec.hand_.PINKY_TIP.z, z_multiplex * hand_vec.hand_.PINKY_TIP.x);
    }
}

NewBehaviourScript.cs

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

Credits

minji kim

minji kim

1 project • 1 follower
Andreas Kraft

Andreas Kraft

34 projects • 12 followers
IoT & connected home architect and developer. Ask me about oneM2M.
SeungMyeong Jeong

SeungMyeong Jeong

34 projects • 12 followers
Bob Flynn

Bob Flynn

32 projects • 13 followers
Miguel Angel Reina Ortega

Miguel Angel Reina Ortega

35 projects • 7 followers
Laurent Velez

Laurent Velez

18 projects • 6 followers
Samir Medjiah

Samir Medjiah

21 projects • 14 followers
Xavier Piednoir

Xavier Piednoir

26 projects • 6 followers
Wonbae Son

Wonbae Son

32 projects • 5 followers
안일엽

안일엽

17 projects • 1 follower

Comments