From cd20e37b65b83bf3502ae468de797c3e761b8241 Mon Sep 17 00:00:00 2001 From: Pooyan Jamshidi Date: Sat, 28 Apr 2018 12:45:48 -0400 Subject: [PATCH] Added documentation --- README.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 296567b..e925d03 100755 --- a/README.md +++ b/README.md @@ -1,2 +1,124 @@ # Functionality -The configuration manager of the bot that receives the power consumption of a list of robot configurations and maintain the current configuration of the robot. When the configuration of the robot will change, it will reflect the change to power consumption by changing the power load of the robot battery plugin. \ No newline at end of file +The configuration manager of the bot that receives the power consumption of a list of robot configurations and maintain the current configuration of the robot. When the configuration of the robot will change, it will reflect the change to power consumption by changing the power load of the robot battery plugin. + +# Support +This plugin is tested for ROS kinetic and Gazebo 7.8.1. + +# Build +Create the build directory: +```bash +mkdir ~/catkin_ws/src/brass_gazebo_config_manager/build +cd ~/catkin_ws/src/brass_gazebo_config_manager/build +``` + +Make sure you have sourced ROS before compiling the code: +```bash +source /opt/ros//setup.bash +``` + +Compile the code: +```bash +cmake ../ +make +``` + +Compiling will result in a shared library, `~/catkin_ws/src/brass_gazebo_config_manager/build/devel/lib/libconfig_manager.so`, that can be inserted in a Gazebo simulation. + +Lastly, add your library path to the `GAZEBO_PLUGIN_PATH`: +```bash +export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:~/catkin_ws/src/brass_gazebo_config_manager/build/devel/lib +``` + +# Build by catkin +Build the plugin by going to the base of your work space and running catkin: +```bash +cd ~/catkin_ws +catkin_make +``` + +# Installing the Plugin +```bash +cd ~/catkin_ws/src/brass_gazebo_config_manager/build +cmake ../ +make +sudo make install +``` + +# Usage + +In the brass.world file, `libconfig_manager.so` is mentioned as a plugin. +This implied that plugin is initialized and loaded when `p2-cp1.world` is opened in Gazebo. +The xml code could be linked to any model in a new `.world` file. +```xml + + /cp1/config_list.json + 0 + cp1_node + +``` + +# Run the Plugin +```bash +cd ~/catkin_ws/src/brass_gazebo_config_manager +gazebo test/worlds/p2-cp1.world --verbose +``` + + +# Exposed ROS services and topics + +This Gazebo plugin expose several services that can be accessed via ROS: + +``` +/battery_monitor_client/battery_demo_model/get_config +/battery_monitor_client/battery_demo_model/set_config +``` + +Also, this publish information about the status of robot battery to the following topics: +``` +/mobile_base/commands/charge_level +/mobile_base/commands/motor_power +``` + +# Extending ROS Services + +First create the service description file `.srv` and put it in the `srv` folder. Then declare it in the `CMakeList.txt` in the +`add_service_files()` section. Also, add the following to the `CMakeList.txt`: +```cmake +generate_messages( +DEPENDENCIES +std_msgs # Or other packages containing msgs +) +``` + +For updating the parameters of the battery model we use ROS services, +so here we explain how to add new services to the code if needed: + +```bash +cd ~/catkin_ws +catkin_make +``` +The header files associated to the service can be found here: + +```bash +cd ~/catkin_ws/devel/include/brass_gazebo_battery +``` +The add the following header into the code that want to use the services: + +```cpp +#include "brass_gazebo_battery/SetLoad.h" +``` +And then add the following declaration: + +```cpp +public: bool ServiceName(brass_gazebo_battery::SetLoad::Request& req, brass_gazebo_battery::SetLoad::Response& res); +``` +The service can then be advertised as follows: + +```cpp +this->rosNode->advertiseService(this->model->GetName() + "/api", &Plugin::ServiceName, this); +``` + + +# Maintainer + +If you need a new feature to be added, please contact [Pooyan Jamshidi](https://pooyanjamshidi.github.io) \ No newline at end of file