Skip to content

Commit

Permalink
add more packages that are building fine
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN committed Nov 26, 2024
1 parent 428f251 commit 7cc26ab
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 104 deletions.
8 changes: 7 additions & 1 deletion mock_controller_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
# License for the specific language governing permissions and limitations under
# the License.

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.8)
project(mock_controller_driver)

# Declare carma package and check ROS version
find_package(carma_cmake_common REQUIRED)
carma_check_ros_version(2)
carma_package()

# Use C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

## Find dependencies using ament auto
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
Expand Down
14 changes: 10 additions & 4 deletions template_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
# License for the specific language governing permissions and limitations under
# the License.

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.8)
project(<SUB><package_name>)

# Declare carma package and check ROS version
find_package(carma_cmake_common REQUIRED)
carma_check_ros_version(2)
carma_package()

# Use C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

## Find dependencies using ament auto
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
Expand All @@ -39,8 +45,8 @@ ament_auto_add_library(${node_lib} SHARED
src/<SUB><package_name>_node.cpp
)

ament_auto_add_executable(${node_exec}
src/main.cpp
ament_auto_add_executable(${node_exec}
src/main.cpp
)

# Register component
Expand All @@ -53,7 +59,7 @@ target_link_libraries(${node_exec}
)

# Testing
if(BUILD_TESTING)
if(BUILD_TESTING)

find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies() # This populates the ${${PROJECT_NAME}_FOUND_TEST_DEPENDS} variable
Expand Down
6 changes: 3 additions & 3 deletions template_package/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>

<!--
<!--
Copyright (C) <SUB><year> LEIDOS.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
Expand All @@ -15,13 +15,13 @@

<package format="3">
<name><SUB><package_name></name>
<version>1.0.0</version>
<version>5.0.0</version>
<description>The <SUB><package_name> package</description>

<maintainer email="[email protected]">carma</maintainer>

<license>Apache 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>carma_cmake_common</build_depend>
<build_depend>ament_auto_cmake</build_depend>
Expand Down
47 changes: 23 additions & 24 deletions template_package/src/template_control_plugin_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
#include "<SUB><package_name>/<SUB><package_name>_node.hpp"

namespace <SUB><package_name>
namespace<SUB><package_name>
{
namespace std_ph = std::placeholders;

Node::Node(const rclcpp::NodeOptions &options)
: carma_guidance_plugins::ControlPlugin(options)
Node::Node(const rclcpp::NodeOptions & options) : carma_guidance_plugins::ControlPlugin(options)
{
// Create initial config
config_ = Config();
Expand All @@ -29,9 +28,11 @@ namespace <SUB><package_name>
config_.example_param = declare_parameter<std::string>("example_param", config_.example_param);
}

rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(const std::vector<rclcpp::Parameter> &parameters)
rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(
const std::vector<rclcpp::Parameter> & parameters)
{
// TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this method
// TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this
// method
auto error = update_params<std::string>({{"example_param", config_.example_param}}, parameters);

rcl_interfaces::msg::SetParametersResult result;
Expand All @@ -53,8 +54,8 @@ namespace <SUB><package_name>
add_on_set_parameters_callback(std::bind(&Node::parameter_update_callback, this, std_ph::_1));

// Setup subscribers
example_sub_ = create_subscription<std_msgs::msg::String>("example_input_topic", 10,
std::bind(&Node::example_callback, this, std_ph::_1));
example_sub_ = create_subscription<std_msgs::msg::String>(
"example_input_topic", 10, std::bind(&Node::example_callback, this, std_ph::_1));

// Setup publishers
example_pub_ = create_publisher<std_msgs::msg::String>("example_output_topic", 10);
Expand All @@ -63,27 +64,26 @@ namespace <SUB><package_name>
example_client_ = create_client<std_srvs::srv::Empty>("example_used_service");

// Setup service servers
example_service_ = create_service<std_srvs::srv::Empty>("example_provided_service",
std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));
example_service_ = create_service<std_srvs::srv::Empty>(
"example_provided_service",
std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));

// Setup timers
// NOTE: You will not be able to actually publish until in the ACTIVE state
// NOTE: You will not be able to actually publish until in the ACTIVE state
// so it may often make more sense for timers to be created in handle_on_activate
example_timer_ = create_timer(
get_clock(),
std::chrono::milliseconds(1000),
std::bind(&Node::example_timer_callback, this));
get_clock(), std::chrono::milliseconds(1000), std::bind(&Node::example_timer_callback, this));

// Return success if everthing initialized successfully
return CallbackReturn::SUCCESS;
}

// Parameter names not shown to prevent unused compile warning. The user may add them back
void Node::example_service_callback(const std::shared_ptr<rmw_request_id_t>,
const std::shared_ptr<std_srvs::srv::Empty::Request>,
std::shared_ptr<std_srvs::srv::Empty::Response>)
void Node::example_service_callback(
const std::shared_ptr<rmw_request_id_t>, const std::shared_ptr<std_srvs::srv::Empty::Request>,
std::shared_ptr<std_srvs::srv::Empty::Response>)
{
RCLCPP_INFO( get_logger(), "Example service callback");
RCLCPP_INFO(get_logger(), "Example service callback");
}

