Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions launch/kobuki.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Modified by Juan Carlos Manzanares Serrano
# Modified by Juan Carlos Manzanares Serrano & Rui Bartolome Segura

import os

Expand All @@ -30,6 +30,30 @@
from launch_ros.actions import Node
import yaml

import subprocess

astra = False
xtion= False

try:
result = subprocess.run(
["lsusb"],
capture_output=True,
text=True
)

for line in result.stdout.splitlines():
if "Astra" in line:
astra = True
elif "Xtion" in line:
xtion = True

except FileNotFoundError:
print("lsusb is not avaliable in the system")


except subprocess.CalledProcessError as e:
print("Error running lsusb:", e.stderr)

def start_description(context):

Expand All @@ -41,8 +65,8 @@ def start_description(context):
lidar = DeclareLaunchArgument('lidar', default_value='false')
description.append(lidar)

if (LaunchConfiguration('xtion').perform(context) == 'true' or
LaunchConfiguration('astra').perform(context) == 'true'):

if astra or xtion:
description.append(SetLaunchConfiguration('camera', 'true'))

if (LaunchConfiguration('lidar_a2').perform(context) == 'true' or
Expand Down Expand Up @@ -130,7 +154,7 @@ def start_lidar(context):

def start_camera(context):

if LaunchConfiguration('xtion').perform(context) == 'true':
if xtion:
xtion_cmd = GroupAction(
scoped=True,
actions=[
Expand All @@ -145,7 +169,7 @@ def start_camera(context):

return [xtion_cmd]

if LaunchConfiguration('astra').perform(context) == 'true':
if astra:
astra_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource([os.path.join(
get_package_share_directory('astra_camera'),
Expand Down