This package is a support package to the bug-algorithm-using-action-server package developed by Dr. Carmine Recchiuto. This support package is useful to set goal pose and monitoring of the states of bug0-planner package. A brief description of the packages is given below, along with instructions for compiling and running the simulation:
Just to be clear, there are two seperate packages being discussed here:
- bug0-package: bug algorithm using action server package
- monitoring_package: this repository
planning_client:
1. await actionServer.IsInitialized()
2. actionClient.sendGoalToActionServer(x_goal, y_goal).
3. For each Pose received on the topic \odom, do:
1. currentPoseVelocityPublisher.publish(topicName='current_pose_velocity_publisher', receivedPose)
last_target:
1. If the service get_last_target is called:
1. return parameterServer.get_param(des_pos_x, des_pos_y)
distance_from_client:
1. Each time a new pose is received(topicName='current_pose_velocity_publisher'), do:
1. lastTarget = lastTargetService.getLastTargetSentToActionServer()
2. newPose, currentVelocity = distanceFromClientService.getCurrentPoseAndVelocityOfRobot()
3. distance_to_goal = calculateDistance(lastTarget, newPose)
4. avg_x_vel, avg_y_vel = (avg_x_vel+abs(currentVelocity.x))/2, (avg_y_vel+abs(currentVelocity.y))/2
5. store distance_to_goal, avg_x_vel, avg_y_vel in global variables.
2. If the service get_distance_and_avg_velocity is called:
1. return distance_to_goal, avg_x_vel, avg_y_vel
This node consumes Action Server implemented in bug0-package. It is responsible to set target position of the robot. Additionally, it also subscribes to odometry data and publishes robot's current position and velocity. Details are as follows:
planning_client()
:
function which sends target pose to the action server. It waits for the action server to be ready, and then sends the goal pose.
initialize_publisher_subscriber()
:
funciton which initializes publisher (on topic: current_pose_velocity_publisher
) and subscriber (on topic: /odom
).
publishPoseAndVelocity(msg)
:
Callback function to the subscriber (topic: /odom
) which also publishes current pose of the robot on the topic current_pose_velocity_publisher
.
Returns last target from the parameter server.
Returns distance (from current robot pose to the target) and average velocity of the robot.
Launches the following:
assignment1.launch
: A launch file in the bug0 package, which starts the gazebo, rviz and relevant nodes for bug0.planning_client.py
last_target.py
distance_from_client.py
Create a standard Catkin Workspace (assuming you have full-desktop installation of ros noetic. For using docker, refer to this docker image [credits: Dr. Carmine]) and clone the following packages inside /src
:
- this repository (https://github.com/mehhdiii/monitoring_package)
- action server (https://github.com/CarmineD8/assignment_2_2023)
To perform the above steps run the following commands:
cd path_to_your_workspace
source devel/setup.bash
cd src && git clone https://github.com/mehhdiii/monitoring_package && git clone https://github.com/CarmineD8/assignment_2_2023
Finally, in order to run the simulation, use:
roslaunch monitoring_package start_monitoring.launch
To see the distance_to_target
and average_velocity
of the robot:
rosservice call /get_distance_and_avg_velocity
Additonal explainations:
This package implements the bug0 algorithm on ROS noetic. The folder structure is described as follows:
├── action
│ ├── Planning.action
├── config
│ ├── ...
├── launch
│ ├── assignment1.launch
│ ├── sim_w1.launch
├── scripts
│ ├── bug_as.py
│ ├── go_to_point_service.py
│ ├── wall_follow_service.py
├── urdf
│ ├── ...
└── world
│ ├── robot2_laser.gazebo
│ ├── robot2_laser.xacro
└── CMakeList.txt
└── package.xml
Let us briefly go through each file.
geometry_msgs/PoseStamped target_pose
: the goal of the action server. This is set by the action-client
geometry_msgs/Pose actual_pose
and string stat
: the feedback of the action-server. This is returned continously by the action server when the action is is progress.
This is an action message which is used as a data interface when communicating with the action server. It contains the three parts (seperated by three hyphins "---" and in-order):
- goal (
target_pose
): the goal pose. - result (
None
): The result of the action-server. We do not use this in our context. It can although be used to flag success when robot reaches goal. - feedback (
actual_pose, stat
): The actual pose of the robot and stats related to it.
This node is responsible for the implementation of the bug0 algorithm. It takes in environment information, and switches between go_to_point_service and wall_follower_service.
Moves the robot towards the target point when no obstacle between robot and target.
Makes the robot follow a wall in front of it.
launches relevant nodes (bug0, go_to_point, wall_follower, gazebo, rviz) for the simulation
CMakeList.txt
package.xml
The above are standard package files for describing build and runtime dependencies. More details can be found on ros-wiki