void Node::example_timer_callback()
Expand All @@ -96,7 +96,7 @@ namespace <SUB><package_name>

void Node::example_callback(std_msgs::msg::String::UniquePtr msg)
{
RCLCPP_INFO_STREAM( get_logger(), "example_sub_ callback called with value: " << msg->data);
RCLCPP_INFO_STREAM(get_logger(), "example_sub_ callback called with value: " << msg->data);
}

autoware_msgs::msg::ControlCommandStamped Node::generate_command()
Expand All @@ -106,15 +106,14 @@ namespace <SUB><package_name>
return msg;
}

bool Node::get_availability() {
return true; // TODO for user implement actual check on availability if applicable to plugin
bool Node::get_availability()
{
return true; // TODO for user implement actual check on availability if applicable to plugin
}

std::string Node::get_version_id() {
return "TODO for user specify plugin version id here";
}
std::string Node::get_version_id() { return "TODO for user specify plugin version id here"; }

} // <SUB><package_name>
} // namespace >

#include "rclcpp_components/register_node_macro.hpp"

Expand Down
38 changes: 19 additions & 19 deletions template_package/src/template_package_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
#include "<SUB><package_name>/<SUB><package_name>_node.hpp"

namespace <SUB><package_name>
namespace<SUB><package_name>
{
namespace std_ph = std::placeholders;

Node::Node(const rclcpp::NodeOptions &options)
: carma_ros2_utils::CarmaLifecycleNode(options)
Node::Node(const rclcpp::NodeOptions & options) : carma_ros2_utils::CarmaLifecycleNode(options)
{
// Create initial config
config_ = Config();
Expand All @@ -29,9 +28,11 @@ namespace <SUB><package_name>
config_.example_param = declare_parameter<std::string>("example_param", config_.example_param);
}

rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(const std::vector<rclcpp::Parameter> &parameters)
rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(
const std::vector<rclcpp::Parameter> & parameters)
{
// TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this method
// TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this
// method
auto error = update_params<std::string>({{"example_param", config_.example_param}}, parameters);

rcl_interfaces::msg::SetParametersResult result;
Expand All @@ -53,8 +54,8 @@ namespace <SUB><package_name>
add_on_set_parameters_callback(std::bind(&Node::parameter_update_callback, this, std_ph::_1));

// Setup subscribers
example_sub_ = create_subscription<std_msgs::msg::String>("example_input_topic", 10,
std::bind(&Node::example_callback, this, std_ph::_1));
example_sub_ = create_subscription<std_msgs::msg::String>(
"example_input_topic", 10, std::bind(&Node::example_callback, this, std_ph::_1));

// Setup publishers
example_pub_ = create_publisher<std_msgs::msg::String>("example_output_topic", 10);
Expand All @@ -63,27 +64,26 @@ namespace <SUB><package_name>
example_client_ = create_client<std_srvs::srv::Empty>("example_used_service");

// Setup service servers
example_service_ = create_service<std_srvs::srv::Empty>("example_provided_service",
std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));
example_service_ = create_service<std_srvs::srv::Empty>(
"example_provided_service",
std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));

// Setup timers
// NOTE: You will not be able to actually publish until in the ACTIVE state
// NOTE: You will not be able to actually publish until in the ACTIVE state
// so it may often make more sense for timers to be created in handle_on_activate
example_timer_ = create_timer(
get_clock(),
std::chrono::milliseconds(1000),
std::bind(&Node::example_timer_callback, this));
get_clock(), std::chrono::milliseconds(1000), std::bind(&Node::example_timer_callback, this));

// Return success if everything initialized successfully
return CallbackReturn::SUCCESS;
}

// Parameter names not shown to prevent unused compile warning. The user may add them back
void Node::example_service_callback(const std::shared_ptr<rmw_request_id_t>,
const std::shared_ptr<std_srvs::srv::Empty::Request>,
std::shared_ptr<std_srvs::srv::Empty::Response>)
void Node::example_service_callback(
const std::shared_ptr<rmw_request_id_t>, const std::shared_ptr<std_srvs::srv::Empty::Request>,
std::shared_ptr<std_srvs::srv::Empty::Response>)
{
RCLCPP_INFO( get_logger(), "Example service callback");
RCLCPP_INFO(get_logger(), "Example service callback");
}

void Node::example_timer_callback()
Expand All @@ -96,10 +96,10 @@ namespace <SUB><package_name>

void Node::example_callback(std_msgs::msg::String::UniquePtr msg)
{
RCLCPP_INFO_STREAM( get_logger(), "example_sub_ callback called with value: " << msg->data);
RCLCPP_INFO_STREAM(get_logger(), "example_sub_ callback called with value: " << msg->data);
}

} // <SUB><package_name>
} // namespace >

