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 127.0.0.1 ip address.)

    $ curl -X PUT 'http://localhost:9080/settings/node?ip=127.0.0.1'
    
  2. Get a json table of the newly added node with uid in step 1.

    $ curl -X GET 'http://localhost:9080/settings/node?node-uri=algo_0000'
    
  3. Modify json with your desired data

  4. Post the modified json data

    $ curl -X POST
    --header "Content-Type: application/json"
    --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 }
    'http://localhost:9080/settings/node?node-uri=algo_0000'
    
  5. Request save configs

    $ curl -X POST 'http://localhost:9080/commands/apply-change'
    

How to delete an algo node§

  1. Request deletion of the node.

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

    $ curl -X POST 'http://localhost:9080/commands/apply-change'
    

How to modify an algo node§

  1. Request to update the generic node configs

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{ "ip": "127.0.0.1",
        "master_ip": "127.0.0.1",
        "name": "localhost",
        "bin": "",
        "rosbag_path": "",
        "username": "",
        "preset": "indoor",
        "enable_gpu": false}'
    'http://localhost:9080/settings/node?node-uri=algo_0000'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/commands/apply-change'
    

How to change an algo node's preset§

  1. Request to update the algo node with a new preset. For this example let's assume it was using the outdoor preset before. We change to the indoor preset. Note that changing the preset will overwrite existing changes to the configuration.

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{ "ip": "127.0.0.1",
        "master_ip": "127.0.0.1",
        "name": "localhost",
        "bin": "",
        "rosbag_path": "",
        "username": "",
        "preset": "indoor",
        "enable_gpu": false}'
    'http://localhost:9080/settings/node?node-uri=algo_0000'
    
  2. Request save configs

    $ curl -X POST 'http://localhost:9080/commands/apply-change'
    
  3. Request reload

    $ curl -X POST 'http://localhost:9080/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.

    $ curl -X PUT 'http://localhost:9080/settings/sensor-ext?&node-uri=algo_0000&sensor-type=lidar'
    
  2. Get a json table of the newly added sensor with the id in step 1.

    $ curl -X GET 'http://localhost:9080/settings/sensor-ext?&sensor-id=lidar_0000'
    
  3. Modify json with your desired data

  4. Post the modified json data(topic must not overlap.)

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{
        "name": "PointCloud",
        "topic": "/lidar0/velodyne_points",
        "sensor": "ROS Message",
        "stack_capacity": 0,
        "arguments": {},
        "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
        },
        "detection_radius": 1000.0,
        "use_intensity_filtering": false,
        "minimum_intensity": 0.0
    }'
    'http://localhost:9080/settings/sensor-ext?sensor-id=lidar_0000'
    
  5. Request save configs

    $ curl -X POST 'http://localhost:9080/commands/apply-change'
    

How to delete a sensor§

  1. Request deletion of the sensor.

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

    $ curl -X POST 'http://localhost:9080/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/settings/sensor-ext?sensor-id=lidar_0000'
    
  2. Modify json with your desired data

  3. Request to update the sensor config

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{
        "name": "PointCloud",
        "topic": "/lidar1/velodyne_points",
        "sensor": "ROS Message",
        "stack_capacity": 0,
        "arguments": {},
        "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
        },
        "detection_radius": 1000.0,
        "use_intensity_filtering": false,
        "minimum_intensity": 0.0
    }'
    'http://localhost:9080/settings/sensor-ext?sensor-id=lidar_0000''
    
  4. Request save configs

    $ curl -X POST 'http://localhost:9080/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.

    $ curl -X PUT 'http://localhost:9080/settings/zone'
    
  2. Get a json table of the newly added zone with the id in step 1.

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

  4. Post the modified json data to SENSR using zone id.(id must not overlap.)

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{
        "id": 1001,
        "name": "zone-1001",
        "zone_type": 1,
        "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
            ]
        ]
    }'
    'http://localhost:9080/settings/zone?zone-id=1001'
    
  5. Request save configs

    $ curl -X POST 'http://localhost:9080/commands/apply-change'
    

How to delete a zone§

  1. Request deletion of the zone and save configs.

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

    $ curl -X POST 'http://localhost:9080/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/settings/zone?zone-id=1001'
    
  2. Modify json with your desired data

  3. Request to update the sensor config

    $ curl -X POST
    --header "Content-Type: application/json"
    --data '{
        "id": 1001,
        "name": "zone-1001",
        "zone_type": 1,
        "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
            ]
        ]
    }'
    'http://localhost:9080/settings/zone?zone-id=1001''
    
  4. Request save configs

    $ curl -X POST 'http://localhost:9080/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/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/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/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/commands/record/cancel'