Ronoco-vm API - Detailed documentation

Run

Define and setup flask server and rostopic subscriber / publisher for ronoco-vm

create_app(test_config)

Build a Flask instance and configure it

Parameters

  • test_config: path to configuration file (Default : None)

Return a Flask instance

setup_app()

Register blueprint in app.

The class attribute "app" must contain a Flask instance

Return None

subscribe_topic()

Uses rospy to subscribe to the different topics needed by the API

Common

Definition of common endpoint

index()

GET Method

ROUTE /

Return if everything is OK : {"Success": "Server is running"}, 200

send_states()

This function check if the state of the robot or rviz has changed. If so, it sends a message to the websockets states channel

ros_state()

Check if you can communicate with MoveIT

  • Use rosservice /move_group/get_loggers
  • Node: /move_group
  • Type: roscpp/GetLoggers
  • Args:

Return True if communication with rosmaster is possible, False else

moveit_state()

Check if you can communicate with moveit

  • Use rosservice /move_group/get_loggers
  • Node: /move_group
  • Type: roscpp/GetLoggers
  • Args:

Return True if communication with moveit is possible, False else

rviz_state()

Check if rviz send data on topic /rviz_moveit_motion_planning_display/robot_interaction_interactive_marker_topic /update

Return False if rviz doesn't send data, True else

shutdown()

GET Method

ROUTE /shutdown

Shutdown server with config.socketio.stop() (and shutdown send_states() daemon)

Free

Implements free endpoints to set and get the compliance (or 0 gravity robot WIP) of robot

free()

GET/POST Method

ROUTE /free/

POST body { "compliant" : "True"/"False" }

Allows you to get or set robot compliance

  • Use rosservice /set_compliant
  • Node: /joint_trajectory_action_server
  • Type: std_srvs/SetBool
  • Args: data

Return if everything is OK : {"compliant":"True"/"False"} else an HttpError

CartesianPoint

Allows adding, get and delete a cartesian point in the ros parameters server from Rviz or compliant mode

add_bd(cartesian_point)

This method adds a cartesian point in the ros parameters server (on the name "cartesianPoints"). This method is called when a POST request is made on point/add/simulation or point/add/real

Parameters

  • cartesian_point: a cartesian point eg {"position": {"x": pose.x, "y": pose.y, "z": pose.z}, "orientation": {"x": orientation.x, "y": orientation.y, "z": orientation.z, "w": orientation.w}}

Return True if everything is OK

delete_db(identifiant)

This method deletes a cartesian point in the ros parameters server (on the name "cartesianPoints"). This method is called when a DELETE request is made on point/delete

Parameters

  • identifiant: a number

Return True if point is deleted, False if point doesn't exist

find_db(identifiant)

This method find a cartesian point in the ros parameters server (on the name "cartesianPoints"). This method is called when a GET request is made on point/get/number or point/get

Parameters

  • identifiant: a number

Return True if point is found, False if point doesn't exist

clear_db()

This method deletes all cartesian points in the ros parameters server (on the name "cartesianPoints"). This method is called when a POST request is made on point/delete

add_point_from_actual_position()

POST Method

ROUTE /point/add/actual

POST body { }

Allows you to add a Cartesian point corresponding to the current position of the robot.

The id of the position is automatically given

Return id for new cartesian point if everything is OK, a 409 error else

add_point_from_rviz()

POST Method

ROUTE /point/add/simulation

POST body { }

Allows you to add a Cartesian point corresponding to the current position of the robot in Rviz.

The id of the position is automatically given

Return id for new cartesian point if everything is OK, a 408 error else

get_all_points()

GET Method

ROUTE /point/get

Allows you to get all Cartesian points in the ros parameters server (on the name "cartesianPoints")

Return a json with cartesian points if everything is OK, a 404 error else

get_one_point(identifiant)

GET Method

ROUTE /point/get/

Allows you to get one Cartesian point in the ros parameters server (on the name "cartesianPoints")

Parameters

  • identifiant: a number

Return a json with cartesian point it exists, a 404 error else

delete_one_point(identifiant)

POST Method

ROUTE /point/delete/

POST body { }

Allows you to delete one Cartesian point in the ros parameters server (on the name "cartesianPoints")

