fazildgr8 / ros_autonomous_slam

ROS package which uses the Navigation Stack to autonomously explore an unknown environment with help of GMAPPING and constructs a map of the explored environment. Finally, a path planning algorithm from the Navigation stack is used in the newly generated map to reach the goal. The Gazebo simulator is used for the simulation of the Turtlebot3 Waffle Pi robot. Various algorithms have been integrated for Autonomously exploring the region and constructing the map with help of the 360-degree Lidar sensor. Different environments can be swapped within launch files to generate a map of the environment.
http://mohamedfazil.com
MIT License
209 stars 69 forks source link

Robot not moving forward #2

Open kvnptl opened 3 years ago

kvnptl commented 3 years ago

After setting everything up as suggested, turtlebot is not moving. It seems RRT node is working fine, but the robot is not receiving any commands on /cmd_vel topic.

Please take a look at below video: robot-not-moving

Please suggest some changes to make it work.

fazildgr8 commented 3 years ago

Hello Kevin, could you share all the topics present at the moment and make sure your robot's /cmd_vel topic is present. And also make sure the Official Navigation stack is installed properly. You can verify the working of the Navigation stack by placing "2D Nav Goal" somewhere within the visible map (Grey Area) in RVIZ by then the Robot should be planning a path and moving towards the goal.

kvnptl commented 3 years ago

Thanks for your response,

1) /cmd_vel topic is there, bit nothing is published on it.

$rostopic list
/camera/parameter_descriptions
/camera/parameter_updates
/camera/rgb/camera_info
/camera/rgb/image_raw
/camera/rgb/image_raw/compressed
/camera/rgb/image_raw/compressed/parameter_descriptions
/camera/rgb/image_raw/compressed/parameter_updates
/camera/rgb/image_raw/compressedDepth
/camera/rgb/image_raw/compressedDepth/parameter_descriptions
/camera/rgb/image_raw/compressedDepth/parameter_updates
/camera/rgb/image_raw/theora
/camera/rgb/image_raw/theora/parameter_descriptions
/camera/rgb/image_raw/theora/parameter_updates
/centroids
/centroids_array
/clicked_point
/clock
/cmd_vel
/detected_points
/filtered_points
/frontiers
/frontiers_array
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/global_detector_shapes
/global_detector_shapes_array
/imu
/initialpose
/joint_states
/local_detector_shapes
/map
/map_metadata
/map_updates
/move_base/DWAPlannerROS/cost_cloud
/move_base/DWAPlannerROS/global_plan
/move_base/DWAPlannerROS/local_plan
/move_base/DWAPlannerROS/parameter_descriptions
/move_base/DWAPlannerROS/parameter_updates
/move_base/DWAPlannerROS/trajectory_cloud
/move_base/NavfnROS/plan
/move_base/cancel
/move_base/current_goal
/move_base/feedback
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/global_costmap/inflation_layer/parameter_descriptions
/move_base/global_costmap/inflation_layer/parameter_updates
/move_base/global_costmap/obstacle_layer/parameter_descriptions
/move_base/global_costmap/obstacle_layer/parameter_updates
/move_base/global_costmap/parameter_descriptions
/move_base/global_costmap/parameter_updates
/move_base/global_costmap/static_layer/parameter_descriptions
/move_base/global_costmap/static_layer/parameter_updates
/move_base/goal
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base/local_costmap/footprint
/move_base/local_costmap/inflation_layer/parameter_descriptions
/move_base/local_costmap/inflation_layer/parameter_updates
/move_base/local_costmap/obstacle_layer/parameter_descriptions
/move_base/local_costmap/obstacle_layer/parameter_updates
/move_base/local_costmap/parameter_descriptions
/move_base/local_costmap/parameter_updates
/move_base/parameter_descriptions
/move_base/parameter_updates
/move_base/recovery_status
/move_base/result
/move_base/status
/move_base_simple/goal
/odom
/rosout
/rosout_agg
/scan
/tf
/tf_static
/turtlebot3_slam_gmapping/entropy

