-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ROS2 temporal provider examples include files
- Loading branch information
1 parent
9d65d33
commit f776811
Showing
4 changed files
with
182 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,31 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
cmake_minimum_required(VERSION 3.5) | ||
project(freyja_examples) | ||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3" ) | ||
|
||
## Find catkin macros and libraries | ||
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) | ||
## is used, also find other catkin packages | ||
find_package(catkin REQUIRED COMPONENTS | ||
geometry_msgs | ||
message_generation | ||
roscpp | ||
freyja_msgs | ||
std_msgs | ||
) | ||
|
||
add_compile_options( -std=c++14 -O3 -ffast-math -Wall ) | ||
|
||
catkin_package( | ||
# INCLUDE_DIRS include | ||
# LIBRARIES trajectory_provider | ||
CATKIN_DEPENDS geometry_msgs message_generation message_runtime roscpp std_msgs | ||
# DEPENDS system_lib | ||
) | ||
find_package(ament_cmake REQUIRED) | ||
|
||
########### | ||
## Build ## | ||
########### | ||
find_package(rclcpp REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(std_srvs REQUIRED) | ||
find_package(freyja_msgs REQUIRED) | ||
|
||
include_directories(include) | ||
include_directories( | ||
${catkin_INCLUDE_DIRS} | ||
|
||
add_executable(temporal_provider src/temporal_provider.cpp) | ||
|
||
target_include_directories( temporal_provider PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
ament_target_dependencies( temporal_provider | ||
rclcpp | ||
freyja_msgs | ||
std_msgs | ||
) | ||
|
||
# simple trajectory provider | ||
add_executable(temporal_provider_node src/temporal_provider.cpp) | ||
add_dependencies(temporal_provider_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) | ||
install(TARGETS | ||
temporal_provider | ||
DESTINATION lib/${PROJECT_NAME}) | ||
|
||
target_link_libraries(temporal_provider_node | ||
${catkin_LIBRARIES} | ||
) | ||
|
||
ament_package() |
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,55 @@ | ||
/* Provides a trajectory for the vehicle to follow. | ||
EXAMPLE FILE; ONLY FOR SUPPORT. | ||
Whatever you do here, output a time-based continuous function to follow. | ||
This node should generate a 7 vector: [pn pe pd vn ve vd yaw]' for the vehicle | ||
to follow. The controller currently listens to this reference trajectory | ||
and updates its knowledge of the "latest" reference point. | ||
-- aj / 23rd Nov, 2017. | ||
*/ | ||
|
||
#include <chrono> | ||
#include <cmath> | ||
#include <memory> | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "std_msgs/msg/u_int8.hpp" | ||
#include "freyja_msgs/msg/reference_state.hpp" | ||
|
||
typedef freyja_msgs::msg::ReferenceState TrajRef; | ||
|
||
#define DEG2RAD(D) ((D)*3.1415326/180.0) | ||
|
||
using std::placeholders::_1; | ||
using namespace std::chrono_literals; | ||
|
||
rclcpp::Time init_time; | ||
std::string traj_type; | ||
int agg_level; | ||
|
||
class Temporal_Traj : public rclcpp::Node | ||
{ | ||
TrajRef ref_state; | ||
rclcpp::Time init_time; | ||
|
||
std::string traj_type; | ||
int agg_level; | ||
|
||
public: | ||
Temporal_Traj(); | ||
|
||
rclcpp::Subscription<std_msgs::msg::UInt8>::SharedPtr time_reset_sub_; | ||
void timer_reset_cb( const std_msgs::msg::UInt8::SharedPtr msg ); | ||
|
||
rclcpp::Publisher<TrajRef>::SharedPtr traj_pub_; | ||
|
||
rclcpp::TimerBase::SharedPtr traj_update_timer_; | ||
void traj_update_cb(); | ||
|
||
TrajRef getHoverReference( rclcpp::Duration cur_time ); | ||
TrajRef getCircleReference( rclcpp::Duration cur_time, const int agg_level); | ||
TrajRef getDefaultReference( rclcpp::Duration cur_time ); | ||
TrajRef getLemiscateReference( rclcpp::Duration cur_time, const int agg_level); | ||
|
||
}; | ||
|
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 |
---|---|---|
@@ -1,34 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<package> | ||
<package format="3"> | ||
<name>freyja_examples</name> | ||
<version>0.0.0</version> | ||
<description>The examples package showing use cases</description> | ||
|
||
<!-- One maintainer tag required, multiple allowed, one person per tag --> | ||
<!-- Example: --> | ||
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> --> | ||
<maintainer email="[email protected]">aj</maintainer> | ||
|
||
<description>ROS2 Trajectory Examples</description> | ||
<maintainer email="[email protected]">Peter Woo</maintainer> | ||
<license>GPLv3</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
<build_depend>geometry_msgs</build_depend> | ||
<build_depend>message_generation</build_depend> | ||
<build_depend>roscpp</build_depend> | ||
<build_depend>freyja_msgs</build_depend> | ||
<build_depend>std_msgs</build_depend> | ||
|
||
<run_depend>geometry_msgs</run_depend> | ||
<run_depend>message_runtime</run_depend> | ||
<run_depend>roscpp</run_depend> | ||
<run_depend>std_msgs</run_depend> | ||
<run_depend>message_generation</run_depend> | ||
|
||
|
||
<!-- The export tag contains other, unspecified, tags --> | ||
<export> | ||
<!-- Other tools can request additional information be placed here --> | ||
<depend>rclcpp</depend> | ||
<depend>std_msgs</depend> | ||
<depend>std_srvs</depend> | ||
<depend>freyja_msgs</depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
|
||
</package> |
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