ROS2 package to control force feedback of logitech g29 steering wheel with ros message, written in c++, for human beings all over the world. This is useful for the user interface of autonomous driving, driving simulator like CARLA, LGSVL etc.
examples/carla_control.py
-
Standalone ros package to control steering wheel. (doesn't depend on the other ros packages like ros-melodic-joy etc.)
-
Two control modes
-
Control mode (
config/g29.yaml/auto_centering=false
)
Rotate wheel to the specified angle (position
) with specifiedtorque
as specified with rostopic. -
Auto centering mode (
config/g29.yaml/auto_centering=true
)
Automatically centering position, without publishing rostopic.
-
-
ROS1 and ROS2 support. (if you use ROS1, checkout and refer ros1 branch)
ROS version g29 g923 ROS1 -- -- Kinetic tested no Melodic tested no Noetic tested no ROS2 -- -- Dashing no no Foxy tested no Galactic tested no Humble no no
- ubuntu18-22
- ROS2
- Logitech G29 Driving Force Racing Wheel (Planning to test with g923)
To check whether your kernel supports force feedback, do as follows
$ cat /boot/config-5.3.0-46-generic | grep CONFIG_LOGIWHEELS_FF
CONFIG_LOGIWHEELS_FF=y
If you cannot get CONFIG_LOGIWHEELS_FF=y
, try to find patch or use latest kernel...
- create ros2_ws
mkdir -p ros2_ws/src cd /ros2_ws colcon build
- download and build package
cd /ros2_ws/src git clone https://github.com/kuriatsu/ros-g29-force-feedback.git cd ../ colcon build --symlink-install
-
Get device name
$ cat /proc/bus/input/devices
find Logitech G29 Driving Force Racing Wheel and check Handlers (ex. event19)
-
Change
device_name
in config/g29.yaml to the device name you obtained in step 1 -
Launch ros node
$ source ros2_ws/install/setup.bash $ ros2 run ros_g29_force_feedback g29_force_feedback --ros-args --params-file ros2_ws/src/ros_g29_force_feedback/config/g29.yaml
-
Publish message (It's better to use tab completion)
$ ros2 topic pub /ff_target ros_g29_force_feedback/msg/ForceFeedback "{header: {stamp: {sec: 0, nanosec: 0}, frame_id: ''}, position: 0.3, torque: 0.5}"
Once the message is published, the wheel rotates to 0.3*<max_angle> (g29: max_angle=450° clockwise, -450° counterclockwise). Publish rate is not restricted.
g29_force_feedback.yaml
parameter | default | description |
---|---|---|
device_name | /dev/input/event19 | device name, change the number |
loop_rate | 0.1 | Loop of retrieving wheel position and uploading control to the wheel |
max_torque | 1.0 | As for g29, 1.0 = 2.5Nm (min_torque < max_torque < 1.0) |
min_torque | 0.2 | Less than 0.2 cannot rotate wheel |
brake_torque | 0.2 | Braking torque to stop at the position (descrived below) |
brake_position | 0.1 | Brake angle (position -0.1*max_angle) |
auto_centering_max_torque | 0.3 | Max torque for auto centering |
auto_centering_max_position | 0.2 | Max torque position while auto centering (position ±0.2*max_angle) |
eps | 0.01 | Wheel in the range (position-eps to position+eps) is considered as it has reached the position |
auto_centering | false | Anto centering if true |
- If you use conda, deactivate and try again. rclpy and conda seem to conflict.
- If you have multiple ros2 versions, source one of them or remove one of them.
Double check the output of cat /proc/bus/input/devices
and update device_name
in config/g29.yaml.
Reboot can change the ID.
Try to update the parameters inside the source code.
Bag fix in ros1 branch thanks to pedrohdsimoes
An example script of CARLA connection was added. Rotate the wheel according to the ego vehicle spawned in CARLA as shown in the GIF image.
Now available in ROS2-Foxy thanks to JLBicho
Oscillation problem solved. Wheel stops at the specified position, then starts auto centering. Auto centering mode are set by rosparam in config/g29.yaml, not by rostopic. Name of topic variables changed.
PID-Constant mode can be changed dynamically!! Removed mode selection from rosparam. Rotation force is ignored when PID mode. (max force can be specified with rosparam (not dynamic))
https://www.kernel.org/doc/html/v5.4/input/ff.html
https://github.com/flosse/linuxconsole/tree/master