2) Nvigation stack is working fine. I have checked '2D Nav Goal' and it worked perfectly.

fazildgr8 commented 3 years ago

Your frontier points (/frontiers or /frontiers_array) aren't being published I guess. Because these frontier points array are sent as a sequence of goals to the Navigation Stack and then the robot starts to accomplish each goal in sequence. Could you please monitor both the topics mentioned above? Further Debugging, In the code assigner.py, it is the node that takes care of sending the Frontier points to Navigation Stack. Line 60 to 99 performs the frontier assignment task divided into different secctions. Please monitor the Variables present within it to figure out the issue.

kvnptl commented 3 years ago

Yes, /frontiers and /filtered_points are not published. And because of that the code get stuck at line 61 while loop in assigner.py

Is it running fine at your end?

fazildgr8 commented 3 years ago

Yes it does run in my end as it should. I back tracked publishing script filter.py which publishes the /filtered_points which is computed from the map data received. I probably feel the correct map is not received by this node. Are you getting a status printed in the terminal such as 'waiting for the map' (Line 87) or 'waiting for the global costmap' (Line 93) . Could you try to verify this.

kvnptl commented 3 years ago

After running roslaunch ros_autonomous_slam autonomous_explorer.launch It receives two warnings about global_costmap and local_costmap as shown below output. It also printed Waiting for the map and then the map and global costmaps are received. Stuck in while loop at line 117 in filter.py Becuase nothing published on /detected_points topic (publisher nodes /global_detector and /local_detector).

ROS_MASTER_URI=http://localhost:11311

process[robot_state_publisher-1]: started with pid [13465]
process[turtlebot3_slam_gmapping-2]: started with pid [13466]
process[rviz-3]: started with pid [13472]
process[move_base-4]: started with pid [13478]
process[global_detector-5]: started with pid [13480]
process[local_detector-6]: started with pid [13487]
process[filter-7]: started with pid [13493]
process[assigner-8]: started with pid [13496]
[ WARN] [1614767930.302246447, 28.106000000]: global_costmap: Parameter "plugins" not provided, loading pre-Hydro parameters
[ INFO] [1614767930.375624425, 28.173000000]: global_costmap: Using plugin "static_layer"
[ INFO] [1614767930.397749136, 28.194000000]: Requesting the map...
[ INFO] [1614767930.453828004, 28.245000000]: Laser is mounted upwards.
 -maxUrange 3 -maxUrange 3.49 -sigma     0.05 -kernelSize 1 -lstep 0.05 -lobsGain 3 -astep 0.05
 -srr 0.1 -srt 0.2 -str 0.1 -stt 0.2
 -linearUpdate 1 -angularUpdate 0.2 -resampleThreshold 0.5
 -xmin -10 -xmax 10 -ymin -10 -ymax 10 -delta 0.05 -particles 100
