Skip to content

Commit

Permalink
Audio nodes (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafadam authored Oct 19, 2023
1 parent 574c973 commit 3b135fc
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 38 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# RAE ROS

This repository contains rae [ROS](https://www.ros.org/) integration files.
This repository contains rae [ROS](https://www.ros.org/) integration files.
**Note** The RAE project is under active development so you can expect changes in the API and improvements in the performance in near future. Please report problems on Github issues as it's important for the development efforts.

### Setting up procedure

Expand Down
34 changes: 10 additions & 24 deletions rae_description/launch/rsp.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,26 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, OpaqueFunction
from launch.substitutions import Command, LaunchConfiguration
from launch_ros.actions import LoadComposableNodes, ComposableNodeContainer
from launch_ros.actions import Node
from launch_ros.descriptions import ComposableNode
from launch.conditions import IfCondition


def launch_setup(context, *args, **kwargs):
name = LaunchConfiguration('name').perform(context)
use_sim_time = LaunchConfiguration('use_sim_time')
run_container = LaunchConfiguration('run_container')
pkg_path = os.path.join(get_package_share_directory('rae_description'))
xacro_path = os.path.join(pkg_path, 'urdf', 'rae.urdf.xacro')

return [
ComposableNodeContainer(
condition=IfCondition(run_container),
name=name+"_container",
namespace="",
package="rclcpp_components",
executable="component_container",
composable_node_descriptions=[],
output="both",
),
LoadComposableNodes(
target_container=name+"_container",
composable_node_descriptions=[
ComposableNode(
package='robot_state_publisher',
plugin='robot_state_publisher::RobotStatePublisher',
name=name+'_state_publisher',
parameters=[{
'robot_description': Command(['xacro ', xacro_path, ' sim_mode:=', use_sim_time]),
'use_sim_time': use_sim_time
}]
)])
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher',
parameters=[{
'robot_description': Command(['xacro ', xacro_path, ' sim_mode:=', use_sim_time]),
'use_sim_time': use_sim_time
}]
)
]


Expand Down
9 changes: 8 additions & 1 deletion rae_hw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ install(
LIBRARY DESTINATION lib
)

add_executable(mic_node src/mic_node.cpp)
ament_target_dependencies(mic_node rclcpp audio_msgs)
target_link_libraries(mic_node ${PROJECT_NAME})

add_executable(speakers_node src/speakers_node.cpp)
ament_target_dependencies(speakers_node rclcpp audio_msgs)
target_link_libraries(speakers_node ${PROJECT_NAME})

add_executable(test_motors test/test_motors.cpp src/rae_motors.cpp)
target_link_libraries(test_motors ${GPIOD_LIBRARY})
Expand All @@ -76,7 +83,7 @@ ament_target_dependencies(test_speed rclcpp geometry_msgs)

install(TARGETS

test_motors test_encoders test_max_speed test_speed
test_motors test_encoders test_max_speed test_speed mic_node speakers_node

DESTINATION lib/${PROJECT_NAME})

Expand Down
21 changes: 9 additions & 12 deletions rae_hw/launch/peripherals.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ def launch_setup(context, *args, **kwargs):
name='led_node',
package='rae_hw',
plugin='rae_hw::LEDNode',
),
ComposableNode(
name='mic_node',
package='rae_hw',
plugin='rae_hw::MicNode',
),
ComposableNode(
name='motors_node',
package='rae_hw',
plugin='rae_hw::SpeakersNode',
),
)
]),

Node(
package='rae_hw',
executable='mic_node'
),
Node(
package='rae_hw',
executable='speakers_node'
),
Node(
package='rae_bringup',
executable='battery_status.py',
Expand Down
16 changes: 16 additions & 0 deletions rae_hw/src/mic_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "rclcpp/rclcpp.hpp"
#include "rae_hw/peripherals/mic.hpp"

int main(int argc, char *argv[])
{
rclcpp::init(argc, argv);

auto node = std::make_shared<rae_hw::MicNode>(rclcpp::NodeOptions());
rclcpp::executors::StaticSingleThreadedExecutor executor;
executor.add_node(node);
executor.spin();

rclcpp::shutdown();

return 0;
}
16 changes: 16 additions & 0 deletions rae_hw/src/speakers_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "rclcpp/rclcpp.hpp"
#include "rae_hw/peripherals/speakers.hpp"

int main(int argc, char *argv[])
{
rclcpp::init(argc, argv);

auto node = std::make_shared<rae_hw::SpeakersNode>(rclcpp::NodeOptions());
rclcpp::executors::StaticSingleThreadedExecutor executor;
executor.add_node(node);
executor.spin();

rclcpp::shutdown();

return 0;
}

0 comments on commit 3b135fc

Please sign in to comment.