A simple package to easily configure and launch rostful.
sudo apt-get install ros-kinetic-rostful
The file config/rostful.cfg is condifured to publish/subscribe topic '/chatter' and to be a client of the service '/add_two_ints'. Thus, you can test basic connections with rostful with the examples in rospy_tutorials package.
By default, the server in configured as 'localhost:5000'.
You can modify this file or make a copy in your own package, modify it, and then launch rostful changing the argument "config_file".
roslaunch rostful_launcher rostful.launch
OR
roslaunch rostful_launcher rostful.launch config_file:="<your_path_to_config_file>"
OR
rosrun rostful_launcher run_rostful.py -c "<your_path_to_config_file>"
To test rostful, follow the instructions on each case.
roslaunch rostful_launcher rostful.launch
- Run the rospy_tutorials examples:
rosrun rospy_tutorials talker.py
- In a web browser, go to the URL: http://localhost:5000/frontend/chatter
- Click on the 'GET LATEST MSG' button. You will see the JSON formatted message.
roslaunch rostful_launcher rostful.launch
- Run the rospy_tutorials examples:
rosrun rospy_tutorials listener.py
- In a web browser, go to the URL: http://localhost:5000/frontend/chatter
- Fill the data field in 'Send message' section. Click on 'POST NEW MSG' button and check the listener.
The rostful web frontend does not support non string types. Thus, for this example, you need to install a REST client plugin (there are plenty in Firefox or Chrome).
roslaunch rostful_launcher rostful.launch
- Run the rospy_tutorials examples:
rosrun rospy_tutorials server_connection_header.py
- From the REST client plugin, set URL to: http://localhost:5000/ros/add_two_ints
- Select POST method, and put the JSON code in the body of the message:
{
"a": 1,
"b": 2
}
- Check the JSON formatted response.
Rostful provides a frontend that allows you to do a first testing very easily. However, as it only support strings, it could very limited for different topics or services. Thus, the best way to test the rostful interface is through a REST client plugin in your web browser.
The frontend is accessed via: http://localhost:5000/frontend/<topic_name>
The URL for the REST client is: http://localhost:5000/ros/<topic_name>
All messages are formatted in JSON. The HTTP method is different on each case:
- Use GET to obtain the latest message received in a subscribed topic.
- Use POST to send a message to a topic.
- Use POST to call a service.