Parameters

  • identifiant: a number

Return a response 200 if the point have been deleted, a 404 error else

delete_all_points

POST Method

ROUTE /point/delete

POST body { }

Allows you to delete all Cartesian points in the ros parameters server (on the name "cartesianPoints")

Return a response 200

Control

Definition of the endpoint control to analyse and execute behaviour trees

compute()

POST Method

ROUTE /compute/

POST body : an export of nodered tree

This method is the main method of the endpoint to transform the json from nodered (or any other tool respecting the json syntax) into a behaviour tree with the py_tree package. Once built, the method call play then executes the different trees.

Every behaviour tree starts with a root block, blocks that are not connected (directly or indirectly) to a root are ignored.

Each root must be connected to strictly one block to be interpreted.

To be interpreted a flow must contain at least one behaviour tree

Return

  • {"Success" : "All behavior trees has been executed", 200} if the tree is built and executed correctly.
  • {"Error": "Block (or child of this block) with id is incorrect", 400} if it is not

play()

Browse the list of previously constructed trees and execute them using the tick_tock method Return Message with code 200 if all trees has been executed, code 409 else

find_roots(bt)

Search in BT-json blocks with type 'root'

Parameters

  • bt: a json representing a behaviour tree (export of nodered)

Return the list of roots found in the json passed in parameter if there are any, an empty list otherwise

find_by_id(identifiant, bt)

Search in the json passed in parameter for a block with the string id passed in parameter

Parameters

  • identifiant: the id of the block searched for
  • bt: a json representing a behaviour tree (export of nodered)

Return True and the root (json) if a root has this id. False, None else

build_tree(json_node, bt)

Builds the behaviour tree as a py_tree object from its root using a bfs algorithm

Parameters

  • json_node: a node of a tree in json format
  • bt: a json representing a behaviour tree (export of nodered)

Return True and None if tree has been built. False and the id of the last block built if it could not be built

build_decorator(node, bt)

Transforms a decorator from a json to a py_tree object. In order to build the decorators it is necessary that the other blocks are already built

Parameters

  • node: the decorator in json format
  • bt: a json representing a behaviour tree (export of nodered)

Return True, None if everything is OK, False and an id else

multiple_data_nodes(node_json)

Analyses the data of a node and according to its type correctly formats the data dictionary.

Normally this function only returns the data field of the node but some special nodes escape this rule.

Parameters

  • node_json: the node to evaluate

Return False, None if a data is expected but not present. True and the correctly formatted dictionary else

build_nodes(bt)

Transforms all the nodes of the tree from json form to py_tree form. This function does not handle decorator blocks that need special treatment concerning their children

Parameters

  • bt: a json representing a behaviour tree (export of nodered)

Return True, None if everything is OK, False and an id else

stop()

Stop execute of current behavior tree

Recorder

Recorder class copy from Poppy project

start_recording

Start the recording of a trajectory

Return False if a record is already in progress, True else

stop_and_save(trajectory_name)

Stop recording then save it as a json file

Parameters

  • trajectory_name: record's name

Return False if another record is in progress, True else

load(, trajectory_name)

Find in the trajectory directory json file with a specific name the convert it in a RobotTrajectory Parameters

  • trajectory_name: name of a previously recorded path

Return None if the trajectory does not exist, a RobotTrajectory else

Logger

Definition of a logger for the websocket to be displayed in ronoco-ui

logger(msg)

Send a message to the /control_log namespace via socketio's emit method The message must be a dictionary with at least one key/value

Some particular keys will be interpreted and reformatted by ronoco-ui (Debug, Success, Error, Warning, Info)

The other keys will be displayed rawly way

Parameters

  • msg: the message to send

debug(msg)

Sends a message with the debug key if the verbosity level is greater than or equal to 4

Parameters

  • msg: a string message

info(msg)

Sends a message with the info key if the verbosity level is greater than or equal to 3

Parameters

  • msg: a string message

warn(msg)

Sends a message with the warn key if the verbosity level is greater than or equal to 2

Parameters

  • msg: a string message

error(msg)

Sends a message with the error key if the verbosity level is greater than or equal to 1

Parameters

  • msg: a string message