Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion racecar_bringup/racecar_bringup/cmd_vel_arbitration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def __init__(self):
self._delay_sec = (
self.declare_parameter("delay_sec", 0.5).get_parameter_value().double_value
)

self._bypass_joy = (
self.declare_parameter("bypass_joy", False).get_parameter_value().bool_value
)

self._time_called = [self.get_clock().now() for _ in range(9)]

self._cmd_vel_pub = self.create_publisher(Twist, "cmd_vel_output", 1)
Expand Down Expand Up @@ -50,7 +55,7 @@ def cmd_vel_callback(self, msg, priority: int):
pub = False
break
if pub:
if self.__autopilot_active:
if self.__autopilot_active or self._bypass_joy:
self._cmd_vel_pub.publish(msg)
elif priority == 0:
self._cmd_vel_pub.publish(msg)
Expand Down
5 changes: 4 additions & 1 deletion racecar_gazebo/launch/simulation.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def launch_setup(context: LaunchContext, *args, **kwargs):
PythonLaunchDescriptionSource(
[os.path.join(racecar_gazebo, "launch", "spawn_racecar.launch.py")]
),
launch_arguments={"use_joy": LaunchConfiguration('use_joy')}.items()
)

return (gazeboDefaultResourcePath, addRacecarGazeboResourcePath, gazebo, spawn_racecar)
Expand All @@ -51,4 +52,6 @@ def generate_launch_description():
choices=["tunnel", "tunnel_genie", "circuit"],
)

return LaunchDescription([world_arg, OpaqueFunction(function=launch_setup)])
return LaunchDescription([DeclareLaunchArgument('use_joy', default_value='True', description="launch joy related node"),
world_arg,
OpaqueFunction(function=launch_setup)])
18 changes: 9 additions & 9 deletions racecar_gazebo/launch/spawn_racecar.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument, OpaqueFunction
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from xml.dom.minidom import Document


def launch_setup(context, *args, **kwargs):
# Declare launch arguments
# Get launch arguments
prefix = LaunchConfiguration('prefix').perform(context)
use_joy = LaunchConfiguration('use_joy').perform(context).lower() == "true"

# Package Directories
racecar_description = get_package_share_directory('racecar_description')
# racecar_gazebo = get_package_share_directory('racecar_gazebo') # NOTE: Unused.
racecar_navigation = get_package_share_directory('racecar_navigation')

# Parse robot description from xacro
Expand Down Expand Up @@ -68,6 +69,7 @@ def launch_setup(context, *args, **kwargs):
cmd_vel_arb = Node(
package='racecar_bringup',
executable='cmd_vel_arbitration',
parameters=[{'bypass_joy': not use_joy}],
remappings=[(f'/{prefix}/cmd_vel_output', f'/{prefix}/cmd_vel')],
namespace=prefix
)
Expand All @@ -79,7 +81,8 @@ def launch_setup(context, *args, **kwargs):
parameters=[{'deadzone': 0.2},
{'autorepeat_rate': 0.0},
{'coalesce_interval': 0.01}],
namespace=prefix
namespace=prefix,
condition=IfCondition(LaunchConfiguration('use_joy'))
)


Expand All @@ -88,14 +91,11 @@ def launch_setup(context, *args, **kwargs):
executable='slash_teleop',
name='racecar_teleop',
remappings=[(f'/{prefix}/ctl_ref', f'/{prefix}/cmd_vel_abtr_0')],
namespace=prefix
namespace=prefix,
condition=IfCondition(LaunchConfiguration('use_joy'))
)


# gaz_control = IncludeLaunchDescription(
# PythonLaunchDescriptionSource([os.path.join(racecar_gazebo, 'launch', 'gazebo_control.launch.py')]),
# ) # NOTE: Does nothing.

kalmanFilter = IncludeLaunchDescription(
PythonLaunchDescriptionSource([os.path.join(racecar_navigation, 'launch', 'kalmanFilter.launch.py')]),
launch_arguments={"odom_topic":f'/{prefix}/odom/filtered',
Expand All @@ -110,14 +110,14 @@ def launch_setup(context, *args, **kwargs):
cmd_vel_arb,
joystick,
teleop,
# gaz_control,
kalmanFilter
]

def generate_launch_description():

return LaunchDescription([
DeclareLaunchArgument('prefix', default_value='racecar'),
DeclareLaunchArgument('use_joy', default_value='True', description="launch joy related node"),
OpaqueFunction(function=launch_setup)
])

Expand Down