2018-03-22 22:28:36 +08:00
# Ros bridge for Carla simulator
This ros package aims at providing a simple ros bridge for carla simulator.
![rviz setup ](./assets/rviz_carla_default.png "rviz" )
![depthcloud ](./assets/depth_cloud_and_lidar.png "depthcloud" )
![short video ](https://youtu.be/S_NoN2GBtdY )
2018-06-01 20:17:39 +08:00
# Features
2018-03-22 22:28:36 +08:00
- [x] Cameras (depth, segmentation, rgb) support
- [x] Add camera matrix
- [x] Lidar sensor support
- [x] Transform publications
- [x] Manual control using ackermann msg
- [x] Autopilot mode using rosparam
- [x] Rosbag in the bridge (in order to avoid rosbag recoard -a small time errors)
- [x] Handle ros dependencies
- [x] Marker/bounding box messages for cars/pedestrian
2018-06-01 20:17:39 +08:00
- [ ] Add traffic light support
2018-03-22 22:28:36 +08:00
- [ ] Support dynamic change (restarting simulation using a topic/rosparam)
# Setup
2018-06-01 20:17:39 +08:00
## Create a catkin workspace and install carla_ros_bridge package
### Create the catkin workspace:
2018-03-22 22:28:36 +08:00
2018-06-01 20:17:39 +08:00
mkdir -p ~/ros/catkin_ws_for_carla/src
cd ~/ros/catkin_ws_for_carla
source /opt/ros/kinetic/setup.bash
catkin_make
source ~/ros/catkin_ws_for_carla/devel/setup.bash
For more information about configuring a ros environment see
http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment
2018-04-03 16:53:32 +08:00
## Install carla python client in your workspace
cd carla/PythonClient
2018-06-06 17:23:59 +08:00
pip2 install -e . --user --upgrade
2018-06-01 20:17:39 +08:00
Check the installation is successfull by trying to import carla from python:
2018-03-22 22:28:36 +08:00
2018-06-01 20:17:39 +08:00
python -c 'import carla;print("Success")'
You should see the Success message without any errors.
2018-04-03 16:53:32 +08:00
2018-06-01 20:17:39 +08:00
### Install recent protobuf version [optional]
2018-04-03 16:53:32 +08:00
2018-06-01 20:17:39 +08:00
sudo apt-get remove python-protobuf
2018-06-06 17:23:59 +08:00
sudo pip2 install --upgrade protobuf
2018-04-03 16:53:32 +08:00
2018-03-22 22:28:36 +08:00
2018-06-01 20:17:39 +08:00
### Add the carla_ros_bridge in the catkin workspace
Run the following command after replacing [PATH_TO_CARLA] with the actual path to carla directory on your machine:
ln -s [PATH_TO_CARLA]/carla_ros_bridge/ ~/ros/catkin_ws_for_carla/src/
source ~/ros/catkin_ws_for_carla/devel/setup.bash
rosdep update
rosdep install --from-paths ~/ros/catkin_ws_for_carla
2018-06-06 17:23:59 +08:00
cd ~/ros/catkin_ws_for_carla
catkin_make
2018-06-27 19:24:14 +08:00
source ~/ros/catkin_ws_for_carla/devel/setup.bash
2018-06-01 20:17:39 +08:00
### Test your installation
If you use the builded binary (0.8.2):
./CarlaUE4 -carla-server -windowed -ResX=320 -ResY=240
Wait for the message:
Waiting for the client to connect...
Then run the tests
2018-06-06 17:23:59 +08:00
rostest carla_ros_bridge ros_bridge_client.test
2018-06-01 20:17:39 +08:00
you should see:
[carla_ros_bridge.rosunit-testTopics/test_publish][passed]
SUMMARY
* RESULT: SUCCESS
2018-03-22 22:28:36 +08:00
# Start the ros bridge
2018-06-01 20:17:39 +08:00
First run the simulator (see carla documentation: http://carla.readthedocs.io/en/latest/)
./CarlaUE4 -carla-server -windowed -ResX=320 -ResY=240
2018-03-22 22:28:36 +08:00
2018-06-01 20:17:39 +08:00
Wait for the message:
Waiting for the client to connect...
2018-03-22 22:28:36 +08:00
Then start the ros bridge:
2018-06-06 17:23:59 +08:00
source ~/ros/catkin_ws_for_carla/devel/setup.bash
2018-04-03 16:53:32 +08:00
roslaunch carla_ros_bridge client.launch
2018-03-22 22:28:36 +08:00
To start the ros bridge with rviz use:
2018-04-13 00:42:14 +08:00
roslaunch carla_ros_bridge client_with_rviz.launch
2018-03-22 22:28:36 +08:00
You can setup the wanted camera/sensors in config/settings.yaml.
# Autopilot control
To enable autopilot control set the ros param carla_autopilot to True
rosparam set carla_autopilot True
# Manual control
To enable manual control set the ros param carla_autopilot to False
rosparam set carla_autopilot False
Then you can send command to the car using the /ackermann_cmd topic.
Example of forward movements, speed in in meters/sec.
2018-06-06 17:23:59 +08:00
rostopic pub /ackermann_cmd ackermann_msgs/AckermannDrive "{steering_angle: 0.0, steering_angle_velocity: 0.0, speed: 10, acceleration: 0.0,
2018-03-22 22:28:36 +08:00
jerk: 0.0}" -r 10
Example of forward with steering
2018-06-06 17:23:59 +08:00
rostopic pub /ackermann_cmd ackermann_msgs/AckermannDrive "{steering_angle: 5.41, steering_angle_velocity: 0.0, speed: 10, acceleration: 0.0,
2018-03-22 22:28:36 +08:00
jerk: 0.0}" -r 10
Warning: the steering_angle is the driving angle (in radians) not the wheel angle, for now max wheel is set to 500 degrees.
Example for backward :
2018-06-06 17:23:59 +08:00
rostopic pub /ackermann_cmd ackermann_msgs/AckermannDrive "{steering_angle: 0, steering_angle_velocity: 0.0, speed: -10, acceleration: 0.0,
2018-03-22 22:28:36 +08:00
jerk: 0.0}" -r 10
2018-06-06 17:23:59 +08:00
# ROSBAG recording
The carla_ros_bridge could also be used to record all published topics into a rosbag:
2018-06-08 14:59:30 +08:00
roslaunch carla_ros_bridge client_with_rviz.launch rosbag_fname:=/tmp/save_session.bag
2018-06-06 17:23:59 +08:00
2018-06-08 14:59:30 +08:00
This command will create a rosbag /tmp/save_session.bag
2018-06-06 17:23:59 +08:00
You can of course also use rosbag record to do the same, but using the ros_bridge to do the recording you have the guarentee that all the message are saved without small desynchronization that could occurs when using *rosbag record* in an other process.
2018-06-01 20:17:39 +08:00