Simulator
Our simulator is capable of simulating all sensors of the physical FreiCar. The simulator comes with the docker image and thus does need to be installed manually.
Starting the Simulator
The simulator together with some necessary ROS-nodes can be started by running:
roslaunch freicar_launch local_comp_launch.launch
The simulator needs always to run if you want to start your own programs. Your ROS-nodes must be started in a separate launch file. In this launch file also the map is specified. See down below how to change it.
Updating the Simulator
We might update the simulator from time to time. When a new simulator version comes out you can upgrade the simulator by running update_simulator.bash
from the docker directory.
Simulated Sensors/Actuators
Throttle, Steering, Brake
All cars can be controlled over throttle, steering and brake. The corresponding ROS-message can be looked up here and can be sent to /AnyCarName/control
.
Localization
If the competition mode is turned off (see explanation below), a ground-truth localization will be provided as tf-transform from /map -> /AnyCarName/handle
(center of the car). You can use a ROS tf-listener to query this transform in your code.
Odometry
The odometry of the car is provided on the topic /AnyCarName/odometry
using the odometry message message type.
RGB Camera
The RGB image of the front facing camera is published as ROS image message on the topic: /AnyCarName/sim/camera/rgb/front/image
.
Depth Camera
We also provide a depth image (also as ROS image message) ,which is aligning with the RGB camera, on the topic : /AnyCarName/sim/camera/depth/front/image_float
. The depth image is encoded as single channel floating point image and the unit is meters.
Lidar
We simulate the Sick lidar on the topic /AnyCarName/sim/lidar
as PointCloud2 message. After receiving the message in one of your nodes we recommend converting the PointCloud2 message to a pcl format for convenience.
Maps
We have prepared various urban and race maps that can be loaded into the simulator.
In order to change the map open the file local_comp_launch.launch
from the package freicar_launch
and change the map_name
to the corresponding map-name in the table below.
You can also provide the map_name as command-line argument like: roslaunch freicar_launch local_comp_launch.launch map_name:=freicar_race_1.aismap
Preview | ROS Map Name (local_comp_launch.launch) |
---|---|
![]() |
freicar_1.aismap |
![]() |
freicar_2.aismap |
![]() |
freicar_race_1.aismap |
![]() |
freicar_race_2.aismap |
Competition Mode
By default, the simulator provides ground-truth localization (a tf-transform from /map to /car_name) and ground-truth odometry. However in the final competition this information won't be available.
In the local_comp_launch.launch
a argument named comp_mode
is defined (default: false). If comp_mode
is set to true the ground-truth localization is not published anymore.
The simulated odometry measurements are always overlaid with gaussian noise, no matter how the comp_mode
is set.
Like the map-name you can set the comp_mode as a command line argument like: roslaunch freicar_launch local_comp_launch.launch map_name:=freicar_1.aismap comp_mode:=true
In the final competition comp_mode
is set to true.
Note: Even though if comp_mode
is turned on other dynamic agents (See section about spawning dynamic cars down below) will publish ground-truth localization information on the topic /car_localization
. It is NOT allowed to use this topic during the competition.
Spawn Poses
There are two ways to define the initial spawn pose of the car:
-
The freicar_carla_proxy node provides the parameters
spawn/x
,spawn/y
,spawn/z
andspawn/heading
that can be used to setup the initial pose. Note that if you use thesim_base.launch
these parameters are getting overwritten by the values defined in this launch file. -
Additionally, freicar_carla_proxy provides the parameter
use_yaml_spawn
. Note again that if you usesim_base.launch
the value gets overwritten by the file. Ifuse_yaml_spawn
is set to true the spawn pose will be read from the files located infreicar_base/freicar_launch/spawn_positions
depending on the map that is defined by the global parametermap_path
(set insim_base.launch
). If the spawn position is used from the yaml file also the ros-parameterspawn/x
etc will be set accordingly.
The heading angle is in degree and defined as follows:
Reset/Set Car Positions Manually
After spawning a car two ROS services are created (by freicar_carla_proxy).
- /FREICAR_NAME/set_position
(e.g /freicar_1/set_position
)
- /FREICAR_NAME/reset_position
(e.g /freicar_1/reset_position
)
These services can be used to either reset the cars position to the spawn pose or to set a custom pose. In both cases the car will be beamed to the changed pose.
Set a new pose
Example to set a new pose (in case the car is called "freicar_1"):
rosservice call /freicar_1/set_position "{x: -0.3, y: -0.3, z: 0.0, heading: -45.0}"
Reset to spawn pose
Example how to reset the cars pose to the spawn pose (in case the car is called "freicar_1"):
rosservice call /freicar_1/reset_position true
Spawning Dynamic Cars
In order to test your system with other dynamic traffic participants you can spawn multiple other scripted cars that obey the traffic rules.
To do so, run: rosrun freicar_executables freicar_carla_agent_node 5
. This will spawn 5 other dynamic cars. Note that the simulation has to run before.
Using a Gamepad
If you like you can use a gamepad to control your car. Just type: roslaunch freicar_launch start_joystick.launch name:=freicar_anyname
where "freicar_anyname" is your car-name.
We support currently xbox controllers, but you could change the "FreiCar Joy" node to your needs (see Freicar Overview)