[ INFO] [1614767930.463897044, 28.255000000]: Initialization complete
update frame 0
update ld=0 ad=0
Laser Pose= -2.06358 0.50001 -3.14149
m_count 0
Registering First Scan
[ INFO] [1614767930.731678311, 28.502000000]: Resizing costmap to 384 X 384 at 0.050000 m/pix
[ INFO] [1614767930.839127653, 28.605000000]: Received a 384 X 384 map at 0.050000 m/pix
[ INFO] [1614767930.859364899, 28.620000000]: global_costmap: Using plugin "obstacle_layer"
[ INFO] [1614767930.882651890, 28.640000000]:     Subscribed to Topics: scan
[ INFO] [1614767930.932313620, 28.687000000]: global_costmap: Using plugin "inflation_layer"
[ WARN] [1614767931.059289027, 28.806000000]: local_costmap: Parameter "plugins" not provided, loading pre-Hydro parameters
[ INFO] [1614767931.090770581, 28.829000000]: local_costmap: Using plugin "obstacle_layer"
[ INFO] [1614767931.098395390, 28.836000000]:     Subscribed to Topics: scan
update frame 3
update ld=2.43988e-07 ad=2.18327e-06
Laser Pose= -2.06358 0.500011 -3.14149
m_count 1
[ INFO] [1614767931.131233657, 28.866000000]: local_costmap: Using plugin "inflation_layer"
[ INFO] [1614767931.240610224, 28.966000000]: Created local_planner dwa_local_planner/DWAPlannerROS
[ INFO] [1614767931.252127731, 28.977000000]: Sim period is set to 0.10
Average Scan Matching Score=201.843
neff= 100
Registering Scans:Done
[ INFO] [1614767931.583432394, 29.261000000]: Recovery behavior will clear layer 'obstacles'
[ INFO] [1614767931.620712095, 29.297000000]: Recovery behavior will clear layer 'obstacles'
[ INFO] [1614767931.776447356, 29.427000000]: odom received!
update frame 6
update ld=2.45e-07 ad=2.19233e-06
Laser Pose= -2.06358 0.500011 -3.14148
m_count 2
Average Scan Matching Score=202.069
neff= 100
Registering Scans:Done
update frame 9
update ld=2.44179e-07 ad=2.18499e-06
Laser Pose= -2.06358 0.500011 -3.14148
m_count 3
[INFO] [1614767932.792079, 0.000000]: Waiting for the map
Average Scan Matching Score=202.024
neff= 100
Registering Scans:Done
update frame 12
update ld=2.444e-07 ad=2.18697e-06
Laser Pose= -2.06358 0.500011 -3.14148
m_count 4
[INFO] [1614767933.218428, 30.714000]: the map and global costmaps are received
Average Scan Matching Score=203.128
neff= 100
Registering Scans:Done
update frame 15
update ld=2.44782e-07 ad=2.19038e-06
Laser Pose= -2.06358 0.500012 -3.14148
m_count 5
Average Scan Matching Score=204.059
neff= 100
Registering Scans:Done
update frame 18
.
.
.
.

(same message continue)

2) Rviz Marker Error: error1

kvnptl commented 3 years ago

I just checked ObstacleFree function in global_rrt_detector.cpp is giving some erroneous output other than 1 and -1. (same for local_rrt_detector.cpp)

kvnptl commented 3 years ago

Can you please share your update on this issue?

rodrigoaantunes commented 3 years ago

Can you please share your update on this issue?

I'm with the same problem, same environment and same error. Did you found a solution?

kvnptl commented 3 years ago

@rodrigoaantunes nope, not yet

batti-nesrine commented 3 years ago

I have the same issue but the package worked fine earlier this day, now i can't get it to work [same environment and same error]. Anyone found a solution ?

Avi241 commented 2 years ago

I have also faced the same problem. Please check when you run explorer.launch whether there is an error of sklearn no found ? If yes just install the sklearn package and relaunch the explorer, the robot will start moving. python -m pip install sklearn

SinanK94 commented 2 years ago

I have also the same problem. I used ROS melodic before and everything was fine, but now I am using ROS noetic and the robot is not moving anymore.

SinanK94 commented 2 years ago

The robot is moving right now, I fixed the issue. Could somebody please verify my solution? What I only did was to change the filter.py code.

old filter.py:

while z < len(centroids):
            cond = False
            temppoint.point.x = centroids[z][0]
            temppoint.point.y = centroids[z][1]

            for i in range(0, n_robots):

                transformedPoint = tfLisn.transformPoint(
                    globalmaps[i].header.frame_id, temppoint)
                x = array([transformedPoint.point.x, transformedPoint.point.y])
                cond = (gridValue(globalmaps[i], x) > threshold) or cond
            if (cond or (informationGain(mapData, [centroids[z][0], centroids[z][1]], info_radius*0.5)) < 0.2):
                centroids = delete(centroids, (z), axis=0)
                z = z-1
            z += 1
