Unmanned Vehicle System (9): An unmanned driving simulation environment based on ROS and Gazebo-car_demo

In the car_demo|Unmanned Vehicle Simulation Environment full tutorial , the installation and configuration of car_demo in the system: Ubuntu 14.04 indigo is introduced. Due to the lower versions of ubuntu and ros on the computer at that time, I installed Docker , nvidia-docker2 , and rocker according to the configuration method of the original tutorial . The final realization is to let car_demo run in an independent docker environment, and use ROS's multi-machine communication mechanism configuration (for how to configure, please refer to the car_demo|Unmanned Vehicle Simulation Environment full tutorial ), so that it can be carried out with the simulation environment on your own computer Data interaction. However, this process is really troublesome, and it feels very bad to use. I just changed my computer recently, and I simply changed my system to ubuntu 18.04+ ros melodic. It is found that it can be directly compiled locally, and then a local ros package is found, which is much more convenient to use.

System: ubuntu 18.04+ros melodic
Purpose: configure car_demo unmanned vehicle simulation environment


Installation and configuration process

  • git clone the car_demo project to the local:
cd ~/Downloads
git clone https://github.com/osrf/car_demo.git
  • Create and locate a new workspace, or an existing workspace ~/cardemo_ws. The location and the name do not matter:
mkdir -p ~/cardemo_ws/src
  • Copy the corresponding package to the src directory of the newly created workspace:
cd ~/Downloads/car_demo_master 
cp -r prius_description ~/cardemo_ws/src/prius_description
cp -r prius_msgs ~/cardemo_ws/src/prius_msgs
cp -r car_demo ~/cardemo_ws/src/car_demo
  • Compile:
cd ~/cardemo_ws
catkin_make
  • Add environment
echo "source ~/cardemo_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

Simple test

roslaunch car_demo demo.launch 

We will see two interfaces, RVIZ and Gazebo

  • RVIZ
    Insert picture description here
  • Gazebo
    Insert picture description here
  • View topic data (data such as laser, sonar, camera, car's own state, etc.):
rostopic list
/amcl_pose
/base_pose_ground_truth
/clicked_point
/clock
/diagnostics
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/joint_states
/joy
/joy/set_feedback
/move_base_simple/goal
/particlecloud
/prius   # 控制车的topic,包括刹车、油门、档位、方向盘转向等命令
/prius/back_camera/camera_info
/prius/back_camera/image_raw
/prius/back_camera/image_raw/compressed
/prius/back_camera/image_raw/compressed/parameter_descriptions
/prius/back_camera/image_raw/compressed/parameter_updates
/prius/back_camera/image_raw/compressedDepth
/prius/back_camera/image_raw/compressedDepth/parameter_descriptions
/prius/back_camera/image_raw/compressedDepth/parameter_updates
/prius/back_camera/image_raw/theora
/prius/back_camera/image_raw/theora/parameter_descriptions
/prius/back_camera/image_raw/theora/parameter_updates
/prius/back_camera/parameter_descriptions
/prius/back_camera/parameter_updates
/prius/back_sonar/left_far_range
/prius/back_sonar/left_middle_range
/prius/back_sonar/right_far_range
/prius/back_sonar/right_middle_range
/prius/center_laser/scan
/prius/front_camera/camera_info
/prius/front_camera/image_raw
/prius/front_camera/image_raw/compressed
/prius/front_camera/image_raw/compressed/parameter_descriptions
/prius/front_camera/image_raw/compressed/parameter_updates
/prius/front_camera/image_raw/compressedDepth
/prius/front_camera/image_raw/compressedDepth/parameter_descriptions
/prius/front_camera/image_raw/compressedDepth/parameter_updates
/prius/front_camera/image_raw/theora
/prius/front_camera/image_raw/theora/parameter_descriptions
/prius/front_camera/image_raw/theora/parameter_updates
/prius/front_camera/parameter_descriptions
/prius/front_camera/parameter_updates
/prius/front_left_laser/scan
/prius/front_right_laser/scan
/prius/front_sonar/left_far_range
/prius/front_sonar/left_middle_range
/prius/front_sonar/right_far_range
/prius/front_sonar/right_middle_range
/prius/left_camera/camera_info
/prius/left_camera/image_raw
/prius/left_camera/image_raw/compressed
/prius/left_camera/image_raw/compressed/parameter_descriptions
/prius/left_camera/image_raw/compressed/parameter_updates
/prius/left_camera/image_raw/compressedDepth
/prius/left_camera/image_raw/compressedDepth/parameter_descriptions
/prius/left_camera/image_raw/compressedDepth/parameter_updates
/prius/left_camera/image_raw/theora
/prius/left_camera/image_raw/theora/parameter_descriptions
/prius/left_camera/image_raw/theora/parameter_updates
/prius/left_camera/parameter_descriptions
/prius/left_camera/parameter_updates
/prius/right_camera/camera_info
/prius/right_camera/image_raw
/prius/right_camera/image_raw/compressed
/prius/right_camera/image_raw/compressed/parameter_descriptions
/prius/right_camera/image_raw/compressed/parameter_updates
/prius/right_camera/image_raw/compressedDepth
/prius/right_camera/image_raw/compressedDepth/parameter_descriptions
/prius/right_camera/image_raw/compressedDepth/parameter_updates
/prius/right_camera/image_raw/theora
/prius/right_camera/image_raw/theora/parameter_descriptions
/prius/right_camera/image_raw/theora/parameter_updates
/prius/right_camera/parameter_descriptions
/prius/right_camera/parameter_updates

among them,/prius # 控制车的topic,包括刹车、油门、档位、方向盘转向等命令

  • Simple control (control commands given randomly)
import rospy
from prius_msgs.msg import Control

def control_test():
    pub = rospy.Publisher("/prius", Control, queue_size=1)
    rospy.init_node('sim_control', anonymous=True)
    rate = rospy.Rate(10) # 10hz
    command = Control()
    command.header.stamp = rospy.Time.now()
    command.throttle = 1.0
    command.brake = 0.0
    command.shift_gears = Control.FORWARD
    
    while not rospy.is_shutdown():
        pub.publish(command)
        rate.sleep()

if __name__ == '__main__':
    try:
        control_test()
    except rospy.ROSInterruptException:
        pass 

We see the motivation of the car.
Insert picture description here

to sum up

This unmanned vehicle simulation environment is very suitable for children's shoes that are based on ROS and want to conduct some research based on ROS. Other simulation environments are really big and test the performance of the computer very much.

Guess you like

Origin blog.csdn.net/u013468614/article/details/103536574