Difference between revisions of "ROS 2 Suite node sample"

From ESS-WIKI
Jump to: navigation, search
(update)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Introduction ==
 
  
=== c++ sample ===
+
== c++ sample ==
  
 
Run example for subscribe, you can open a terminal to executing command:
 
Run example for subscribe, you can open a terminal to executing command:
 +
<pre>ros2 run demo_nodes_cpp listener
 +
</pre>
  
<pre>
+
Open a new terminal to executing command to publish:
ros2 run demo_nodes_cpp listener
+
<pre>ros2 run demo_nodes_cpp talker
 
</pre>
 
</pre>
  
Open a new terminal to executing command to publish:
+
[[File:Ros2 suite node sample cpp.png|800x480px|Ros2 suite node sample cpp.png]]
 +
 
 +
&nbsp;
 +
 
 +
== rclnodejs sample ==
  
<pre>
+
Run example for subscribe, you can open a terminal to executing command:
ros2 run demo_nodes_cpp talker
+
<pre>cd /usr/local/Advantech/ros/foxy/sample_code/rclnodejs_sample
 +
node sub.js
 
</pre>
 
</pre>
  
 +
Open a new terminal to executing command to publish:
 +
<pre>cd /usr/local/Advantech/ros/foxy/sample_code/rclnodejs_sample
 +
node pub.js
 +
</pre>
  
 +
&nbsp;
  
 
+
== rclpy sample ==
=== rclnodejs sample ===
 
  
 
Run example for subscribe, you can open a terminal to executing command:
 
Run example for subscribe, you can open a terminal to executing command:
 +
<pre>cd /usr/local/Advantech/ros/foxy/sample_code/rclpy_sample
 +
python3 subscriber.py
 +
</pre>
  
<pre>
+
Open a new terminal to executing command to publish:
cd /usr/local/Advantech/ros/foxy/sample_code/rclnodejs_sample
+
<pre>cd /usr/local/Advantech/ros/foxy/sample_code/rclpy_sample
node sub.js
+
python3 publish.py
 
</pre>
 
</pre>
  
Open a new terminal to executing command to publish:
+
== turtlesim ==
  
<pre>
+
Open a terminal to start turtlesim by executing command:
cd /usr/local/Advantech/ros/foxy/sample_code/rclnodejs_sample
+
<pre>ros2 run turtlesim turtlesim_node
node pub.js
 
 
</pre>
 
</pre>
  
 +
The simulator window should appear, with a random turtle in the center.
 +
 +
[[File:Ros2 suite turtlesim node.png|RTENOTITLE]]
 +
 +
Open a new terminal, run a new node to control the turtle in the first node by executing command:
 +
<pre>ros2 run turtlesim turtle_teleop_key
 +
</pre>
  
=== rclpy sample ===
+
Use the arrow keys on your keyboard to control the turtle. It will move around the screen, using its attached “pen” to draw the path it followed so far.
  
ttt
+
[[File:Ros2 suite turtlesim teleop key.png]]

Latest revision as of 04:28, 25 April 2025

c++ sample

Run example for subscribe, you can open a terminal to executing command:

ros2 run demo_nodes_cpp listener

Open a new terminal to executing command to publish:

ros2 run demo_nodes_cpp talker

Ros2 suite node sample cpp.png

 

rclnodejs sample

Run example for subscribe, you can open a terminal to executing command:

cd /usr/local/Advantech/ros/foxy/sample_code/rclnodejs_sample
node sub.js

Open a new terminal to executing command to publish:

cd /usr/local/Advantech/ros/foxy/sample_code/rclnodejs_sample
node pub.js

 

rclpy sample

Run example for subscribe, you can open a terminal to executing command:

cd /usr/local/Advantech/ros/foxy/sample_code/rclpy_sample
python3 subscriber.py

Open a new terminal to executing command to publish:

cd /usr/local/Advantech/ros/foxy/sample_code/rclpy_sample
python3 publish.py

turtlesim

Open a terminal to start turtlesim by executing command:

ros2 run turtlesim turtlesim_node

The simulator window should appear, with a random turtle in the center.

RTENOTITLE

Open a new terminal, run a new node to control the turtle in the first node by executing command:

ros2 run turtlesim turtle_teleop_key

Use the arrow keys on your keyboard to control the turtle. It will move around the screen, using its attached “pen” to draw the path it followed so far.

Ros2 suite turtlesim teleop key.png