#include "rclcpp_components/register_node_macro.hpp"

Expand Down
51 changes: 25 additions & 26 deletions template_package/src/template_strategic_plugin_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
#include "<SUB><package_name>/<SUB><package_name>_node.hpp"

namespace <SUB><package_name>
namespace<SUB><package_name>
{
namespace std_ph = std::placeholders;

Node::Node(const rclcpp::NodeOptions &options)
: carma_guidance_plugins::StrategicPlugin(options)
Node::Node(const rclcpp::NodeOptions & options) : carma_guidance_plugins::StrategicPlugin(options)
{
// Create initial config
config_ = Config();
Expand All @@ -29,9 +28,11 @@ namespace <SUB><package_name>
config_.example_param = declare_parameter<std::string>("example_param", config_.example_param);
}

rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(const std::vector<rclcpp::Parameter> &parameters)
rcl_interfaces::msg::SetParametersResult Node::parameter_update_callback(
const std::vector<rclcpp::Parameter> & parameters)
{
// TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this method
// TODO for the USER: Ensure all parameters can be updated dynamically by adding them to this
// method
auto error = update_params<std::string>({{"example_param", config_.example_param}}, parameters);

rcl_interfaces::msg::SetParametersResult result;
Expand All @@ -53,8 +54,8 @@ namespace <SUB><package_name>
add_on_set_parameters_callback(std::bind(&Node::parameter_update_callback, this, std_ph::_1));

// Setup subscribers
example_sub_ = create_subscription<std_msgs::msg::String>("example_input_topic", 10,
std::bind(&Node::example_callback, this, std_ph::_1));
example_sub_ = create_subscription<std_msgs::msg::String>(
"example_input_topic", 10, std::bind(&Node::example_callback, this, std_ph::_1));

// Setup publishers
example_pub_ = create_publisher<std_msgs::msg::String>("example_output_topic", 10);
Expand All @@ -63,27 +64,26 @@ namespace <SUB><package_name>
example_client_ = create_client<std_srvs::srv::Empty>("example_used_service");

// Setup service servers
example_service_ = create_service<std_srvs::srv::Empty>("example_provided_service",
std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));
example_service_ = create_service<std_srvs::srv::Empty>(
"example_provided_service",
std::bind(&Node::example_service_callback, this, std_ph::_1, std_ph::_2, std_ph::_3));

// Setup timers
// NOTE: You will not be able to actually publish until in the ACTIVE state
// NOTE: You will not be able to actually publish until in the ACTIVE state
// so it may often make more sense for timers to be created in handle_on_activate
example_timer_ = create_timer(
get_clock(),
std::chrono::milliseconds(1000),
std::bind(&Node::example_timer_callback, this));
get_clock(), std::chrono::milliseconds(1000), std::bind(&Node::example_timer_callback, this));

// Return success if everything initialized successfully
return CallbackReturn::SUCCESS;
}

// Parameter names not shown to prevent unused compile warning. The user may add them back
void Node::example_service_callback(const std::shared_ptr<rmw_request_id_t>,
const std::shared_ptr<std_srvs::srv::Empty::Request>,
std::shared_ptr<std_srvs::srv::Empty::Response>)
void Node::example_service_callback(
const std::shared_ptr<rmw_request_id_t>, const std::shared_ptr<std_srvs::srv::Empty::Request>,
std::shared_ptr<std_srvs::srv::Empty::Response>)
{
RCLCPP_INFO( get_logger(), "Example service callback");
RCLCPP_INFO(get_logger(), "Example service callback");
}

void Node::example_timer_callback()
Expand All @@ -96,26 +96,25 @@ namespace <SUB><package_name>

void Node::example_callback(std_msgs::msg::String::UniquePtr msg)
{
RCLCPP_INFO_STREAM( get_logger(), "example_sub_ callback called with value: " << msg->data);
RCLCPP_INFO_STREAM(get_logger(), "example_sub_ callback called with value: " << msg->data);
}

void Node::plan_maneuvers_callback(
std::shared_ptr<rmw_request_id_t>,
carma_planning_msgs::srv::PlanManeuvers::Request::SharedPtr req,
std::shared_ptr<rmw_request_id_t>,
carma_planning_msgs::srv::PlanManeuvers::Request::SharedPtr req,
carma_planning_msgs::srv::PlanManeuvers::Response::SharedPtr resp)
{
// TODO for user: Implement maneuver planning logic here to populate resp based on req.
}

bool Node::get_availability() {
return true; // TODO for user implement actual check on availability if applicable to plugin
bool Node::get_availability()
{
return true; // TODO for user implement actual check on availability if applicable to plugin
}

std::string Node::get_version_id() {
return "TODO for user specify plugin version id here";
}
std::string Node::get_version_id() { return "TODO for user specify plugin version id here"; }

} // <SUB><package_name>
} // namespace >

#include "rclcpp_components/register_node_macro.hpp"

Expand Down
Loading

0 comments on commit 7cc26ab

Please sign in to comment.