Skip to content

iasonasiasonos/iot_agent_ros2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iot_agent_ros2

Installation

Run the following commands in terminal.

Source ROS2 setup files.

source /opt/ros/humble/setup.bash

Execute nodejs code.

node index.js

Usage

This agent uses the rclnodejs library combined with the Fiware iotagent-node-lib. The agent creates the following

  1. Subscriptions and Publishers for ROS Machines
  2. ROS2 Client
  3. GPIO Action Client for Legacy CNC Machines

Subscriptions and Publishers

The function "initROSDevice" was created to initialize or create new subscribers or publishers. When the agent starts, it locates the already registered/created devices and initializes the existing ROS2 publishers and subscribers for each device. Additionally the agent handles new registrations/creations of publishers and subscribers when a new device is created.

ROS2 Client

You can send your commands and be redirected to your ROS2 device with the rclnodejs Client/Server. The server runs on the actual hardware device and the agent handles in the function called "updateContextHandler" the creation of the ROS2 Client and sends the message to the device.

GPIO Action Client for Legacy CNC Machines

You can send your commands and be redirected to your ROS2 device with the rclnodejs Action Client/Server. The action server runs on the actual hardware device and the agent handles in the function called "updateContextHandler" the creation of the ROS2 Action Client (class called "GPIOActionClient") and sends the message to the device.

Data Models

ROS2 System

{
    "devices": [
        {
            "device_id": "turtle001",
            "entity_name": "urn:ngsiv2:ROS2System:Turtle001",
            "entity_type": "ROS2System",
            "transport": "HTTP",
            "lazy": [
                {"object_id": "pose_lazy", "name": "turtlePoseLazy", "type":"object"},
                {"object_id": "cmd_vel", "name":"setVelocity", "type": "object"}
            ],
            "internal_attributes": [
                {"turtlePoseLazy": {"ros2Interface": {"type":"string","value":"subscriber"},
                                    "topicType":{ "type":"string","value":"turtlesim/msg/Pose"},
                                    "topicName": {"type":"string","value":"/turtle1/pose"},
                                    "throttlingInMilliseconds": {"type":"number", "value": 200 }}
                },
                {"setVelocity": {"ros2Interface": {"type":"string","value":"publisher"},
                                    "topicType":{ "type":"string","value":"geometry_msgs/msg/Twist"},
                                    "topicName": {"type":"string","value":"/turtle1/cmd_vel"},
                                    "throttlingInMilliseconds": {"type":"number", "value": 200 }}
                }
            ],
            "attributes": [
                {
                    "object_id": "pose", "name": "turtlePoseActive", "type": "object",
                    "metadata": {"ros2Interface": {"type":"string", "value":"subscriber"},
                                 "topicType": {"type":"string", "value":"turtlesim/msg/Pose"},
                                 "topicName": {"type":"string", "value":"/turtle1/pose"},
                                 "throttlingInMilliseconds": {"type":"number", "value":200}
                                 }
                }
            ],
            "commands":[
                {
                    "object_id":"start",
                    "name":"start",
                    "type":"command"
                },
                {
                    "object_id":"stop",
                    "name":"stop",
                    "type":"command"
                }
            ]
        }
    ]
}

CNC Legacy Devices

{
    "devices": [
        {
            "device_id":"axis001",
            "entity_name":"urn:ngsi-ld:Axis:001",
            "entity_type":"IOT",
            "endpoint":"https://dihweb.conveyor.cloud/api/api/ThreeAxisEndpoint",
            "transport":"HTTP",
            "attributes":[
                {
                    "object_id":"Status",
                    "name":"Status",
                    "type":"Text"
                }
            ],
            "commands":[
                {
                    "object_id":"start",
                    "name":"start",
                    "type":"command"
                },
                {
                    "object_id":"stop",
                    "name":"stop",
                    "type":"command"
                },
                {
                    "object_id":"auto",
                    "name":"auto",
                    "type":"command"
                }
            ]
        }
    ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published