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§
-
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'
-
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'
-
Modify json with your desired data
-
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'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to delete an algo node§
-
Request deletion of the node.
$ curl -X DELETE 'http://localhost:9080/settings/node?node-uri=algo_0000'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to modify an algo node§
-
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'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to change an algo node's preset§
-
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'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
-
Request reload
$ curl -X POST 'http://localhost:9080/commands/reload'
How to add a new sensor§
-
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'
-
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'
-
Modify json with your desired data
-
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'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to delete a sensor§
-
Request deletion of the sensor.
$ curl -X DELETE 'http://localhost:9080/settings/sensor-ext?sensor-id=lidar_0000'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to modify a sensor§
-
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'
-
Modify json with your desired data
-
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''
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to add a new zone§
-
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'
-
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'
-
Modify json with your desired data
-
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'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to delete a zone§
-
Request deletion of the zone and save configs.
$ curl -X DELETE 'http://localhost:9080/settings/zone?zone-id=1001'
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to modify zone§
-
Get current zone config with a specific sensor-id (e.g. 1001)
$ curl -X GET 'http://localhost:9080/settings/zone?zone-id=1001'
-
Modify json with your desired data
-
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''
-
Request save configs
$ curl -X POST 'http://localhost:9080/commands/apply-change'
How to record rosbag or background points§
-
record
command takes data body for detail setup. You can passcapture_rosbag
orcapture_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''
-
(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§
-
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'
-
If you enable
capture_rosbag
in multiple algo nodes situation, saving file can take very long. You can cancel saving process by callingcommands/record/cancel
command.$ curl -X POST 'http://localhost:9080/commands/record/cancel'