REST API Usage example§

This page will display some examples on how to use the REST API within SENSR.

How to add a new algo node§

  1. Request to create a new algo node in SENSR. You will get the uid as response.
    In this example, we are going to add an algo node with IP address 127.0.0.1.

    $ curl -X PUT 'http://localhost:9080/[SENSR version]/settings/node?ip=127.0.0.1'
    --data '{
        "ip": "127.0.0.1",
        "master_ip": "127.0.0.1",
        "name": "localhost",
        "bin": "",
        "rosbag_path": "",
        "username": "",
        "preset": "indoor",
        "enable_gpu": false
    }'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to delete an algo node§

  1. Request deletion of the node.

    $ curl -X DELETE 'http://localhost:9080/[SENSR version]/settings/node?node-uri=algo_0000'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to modify an algo node§

  1. Request to update the algo node config. Here we use the uid we got earlier when we created it. Here we are updating the algo node's preset. Note that changing the preset will overwrite existing changes to the configuration.

    $ curl -X POST 'http://localhost:9080/[SENSR version]/settings/node' 
    --data '{
        "uid": "algo_0000",
        "ip": "127.0.0.1",
        "master_ip": "127.0.0.1",
        "name": "localhost",
        "bin": "",
        "rosbag_path": "",
        "username": "",
        "preset": "indoor",
        "enable_gpu": false
    }'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    
  3. Request reload to restart the algo node with the new changes

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/reload'
    

How to add a new sensor§

  1. Request to create a new sensor in SENSR. You will get an uid of the newly added sensor in response. Note that this might fail if certain conditions are not met, such as if there is already a sensor with the same topic in the algo node.

    $ curl -X PUT 'http://localhost:9080/[SENSR version]/settings/sensor-ext?node-uri=algo_0000&sensor-type=lidar'
    --data '{
    "name": "PointCloud",
    "topic": "/lidar0/velodyne_points",
    "sensor": "ROS Message",
    "stack_capacity": 0,
    "detection_radius": 1000.0,
    "horizontal_angle_range": [-180.0, 180.0],
    "use_lidar_timestamp" : false,
    "use_intensity_filtering" : false,
    "minimum_intensity": 0.0,
    "retro_reflective_intensity": 250.0
    "base_to_origin": {
            "tx": -0.08,
            "ty": 3.97
    },
    "sensor_to_base": {
            "tz": 2.15,
            "qw": 0.48,
            "qx": -0.09,
            "qy": -0.03,
            "qz": 0.86
    },
    "arguments": {}
    }'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to delete a sensor§

  1. Request deletion of the sensor.

    $ curl -X DELETE 'http://localhost:9080/[SENSR version]/settings/sensor-ext?sensor-id=lidar_0000'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to modify a sensor§

  1. Get current sensor config with a specific uid (e.g. lidar_0000)

    $ curl -X GET 'http://localhost:9080/[SENSR version]/settings/sensor-ext?sensor-id=lidar_0000'
    
  2. Modify json with your desired data

  3. Request to update the sensor config

    $ curl -X POST 'http://localhost:9080/[SENSR version]/settings/sensor-ext' 
    --data '{
    "uid": "lidar_0000"
    "name": "PointCloud",
    "topic": "/lidar1/velodyne_points",
    "sensor": "ROS Message",
    "stack_capacity": 0,
    "detection_radius": 1000.0,
    "horizontal_angle_range": [-180.0, 180.0],
    "use_lidar_timestamp" : false,
    "use_intensity_filtering" : false,
    "minimum_intensity": 0.0,
    "retro_reflective_intensity": 250.0
    "base_to_origin": {
            "tx": 0.0,
            "ty": 0.0
    },
    "sensor_to_base": {
            "tz": 0.0,
            "qw": 1.0,
            "qx": 0.0,
            "qy": 0.0,
            "qz": 0.0
    },
    "arguments": {}
    }'
    
  4. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to add a new zone§

  1. Request to create a new zone in SENSR. You will get an id of the newly added zone in response. Note that the "id"-field must not overlap with an existing zone.

     curl -X PUT 'http://localhost:9080/[SENSR version]/settings/zone' 
    --data '{
            "id": 1001,
            "name": "zone-1001",
            "zone_type": "Event",
            "speed_limit": 27.77,
            "loitering_threshold": 0,
            "min_z": 0.0,
            "max_z": 2.5,
            "vertices": [
            [
                    -4.04,
                    5.27
            ],
            [
                    -3.68,
                    3.32
            ],
            [
                    -5.65,
                    3.02
            ],
            [
                    -5.96,
                    4.85
            ]
            ]
    }'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to delete a zone§

  1. Request deletion of the zone and save configs.

    $ curl -X DELETE 'http://localhost:9080/[SENSR version]/settings/zone?zone-id=1001'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to modify zone§

  1. Get current zone config with a specific sensor-id (e.g. 1001)

    $ curl -X GET 'http://localhost:9080/[SENSR version]/settings/zone?zone-id=1001'
    
  2. Modify json with your desired data

  3. Request to update the sensor config

    $ curl -X POST 'http://localhost:9080/[SENSR version]/settings/zone' 
    --data '{
    "id": 1001,
    "name": "zone-1001",
    "zone_type": "Event",
    "speed_limit": 27.77,
    "loitering_threshold": 0,
    "min_z": 0.0,
    "max_z": 2.5,
    "vertices": [
            [
                8.95,
                -21.91
            ],
            [
                -13.30,
                -25.27
            ],
            [
                -12.95,
                -4.06
            ],
            [
                16.37,
                5.74
            ],
            [
                9.58,
                -21.35
            ]
    ]
    }'
    
  4. Request save configs

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/apply-change'
    

How to record rosbag or background points§

  1. record command takes data body for detail setup. You can pass capture_rosbag or capture_point to record rosbag and background points.

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{
            "capture_rosbag": false,
            "capture_point": true,
            "max_time": 10.0
    }'
    'http://localhost:9080/[SENSR version]/commands/record/start?name=replay0003''
    
  2. (optional) Request stop recording. (You can explicitly stop recording before recording reach max_time.)

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/record/stop'
    

How to cancel recording save§

  1. Request stop recording. (If you want cancel before recording reach max_time, stop should be called first.)

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/record/stop'
    
  2. If you enable capture_rosbag in multiple algo nodes situation, saving file can take very long. You can cancel saving process by calling commands/record/cancel command.

    $ curl -X POST 'http://localhost:9080/[SENSR version]/commands/record/cancel'