2021-11-06

使用虚拟环境训练turtlebot3小车实现避障碍实现导航
关键词:DDPG,turtlebot3,gazebo,强化学习,避障导航, pytorch。
环境已经搭建好了
开始
1.roslaunch turtlebot3_gazebo turtlebot3_stage_4.launch
2.用vscore运行DDPG程序开始训练
数据记录
rostopic echo /result
rosbag record /result
数据内容

 if flag:
 	total_result = rewards_current_episode
	trainer.qvalue = torch.tensor(trainer.qvalue)
	result.data = [total_result,torch.median(trainer.qvalue),trainer.loss_actor_value,trainer.loss_critic_value]
    pub_result.publish(result)
 else:
    total_result =[rewards_current_episode]
    result.data=total_result
    pub_result.publish(result)
 break

2021-11-06_第1张图片初始的数据值:data: [-2.0, 0.4157009422779083, -115.70923614501953, 2.711627721786499]

数据可视化:
用的是QT
conda create -n py3 pip python=3.6 pyqtgraph pyqt5
source activate py3
rosrun project result

2021-11-06_第2张图片一些参数:
exploration_decay_rate = 0.001

MAX_EPISODES = 10001
MAX_STEPS = 1000
MAX_BUFFER = 200000
rewards_all_episodes = []

STATE_DIMENSION = 28
ACTION_DIMENSION = 2
ACTION_V_MAX = 0.5 # m/s
ACTION_W_MAX = 2. # rad/s

if distance_rate > 0:
reward = 2.
if distance_rate <= 0:
reward = -2.

if done:
rospy.loginfo(“Collision!!”)
# reward = -500.
reward = -10.
self.pub_cmd_vel.publish(Twist())

if self.get_goalbox:
rospy.loginfo(“Goal!!”)
# reward = 500.
reward = 100.

你可能感兴趣的:(ROS,pytorch,深度学习,自动驾驶)