reiniscimurs / DRL-robot-navigation

Deep Reinforcement Learning for mobile robot navigation in ROS Gazebo simulator. Using Twin Delayed Deep Deterministic Policy Gradient (TD3) neural network, a robot learns to navigate to a random goal point in a simulated environment while avoiding obstacles.
MIT License
486 stars 97 forks source link

About lidar #124

Open Ethan0207 opened 3 months ago

Ethan0207 commented 3 months ago

Hi, This project uses a single-line Lidar. I would like to ask if multi-line Lidar is feasible.

reiniscimurs commented 3 months ago

Hi,

This project uses multi-channel Lidar. We squash the 3D measurements into 2D to create a single dimensional vector for input into the TD3 network. Direct multi-channel input is also possible in theory. But this project does not support that. Here, only single dimension inputs are supported out of the box.

Ethan0207 commented 3 months ago

OK, thank you for your reply. It is helpful for me.

Ethan0207 commented 3 months ago

Hi, These days I changed the lidar. But I met a problem. The lidar had changed successfully, but the car model could not move. I checked my plugin and I synced my robot namespace. Could you give me some suggestions? 3 20-1 3 20-2 3 20-3 3 20-4 this is my modified env.py file. 3 20-5 3 20-6 3 20-7 this is main xacro file. 3 20-8 3 20-9 3 20-10 3 20-11 3 20-12 3 20-13 3 20-14 3 20-15 3 20-17 this is main plugin file 3 20-18

reiniscimurs commented 3 months ago

Hi,

Please provide more information about the issue. What do you mean it cannot move? Is there an error or does the network not produce an output? How have you debugged the code? How do you check that the data from your lidar is correct?

Quick note is that in your callback you are using a point_cloud2 function but your message type is PointCloud instead of PointCloud2. But in general, these kinds of changes are outside the scope of this repository and I would not have the time to investigate such in depth changes. Good luck!

Ethan0207 commented 3 months ago

Hi, Thank you for your reply. Firstly, the model can not move. It just means when I trained it, nothing happened. But the topic could be subscribed, so I guessed the problem is with the car motion plugin. Therefore, I checked it and I synced my robot namespace. But now, I find a strange thing. When I change my robot namespace to "/", it is normal and the model can move. I adjusted the namespace earlier because it reported the following error. Traceback (most recent call last): File "train_velodyne_td3.py", line 346, in next_state, reward, done, target = env.step(a_in) File "/home/team/DRL-robot-navigation-scout/TD3/velodyne_env.py", line 196, in step self.odom_x = self.last_odom.pose.pose.position.x AttributeError: 'NoneType' object has no attribute 'pose' So I synced my robot namespace from"/" to "/scout". Now, I adjust the namespace to "/". It is normal. Secondly, based on your answer, if I want to check if it has an output, how can I do? Finally, about the lidar, it is good suggestion, I will try to synced the message type.

Ethan0207 commented 3 months ago

Hi, I unified the sensor_msgs/PointCloud, but it still reported the following error. Traceback (most recent call last): File "train_velodyne_td3.py", line 346, in next_state, reward, done, target = env.step(a_in) File "/home/team/DRL-robot-navigation-scout/TD3/velodyne_env.py", line 196, in step self.odom_x = self.last_odom.pose.pose.position.x AttributeError: 'NoneType' object has no attribute 'pose' I didn't understand this error. Can you help me explain it? And faced with such mistakes, how to solve?

Ethan0207 commented 3 months ago

Add: I synced my robot namespace from"/" to "/scout". It is ok. But the model can not move. Based on your answer, if I want to check if it has an output, how can I do? Could you give me some suggestions?