# -------------------------------------------------------------------------
# publishing
        arraypoints.points = []
        for i in centroids:
            tempPoint.x = i[0]
            tempPoint.y = i[1]
            arraypoints.points.append(copy(tempPoint))
        filterpub.publish(arraypoints)
        pp = []
        for q in range(0, len(frontiers)):
            p.x = frontiers[q][0]
            p.y = frontiers[q][1]
            pp.append(copy(p))
        points.points = pp
        pp = []
        for q in range(0, len(centroids)):
            p.x = centroids[q][0]
            p.y = centroids[q][1]
            pp.append(copy(p))
        points_clust.points = pp
        pub.publish(points)
        pub2.publish(points_clust)
        rate.sleep()

new filter.py:

  while z < len(centroids):
            cond = False
            temppoint.point.x = centroids[z][0]
            temppoint.point.y = centroids[z][1]

            for i in range(0, n_robots):

                transformedPoint = tfLisn.transformPoint(
                    globalmaps[i].header.frame_id, temppoint)
                x = array([transformedPoint.point.x, transformedPoint.point.y])
                cond = (gridValue(globalmaps[i], x) > threshold) or cond
            if (cond or (informationGain(mapData, [centroids[z][0], centroids[z][1]], info_radius*0.5)) < 0.2):
                centroids = delete(centroids, (z), axis=0)
                z = z-1
            z += 1
# -------------------------------------------------------------------------
# publishing
              arraypoints.points = []
              for i in centroids:
                  tempPoint.x = i[0]
                  tempPoint.y = i[1]
                  arraypoints.points.append(copy(tempPoint))
              filterpub.publish(arraypoints)
              pp = []
              for q in range(0, len(frontiers)):
                  p.x = frontiers[q][0]
                  p.y = frontiers[q][1]
                  pp.append(copy(p))
              points.points = pp
              pp = []
              for q in range(0, len(centroids)):
                  p.x = centroids[q][0]
                  p.y = centroids[q][1]
                  pp.append(copy(p))
              points_clust.points = pp
              pub.publish(points)
              pub2.publish(points_clust)
              rate.sleep()

Finally the problem was that the publishing code do not get any centroid data after the while loop. Therefore the assigner could not send any move action to the mobile robot.

iory commented 2 years ago

@SinanK94

Maybe this PR https://github.com/fazildgr8/ros_autonomous_slam/pull/7 solve your problem.

SinanK94 commented 2 years ago

@iory thank you for your PR This was exactly the problem

but can you tell me why the change is only necessary for this part of the code ?

iory commented 2 years ago

For noetic, python3 is the default, and for melodic, python2 is the default. Since the behavior of division changes between python2 and python3, this change makes both of them return the same result.

MJ1307 commented 1 year ago

@kvnptl @Avi241 @SinanK94 @rodrigoaantunes Hello Everyone. I am facing the same issue can anyone please help me in finding the solution.

Avi241 commented 1 year ago

Hey @MJ1307 . Can you provide us with more details.. what errors you are getting and also the logs..

Thanks

amaya2012 commented 10 months ago

Hey, I have the same issue, my robot is not moving. I use Ros Noetic and have tried @SinanK94 code but it's not working for me. Here is the issue I have:

[filter-7] process has died [pid 6452, exit code 1, cmd /home/amaya/catkin_ws/src/ros_autonomous_slam/scripts/filter.py name:=filter log:=/home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/filter-7.log]. log file: /home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/filter-7.log [assigner-8] process has died [pid 6454, exit code 1, cmd /home/amaya/catkin_ws/src/ros_autonomous_slam/scripts/assigner.py name:=assigner log:=/home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/assigner-8.log]. log file: /home/amaya/.ros/log/3d4bcb8c-6975-11ee-b407-65d4e7192b1e/assigner-8.log

To what I understand I have issue with my filter.py et assigner.py files but I don't really what to do.

Thanks

jyf201012jyf commented 5 months ago

same question: solution:pip install -U scikit-learn