logitech G29 Carla

电脑配置:Ubuntu20.04

ros2 galactic

Carla:0.9.12

由于Carla+G29要适配Linux系统,罗技的官网没有Linux的驱动,所以需要自己鼓捣;

可以看到罗技的G29由方向盘和油门刹车离合组成,需要将离合上的线接到方向盘上,注意,方向盘有一个电源线需要注意连接,电源线连接好,USB接口连接到计算机G29就开始旋转自检(之前就是这个坑,上机以后其他的按键和油门,刹车有反应,就是方向盘不动,你可以查看一下是不是线松了)。

查看工具:jstest-gtk

sudo apt-get install jstest-gtk #安装这个小工具

jstest-gtk                      #启动小工具

运行以后发现一个命名为Joystick Preferences的小窗口,发现已经识别到了罗技的设备、Device:/dev   /input/js0 >>> 点击Properties进入:

我的油门对应着Axis2,踩油门就有数值变化;刹车对应着Axis3,方向盘对应的Axis0;(Axis0没数据看看有没有给方向盘上电,上电会转,还有一排灯亮起来)

固定问题

看完视频已后才知道想要固定住G29需要先把上面两个圆形的东西给拧开,然后用力朝松的方向拧开,越拧底下的卡扣越向下,然后把两个帽子给掰出来,然后就可以卡在桌子上极品飞车了;

Carla这一端的话做了两个测试验证

./CarlaUE4.sh

Carla/PythonAPI/example

./manual_control_steeringwheel.py --host <服务器地址>

这里如果报错的话,需要改一下manual_control_steeringwheel.py里面的代码

ERROR:

Welcome to CARLA manual control with steering wheel Logitech G29.

To drive start by preshing the brake pedal.

Change your wheel_config.ini according to your steering wheel.

To find out the values of your steering wheel use jstest-gtk in Ubuntu.

WARNING: Version mismatch detected: You are trying to connect to a simulator that might be incompatible with this API

WARNING: Client API version     = 0.9.4-84-g889b998-dirty

WARNING: Simulator API version  = 0.9.5-1-g4d1230e-dirty

Traceback (most recent call last):

  File "./manual_control_steeringwheel.py", line 863, in <module>

    main()

  File "./manual_control_steeringwheel.py", line 855, in main

    game_loop(args)

  File "./manual_control_steeringwheel.py", line 790, in game_loop

    world.tick(clock)

  File "./manual_control_steeringwheel.py", line 180, in tick

    self.hud.tick(self, clock)

  File "./manual_control_steeringwheel.py", line 426, in tick

    'Map:     % 20s' % world.world.map_name,

AttributeError: 'World' object has no attribute 'map_name'

解决:

map_name was removed from world, use world.get_map().name

如果是本机运行则可不加服务器地址参数

同时,需要根据测试的方向盘来设置wheel_config.init的参数

cd  Carla_python_Client

gedit manual_control_steeringwheel.py

gedit wheel_config.init

这样就可以在Carla中飙车了,但是有一个问题:方向盘没有阻力,容易开飘掉,下一步给G29加force-feedback(力反馈)

解决办法:GitHub上有一个小日子过得不错的程序员做了轮子,那就用一下吧,GitHub - kuriatsu/ros-g29-force-feedback: ros package for logicool g29 steering force feedback control

支持的版本贴到下面了

ROS version

g29

g923

ROS1

--

--

Kinetic

tested

no

Melodic

tested

no

ROS2

--

--

Dashing

no

no

Foxy

tested

no

Galactic

tested

no

#看看你的电脑的内核支持力反馈不,内核版本调整成自己的

cat /boot/config-5.3.0-46-generic | grep CONFIG_LOGIWHEELS_FF

CONFIG_LOGIWHEELS_FF=y

install

1.create ros2_ws

mkdir ~p ros2_ws/src

cd /ros2_ws

colcon build

2.download and build package

cd /ros2_ws/src

git clone https://github.com/kuriatsu/ros-g29-force-feedback.git

cd ../

colcon build --symlink-install

适配:

1.配置你的驱动名字

cat /proc/bus/input/devices

看看带有Logitch G29 Driving Force Racing Wheel 的event是哪一个

2.编辑 /config/g29.yaml/device_name event X

3运行节点

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

启动的位置应当在文件夹外面!!!

如此就可以感受到方向盘有阻力了,但是我像要方向盘自己动

4.传递信息

$ 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}"

一旦消息被抛出,转盘旋转到0.3 * < max _ angle > (g29: max _ angle = 450 ° 顺时针,-450 ° 逆时针方向) ,发布速度不受限制。

29_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

参看资料:

ubuntu20.04安装Carla并配置罗技G29方向盘使用_carla外接方向盘_冻★结♬ ☞memory☜的博客-CSDN博客

反馈模式

Carla给控制指令,G29作为接收器接收控制指令

GitHub - kuriatsu/ros-g29-force-feedback: ros package for logicool g29 steering force feedback control

源码下载,并编译

然后在example中运行 carla_contrpol.py

python3 .carla_control.py

当然,之前也要开启Carla的世界脚本

。/CarlaUE4.sh -quality-level=Epic -RenderOffScreen

cd carla/PythonAPI/example

./manual_control.py

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
simulink联合罗技G29可以实现驾驶员在环仿真。具体步骤如下: 1. 首先,确保你已经安装了MATLAB和Simulink软件,并且已经连接了罗技G29方向盘。 2. 打开Simulink软件,创建一个新的模型。 3. 在模型中添加一个输入设备模块,选择罗技G29方向盘作为输入设备。 4. 配置输入设备模块,设置方向盘的输入通道和轴的映射关系。 5. 添加其他必要的模块,例如车辆模型、环境模型等,以构建完整的联合仿真系统。 6. 配置模型参数,例如车辆的物理特性、环境条件等。 7. 运行模型,即可开始进行联合仿真。你可以通过转动方向盘来控制车辆的转向,同时观察仿真结果。 8. 在仿真过程中,你可以根据需要进行参数调整和优化,以获得更好的仿真效果。 9. 完成联合仿真后,你可以分析仿真结果,并根据需要进行后续的数据处理和评估。 下面是一个示例代码,展示了如何在Simulink中实现联合仿真: ```matlab % 导入罗技G29方向盘的输入设备模块 inputDevice = simulink.InputDevice('Logitech G29 Racing Wheel'); % 配置方向盘的输入通道和轴的映射关系 inputDevice.Channel = 1; inputDevice.AxisMapping = 'X'; % 创建一个车辆模型 vehicleModel = simulink.VehicleModel('Car'); % 添加其他必要的模块,例如环境模型 environmentModel = simulink.EnvironmentModel('Road'); % 配置模型参数 vehicleModel.Mass = 1000; % 车辆质量 vehicleModel.Length = 4; % 车辆长度 environmentModel.RoadType = 'Straight'; % 道路类型 % 运行模型 simOut = sim('YourModel'); % 分析仿真结果 % ... % 后续数据处理和评估 % ... ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值