Hi, Thank you for your reply. Firstly, the model can not move. It just means when I trained it, nothing happened. But the topic could be subscribed, so I guessed the problem is with the car motion plugin. Therefore, I checked it and I synced my robot namespace. But now, I find a strange thing. When I change my robot namespace to "/", it is normal and the model can move. I adjusted the namespace earlier because it reported the following error. Traceback (most recent call last): File "train_velodyne_td3.py", line 346, in next_state, reward, done, target = env.step(a_in) File "/home/team/DRL-robot-navigation-scout/TD3/velodyne_env.py", line 196, in step self.odom_x = self.last_odom.pose.pose.position.x AttributeError: 'NoneType' object has no attribute 'pose' So I synced my robot namespace from"/" to "/scout". Now, I adjust the namespace to "/". It is normal. Secondly, based on your answer, if I want to check if it has an output, how can I do? Finally, about the lidar, it is good suggestion, I will try to synced the message type.

tina525241 commented 3 months ago

Hi, I unified the sensor_msgs/PointCloud, but it still reported the following error. Traceback (most recent call last): File "train_velodyne_td3.py", line 346, in next_state, reward, done, target = env.step(a_in) File "/home/team/DRL-robot-navigation-scout/TD3/velodyne_env.py", line 196, in step self.odom_x = self.last_odom.pose.pose.position.x AttributeError: 'NoneType' object has no attribute 'pose' I didn't understand this error. Can you help me explain it? And faced with such mistakes, how to solve?

Hi! Just fixed this problem and found someone has encountered the same problem. In velodyne_env.py there's a "self.last_odom" which is init with "None", if you change "self.last_odom = None" into "self.last_odom = Odometry()" the attribute error will be solved. (At least for me) :)

Ethan0207 commented 3 months ago

Hi, I unified the sensor_msgs/PointCloud, but it still reported the following error. Traceback (most recent call last): File "train_velodyne_td3.py", line 346, in next_state, reward, done, target = env.step(a_in) File "/home/team/DRL-robot-navigation-scout/TD3/velodyne_env.py", line 196, in step self.odom_x = self.last_odom.pose.pose.position.x AttributeError: 'NoneType' object has no attribute 'pose' I didn't understand this error. Can you help me explain it? And faced with such mistakes, how to solve?

Hi! Just fixed this problem and found someone has encountered the same problem. In velodyne_env.py there's a "self.last_odom" which is init with "None", if you change "self.last_odom = None" into "self.last_odom = Odometry()" the attribute error will be solved. (At least for me) :)

Hi, thank you for your reply. I have solved the problem. Could you tell me what the reason is?

reiniscimurs commented 3 months ago

Hi,

Initializing with Odometry() will solve the symptom but not the issue. The reason why this error appears is that there has been no odometry published to the topic that you subscribed to. So the callback does not get triggered and value for self.last_odom does not get updated before you call it. We initialize with None so that we accidentally would not be using some random values in odometry that would be difficult to trace. If you initialize with Odometry() you will get some input already in self.last_odom from the very beginning with some dummy numbers, but if the odometry callback will never be triggered, your self.last_odom will never be updated and the odoetry information will be wrong.

I assume this issue arises for you because of one of two reasons:

  1. Odometry simply has not started publishing yet in which case you can try increasing the wait time for ros to settle here: https://github.com/reiniscimurs/DRL-robot-navigation/blob/main/TD3/train_velodyne_td3.py#L253
  2. The topic you are subscribing to is either wrong or not publishing anything. You should check your published topics, their names and use rostopic echo to see their values. For instance, you are hardcoding a prefix /scout to some topics in your plugin but not for odom. But you still have prefix /scout in your odometry subscriber. I would suggest double checking that.
Ethan0207 commented 3 months ago

Hi, Thank you for your reply. It is extremely helpful for me. I have another question. 3 29 From this picture, I can't understand how to setting the filtering parameter? For example, the filtering parameter of Turtlebot waffle is -0.072. How did you calculate 0.072?

reiniscimurs commented 2 months ago

It is simply the height from the ground at which you have set your sensor (plus some buffer value)