-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mock hardware components and namespace
- Loading branch information
Showing
15 changed files
with
322 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import os | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
from launch import LaunchDescription | ||
from launch.launch_description_sources import PythonLaunchDescriptionSource | ||
from launch.actions import IncludeLaunchDescription, OpaqueFunction, DeclareLaunchArgument | ||
from launch.substitutions import LaunchConfiguration | ||
from launch.conditions import IfCondition | ||
from launch_ros.actions import Node | ||
import xacro | ||
|
||
|
||
def launch_setup(context, *args, **kwargs): | ||
rae_description_path = os.path.join(get_package_share_directory( | ||
'rae_description'), 'urdf', 'rae.urdf.xacro') | ||
return [ | ||
IncludeLaunchDescription( | ||
PythonLaunchDescriptionSource( | ||
os.path.join(get_package_share_directory('rae_description'), 'launch', 'rsp.launch.py')), | ||
launch_arguments={'sim': 'false', | ||
'namespace': LaunchConfiguration('namespace'), | ||
}.items() | ||
), | ||
Node( | ||
package='rae_hw', | ||
executable='mock_wheels.py', | ||
name='mock_wheels', | ||
namespace=LaunchConfiguration('namespace') | ||
), | ||
Node( | ||
package='rae_hw', | ||
executable='mock_leds.py', | ||
name='mock_leds', | ||
namespace=LaunchConfiguration('namespace') | ||
), | ||
Node( | ||
package='rae_hw', | ||
executable='mock_battery.py', | ||
name='mock_battery', | ||
namespace=LaunchConfiguration('namespace') | ||
), | ||
Node( | ||
package='rae_hw', | ||
executable='mock_lcd.py', | ||
name='mock_lcd', | ||
namespace=LaunchConfiguration('namespace') | ||
), | ||
Node( | ||
package='rae_hw', | ||
executable='mock_speakers.py', | ||
name='mock_speakers', | ||
namespace=LaunchConfiguration('namespace') | ||
), | ||
Node( | ||
package='rae_hw', | ||
executable='mock_mic.py', | ||
name='mock_mic', | ||
namespace=LaunchConfiguration('namespace') | ||
) | ||
] | ||
|
||
|
||
def generate_launch_description(): | ||
declared_arguments = [ | ||
DeclareLaunchArgument('name', default_value='rae'), | ||
DeclareLaunchArgument('namespace', default_value=''), | ||
DeclareLaunchArgument('run_container', default_value='true'), | ||
DeclareLaunchArgument('enable_battery_status', default_value='true'), | ||
DeclareLaunchArgument('enable_localization', default_value='true'), | ||
DeclareLaunchArgument('controller_params_file', default_value=os.path.join(get_package_share_directory( | ||
'rae_hw'), 'config', 'controller.yaml')), | ||
] | ||
|
||
return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from sensor_msgs.msg import BatteryState | ||
|
||
class MockBattery(Node): | ||
def __init__(self): | ||
super().__init__('mock_battery') | ||
self._battery_pub = self.create_publisher(BatteryState, 'battery', 10) | ||
self.timer = self.create_timer(1, self.timer_callback) | ||
|
||
def timer_callback(self): | ||
msg = BatteryState() | ||
self._battery_pub.publish(msg) | ||
|
||
if __name__ == '__main__': | ||
rclpy.init() | ||
mock_battery = MockBattery() | ||
rclpy.spin(mock_battery) | ||
mock_battery.destroy_node() | ||
rclpy.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from sensor_msgs.msg import Image | ||
|
||
class MockLCD(Node): | ||
def __init__(self): | ||
super().__init__('mock_display') | ||
self._image_sub = self.create_subscription(Image, 'lcd', self.image_callback, 10) | ||
def image_callback(self, msg: Image): | ||
self.get_logger().info(f'I heard: {msg.width}, {msg.height}') | ||
|
||
if __name__ == '__main__': | ||
rclpy.init() | ||
mock_lcd = MockLCD() | ||
rclpy.spin(mock_lcd) | ||
mock_lcd.destroy_node() | ||
rclpy.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python3 | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from rae_msgs.msg import LEDControl | ||
|
||
class MockLeds(Node): | ||
def __init__(self): | ||
super().__init__('mock_leds') | ||
self._led_sub = self.create_subscription(LEDControl, 'leds', self.led_callback, 10) | ||
def led_callback(self, msg: LEDControl): | ||
self.get_logger().info('I heard: "%s"' % msg.data) | ||
|
||
if __name__ == '__main__': | ||
rclpy.init() | ||
mock_leds = MockLeds() | ||
rclpy.spin(mock_leds) | ||
mock_leds.destroy_node() | ||
rclpy.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
import rclpy | ||
from rclpy.node import Node | ||
from audio_msgs.msg import Audio | ||
|
||
|
||
class MockMic(Node): | ||
def __init__(self): | ||
super().__init__('mock_mic') | ||
self._audio_pub = self.create_publisher(Audio, 'audio_in', 10) | ||
self.timer = self.create_timer(1, self.timer_callback) | ||
|
||
def timer_callback(self): | ||
msg = Audio() | ||
self._audio_pub.publish(msg) | ||
|
||
if __name__ == '__main__': | ||
rclpy.init() | ||
mock_mic = MockMic() | ||
rclpy.spin(mock_mic) | ||
mock_mic.destroy_node() | ||
rclpy.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python3 | ||
import rclpy | ||
from rclpy.node import Node | ||
|
||
from audio_msgs.msg import Audio | ||
from rae_msgs.srv import PlayAudio | ||
|
||
|
||
class MockSpeakers(Node): | ||
def __init__(self): | ||
super().__init__('mock_speakers') | ||
self._audio_sub = self.create_subscription( | ||
Audio, 'audio_out', self.audio_callback, 10) | ||
self._play_service = self.create_service( | ||
PlayAudio, 'play_audio', self.play_callback) | ||
|
||
def audio_callback(self, msg: Audio): | ||
self.get_logger().info('I heard: "%s"' % msg.data) | ||
|
||
def play_callback(self, request: PlayAudio.Request, response): | ||
self.get_logger().info('I heard: "%s"' % request.mp3_file) | ||
return response | ||
|
||
|
||
if __name__ == '__main__': | ||
rclpy.init() | ||
mock_speakers = MockSpeakers() | ||
rclpy.spin(mock_speakers) | ||
mock_speakers.destroy_node() | ||
rclpy.shutdown() |
Oops, something went wrong.