Skip to content

Commit

Permalink
Merge pull request #8 from mROS-base/v0.2.4
Browse files Browse the repository at this point in the history
V0.2.4
  • Loading branch information
takasehideki authored Feb 20, 2022
2 parents 282623b + 0d142e2 commit b0750bf
Show file tree
Hide file tree
Showing 20 changed files with 308 additions and 131 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
log/
.vscode/
build/
install/
git rm --cached -r mros2_echoback_joint_state
git rm --cached -r mros2_echoback_odometry
48 changes: 31 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,47 @@ Please also check [mROS-base/mros2-asp3-f767zi/workspace](https://github.com/mRO
- `$ ros2 run mros2_echoback_string sub_node`
- mros2 application on the embedded device:
- [echoreply_string](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/echoreply_string)
- [pub_string](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/pub_string)
- [sub_string](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/sub_string)

## mros2_echoback_uint16
## mros2_pub_uint16

- Description:
- The `pub_mros2` node on the host publishes `uint16` (`std_msgs::msg::UInt16`) message to `/to_stm` topic.
- (The mros2 node on the embedded device will echoreply this message as it is.)
- The `mros2_sub` node on the host subscribes `uint16` message from `/to_linux` topic.
- Host operation:
- `$ ros2 launch mros2_echoback_uint16 launch.py`
- `$ ros2 launch mros2_pub_uint16 launch.py`
- or, at two terminals:
- `$ ros2 run mros2_echoback_uint16 pub_node`
- `$ ros2 run mros2_echoback_uint16 sub_node`
- `$ ros2 run mros2_pub_uint16 pub_node`
- mros2 application on the embedded device:
- [echoreply_uint16](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/echoreply_uint16)
- [sub_uint16](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/sub_uint16)

## mros2_echoback_string
## mros2_sub_float32

- Description:
- The `pub_mros2` node on the host publishes `float32` (`std_msgs::msg::Float32`) message to `/to_stm` topic.
- (The mros2 node on the embedded device will echoreply this message as it is.)
- The `mros2_sub` node on the host subscribes `float32` message from `/to_linux` topic.
- The `mros2_sub` node on the host subscribes `float32` (`std_msgs::msg::Float32`) message from `/to_linux` topic.
- Host operation:
- `$ ros2 launch mros2_sub_float32 launch.py`
- or, at two terminals:
- `$ ros2 run mros2_sub_float32 sub_node`
- mros2 application on the embedded device:
- [pub_float32](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/pub_float32)

## mros2_pub_pose

- Description:
- The `pub_pose` node on the host publishes `Pose` (`geometry_msgs::msg::Pose`) message to `cmd_vel` topic.
- Host operation:
- `$ ros2 launch mros2_pub_pose launch.py`
- or, at two terminals:
- `$ ros2 run mros2_pub_pose pub_node`
- mros2 application on the embedded device:
- [sub_pose](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/sub_pose)

## mros2_sub_twist

- Description:
- The `sub_twist` node on the host subscribes `Twist` (`geometry_msgs::msg::Twist`) message from `cmd_vel` topic.
- Host operation:
- `$ ros2 launch mros2_echoback_float32 launch.py`
- `$ ros2 launch mros2_sub_twist launch.py`
- or, at two terminals:
- `$ ros2 run mros2_echoback_float32 pub_node`
- `$ ros2 run mros2_echoback_float32 sub_node`
- `$ ros2 run mros2_sub_twist sub_node`
- mros2 application on the embedded device:
- [echoreply_float32](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/echoreply_float32)
- [pub_twist](https://github.com/mROS-base/mros2-asp3-f767zi/workspace/pub_twist)
43 changes: 0 additions & 43 deletions mros2_echoback_float32/src/pub_node.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions mros2_echoback_uint16/src/sub_node.cpp

This file was deleted.

53 changes: 53 additions & 0 deletions mros2_pub_pose/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.5)
project(mros2_pub_pose)


# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(pub_node src/pub_node.cpp)
ament_target_dependencies(pub_node rclcpp geometry_msgs)

target_include_directories(pub_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

install(TARGETS pub_node
DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
14 changes: 14 additions & 0 deletions mros2_pub_pose/launch/launch_pubsub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from launch import LaunchDescription
from launch_ros.actions import Node

# Note: `node_`, `prefix` and `output` will be removed on Foxy
def generate_launch_description():
return LaunchDescription([
Node(
package='mros2_pub_pose',
node_executable='pub_node',
node_name='pub_pose',
prefix=['stdbuf -o L'],
output="screen"
)
])
21 changes: 21 additions & 0 deletions mros2_pub_pose/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mros2_pub_pose</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="uden@todo.todo">uden</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>geometry_msgs</build_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
56 changes: 56 additions & 0 deletions mros2_pub_pose/src/pub_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <chrono>
#include <functional>
#include <memory>
#include <string>

#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/point.hpp"
#include "geometry_msgs/msg/quaternion.hpp"
#include "geometry_msgs/msg/pose.hpp"

using namespace std::chrono_literals;

/* This example creates a subclass of Node and uses std::bind() to register a
* member function as a callback from the timer. */

class Publisher : public rclcpp::Node
{
public:
Publisher()
: Node("pub_pose"), count_(0)
{
publisher_ = this->create_publisher<geometry_msgs::msg::Pose>("cmd_vel", 10);
timer_ = this->create_wall_timer(1000ms, std::bind(&Publisher::timer_callback, this));
}

private:
void timer_callback()
{
auto point = geometry_msgs::msg::Point();
auto quaternion = geometry_msgs::msg::Quaternion();
auto pose = geometry_msgs::msg::Pose();
point.x = count_/1.0;
point.y = count_/1.0;
point.z = count_/1.0;
quaternion.x = count_/1.0;
quaternion.y = count_/1.0;
quaternion.z = count_/1.0;
quaternion.w = count_/1.0;
pose.position = point;
pose.orientation = quaternion;
RCLCPP_INFO(this->get_logger(), "Publishing msg: { position: {x: %f, y: %f, z: %f }, orientation: {x: %f, y: %f, z: %f, w: %f } }" , pose.position.x, pose.position.y, pose.position.z, pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w );
publisher_->publish(pose);
count_++;
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<geometry_msgs::msg::Pose>::SharedPtr publisher_;
uint16_t count_;
};

int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<Publisher>());
rclcpp::shutdown();
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(mros2_echoback_uint16)
project(mros2_pub_uint16)


# Default to C99
Expand Down Expand Up @@ -27,21 +27,12 @@ find_package(std_msgs REQUIRED)
add_executable(pub_node src/pub_node.cpp)
ament_target_dependencies(pub_node rclcpp std_msgs)

add_executable(sub_node src/sub_node.cpp)
ament_target_dependencies(sub_node rclcpp std_msgs)

target_include_directories(pub_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_include_directories(sub_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

install(TARGETS pub_node
DESTINATION lib/${PROJECT_NAME})
install(TARGETS sub_node
DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY
launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,5 @@ def generate_launch_description():
name='pub_mros2',
prefix=['stdbuf -o L'],
output="screen"
),
Node(
package='mros2_echoback_uint16',
executable='sub_node',
name='mros2_sub',
prefix=['stdbuf -o L'],
output="screen"
)
])
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>mros2_echoback_uint16</name>
<name>mros2_pub_uint16</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="uden@todo.todo">uden</maintainer>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(mros2_echoback_float32)
project(mros2_sub_float32)


# Default to C99
Expand All @@ -24,22 +24,13 @@ find_package(std_msgs REQUIRED)
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(pub_node src/pub_node.cpp)
ament_target_dependencies(pub_node rclcpp std_msgs)

add_executable(sub_node src/sub_node.cpp)
ament_target_dependencies(sub_node rclcpp std_msgs)

target_include_directories(pub_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_include_directories(sub_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

install(TARGETS pub_node
DESTINATION lib/${PROJECT_NAME})

install(TARGETS sub_node
DESTINATION lib/${PROJECT_NAME})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,5 @@ def generate_launch_description():
name='pub_mros2',
prefix=['stdbuf -o L'],
output="screen"
),
Node(
package='mros2_echoback_float32',
executable='sub_node',
name='mros2_sub',
prefix=['stdbuf -o L'],
output="screen"
)
])
Loading

0 comments on commit b0750bf

Please sign in to comment.