Skip to content

Commit 5e1f0dd

Browse files
committed
bag fix
1 parent e82459a commit 5e1f0dd

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Assets/Scripts/JoyController.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void Update()
128128
/// <param name="isOn">トグルの新しい状態</param>
129129
public void OnAccelToggleChanged(bool isOn)
130130
{
131-
if (ros2Unity == null || !ros2Unity.Ok() || ros2Node == null || accel_pub == null || speed_pub == null)
131+
if (ros2Unity == null || !ros2Unity.Ok() || ros2Node == null || accel_pub == null)
132132
{
133133
Debug.LogWarning("ROS2 is not initialized. Cannot publish acceleration message.");
134134
return;
@@ -137,7 +137,7 @@ public void OnAccelToggleChanged(bool isOn)
137137
std_msgs.msg.Bool msg = new std_msgs.msg.Bool();
138138
msg.Data = isOn;
139139

140-
speed_pub.Publish(msg);
140+
// speed_pub.Publish(msg); // <--- この行を削除/コメントアウト
141141
accel_pub.Publish(msg);
142142
Debug.Log($"Published acceleration toggle state: {msg.Data}");
143143
}
@@ -162,6 +162,15 @@ public void OnLowSpeedToggleChanged(bool isOn)
162162
// 現在の値を新しい最大値に合わせて調整
163163
angularSpeedSlider.value = Mathf.Min(angularSpeed, angularSpeedSlider.maxValue);
164164
}
165+
166+
// 低速トグルの状態をROS2にパブリッシュ (速度パブリッシャーを使用)
167+
if (ros2Unity != null && ros2Unity.Ok() && ros2Node != null && speed_pub != null)
168+
{
169+
std_msgs.msg.Bool msg = new std_msgs.msg.Bool();
170+
msg.Data = isOn;
171+
speed_pub.Publish(msg);
172+
Debug.Log($"Published speed toggle state: {msg.Data}");
173+
}
165174
}
166175

167176
/// <summary>

0 commit comments

Comments
 (0)