> ## Content Index
> Fetch the complete content index at: https://www.oransblog.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Learning ROS notes from theconstructsim.com
- URL: https://www.oransblog.com/learning-ros-notes-from/
- Published: 2021-02-19T05:05:39.000Z
- Updated: 2026-10-29T05:58:50.000Z
- Author: Oran C
- Tags: #Import 2026-11-12 01:14

---

Ros tutorial  
[https://app.theconstructsim.com/#/Desktop](https://app.theconstructsim.com/?ref=oransblog.com#/Desktop)

Topics:  
communication to compnents of

services and actions

# tutorial 1

```bash

# basic demoroslaunch publisher_example move.launch
roslaunch publisher_example stop.launch

# services
roslaunch service_demo service_launch.launch
rosservice call /service_demo "{}"
```

the subscribers run last message that it recieved

## services

##### Defintion:

### basic demoroslaunch publisher\_example move.launch

roslaunch publisher\_example stop.launch

# services

### requices the node to finish its process

# actions

### live feedback retuine

```bash
roslaunch service_demo service_launch.launch
rosservice call /service_demo "{}"
roslaunch action_demo action_launch.launch
roslaunch action_demo_client client_launch.launch
rosrun rviz rviz

```

```bash
cd ~/catkin_ws/src
catkin_create_pkg my_examples_pkg rospy std_msgs
cd ~/catkin_ws
catkin_make
source devel/setup.bash
rospack profile
roscd my_examples_pkg
mkdir scripts

roscd my_examples_pkg/scripts
touch NAME_OF_EXAMPLE_SCRIPT.py
chmod +x NAME_OF_EXAMPLE_SCRIPT.py

roscd my_examples_pkg/scripts
python NAME_OF_EXAMPLE_SCRIPT.py
# OR
rosrun my_examples_pkg NAME_OF_EXAMPLE_SCRIPT.py

roscd my_examples_pkg/scripts
touch simple_topic_publisher.py
chmod +x simple_topic_publisher.py

```

## file `simple_topic_publisher.py`

```python
#! /usr/bin/env python

import rospy
from std_msgs.msg import Int32 

rospy.init_node('topic_publisher')
pub = rospy.Publisher('/counter', Int32, queue_size=1)
rate = rospy.Rate(2)
count = Int32()
count.data = 0

while not rospy.is_shutdown(): 
  pub.publish(count)
  count.data += 1
  rate.sleep()

```

### run shell 1

```bash
rosrun my_examples_pkg simple_topic_publisher.py

```

### run shell 2

```bash
rostopic list | grep  '/counter'

```

# how to see data publishing on ros

```bash
rostopic info /counter

```

### result

```bash
user:~$ rostopic info /counter
Type: std_msgs/Int32

Publishers:
 * /topic_publisher (http://5_xterm:42533/)

Subscribers: None

```

### how view the data

```bash
rostopic echo /counter

```

---

```bash
data: 546
---
data: 547
---
data: 548
---

```

# what's a topic?

### `A topic is a channel that acts as a pipe, where other ROS nodes can either publish or read information`

### list ros topics

```bash
rostopic list

rostopic echo <topic_name>
rostopic echo <topic_name> -n1
rostopic echo /counter
rostopic echo /counter -n1

rostopic info /counter
rostopic -h

```

##### 20210219

## Messages

```bash
rosmsg show <message>
rosmsg show std_msgs/Int32

```

#### resulst

```bash
user:~/catkin_ws/src/my_examples_pkg$ rosmsg show std_msgs/Int32
int32 data

```

### 'data' is a variable defined in simple\_topic\_publisher.py

```bash
count = Int32()
count.data = 0

```

### looking at Int32.msg

```bash
roscd std_msgs/msg/

```

```bash
rostopic info /cmd_vel 
rosmsg show

```

### solving the challenge

```bash
cd ~/catkin_ws/src/
catkin_create_pkg exercise_31 rospy std_msgs geometry_msgs
cd ~/catkin_ws
catkin_make
source devel/setup.bash
rospack profile
roscd exercise_31
mkdir scripts
touch ./scripts/move_robot.py

```

```python
#! /usr/bin/env python

import rospy
from geometry_msgs.msg import Twist

rospy.init_node('move_robot_node')
pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
rate = rospy.Rate(2)
move = Twist()
move.linear.x = 0.5 #Move the robot with a linear velocity in the x axis
move.angular.z = 0.5 #Move the with an angular velocity in the z axis

while not rospy.is_shutdown(): 
  pub.publish(move)
  rate.sleep()

```

#### link how ros launch files work [roslaunch - ROS Wiki](http://wiki.ros.org/roslaunch?ref=oransblog.com#Video%5FTutorial%5Fon%5FLaunch%5FFiles)

```bash
roscd exersize_31
# created a file called /catkin_ws/src/exersize_31/launch/move_robot.launch
touch ./launch/move_robot.launch
chmod +x ./launch/move_robot.launch

```

### add text

```xml
<launch>
    <node pkg="exercise_31" type="move_robot.py" name="move_robot_node" output="screen" />
</launch>

```

```bash
chmod +x ./scripts/move_robot.py
roslaunch exercise_31 move_robot.py

roslaunch exercise_31 move_robot.launch

```

# Subscribers

### reads data from a publisher (similar to a client)

```bash

cd ~/catkin_ws/src
catkin_create_pkg my_examples_pkg rospy std_msgs
cd ~/catkin_ws
catkin_make
source devel/setup.bash
rospack profile
roscd my_examples_pkg
mkdir scripts

roscd my_examples_pkg/scripts
touch NAME_OF_EXAMPLE_SCRIPT.py
chmod +x NAME_OF_EXAMPLE_SCRIPT.py

roscd my_examples_pkg/scripts
python NAME_OF_EXAMPLE_SCRIPT.py
# OR
rosrun my_examples_pkg NAME_OF_EXAMPLE_SCRIPT.py

roscd my_examples_pkg/scripts
touch simple_topic_subscriber.py
chmod +x simple_topic_subscriber.py

```

### simple\_topic\_subscriber.py

```bash

#! /usr/bin/env python

import rospy
from std_msgs.msg import Int32 

def callback(msg): 
  print (msg.data)

rospy.init_node('topic_subscriber')
sub = rospy.Subscriber('/counter', Int32, callback)
rospy.spin()

```

```bash
rosrun my_examples_pkg simple_topic_subscriber.py
rostopic echo /counter

OUTPUT:
----------
user ~ $ rostopic echo /counter
WARNING: no messages received and simulated time is active.
Is /clock being published?
---------

```

### how to publish test data to topic

```bash
rostopic pub <topic_name> <message_type> <value>
rostopic pub /counter std_msgs/Int32 5

OUTPUT
----
user ~ $ rostopic echo /counter
WARNING: no messages received and simulated time is active.
Is /clock being published?
data:
5
---
----

```

```bash
#! /usr/bin/env python

import rospy                                          
from std_msgs.msg import Int32 

def callback(msg):   # Define a function called 'callback' that receives a parameter 
                     # named 'msg'
    print (msg.data) # Print the value 'data' inside the 'msg' parameter
rospy.init_node('topic_subscriber')  # Initiate a Node called 'topic_subscriber'

# Create a Subscriber object that will listen to the /counter
# topic and will cal the 'callback' function each time it reads

sub = rospy.Subscriber('/counter', Int32, callback)

# something from the topic
rospy.spin()   

```

# Challenge 2

```bash

rostopic info /odom
OUTPUT:
--------------------------
Type: nav_msgs/Odometry

Publishers:
 * /gazebo (http://15_simulation:35255/)

Subscribers: None
--------------------------

```

### find more about nav\_msgs/Odometry

```bash
roscd nav_msgs

```

![](blob:https://www.oransblog.com/0faeac38-a48b-46d9-afb5-2a9baf33fd06)

![](blob:https://www.oransblog.com/9e355049-92b3-4340-993a-a0b8a7aa719f)

# Debugging tools

### Questions:

- what does "{}" mean
- what does it mean to 'call' a sevice
- what does http://5\_xterm:37773/ mean
- what is a ros master?
- how is it used?
- what are paramaters?
- what is queue\_size=1
- how does the datatypes work in ros
- what does rospy.spin() do?

![](https://www.oransblog.com/content/images/2021/02/image-43.png)

![](https://www.oransblog.com/content/images/2021/02/image-44.png)

![](https://www.oransblog.com/content/images/2021/02/image-45.png)

![](https://www.oransblog.com/content/images/2021/02/image-46.png)

![](https://www.oransblog.com/content/images/2021/02/image-47.png)

# Sucess!

![](https://www.oransblog.com/content/images/2021/02/image-48.png)

### Results!

```python
#! /usr/bin/env python

import rospy
from std_msgs.msg import Int32 
from nav_msgs.msg import Odometry
def callback(msg): 
  print (msg.header)
  print (msg.child_frame_id)
  print (msg.pose)
  print (msg.twist)

rospy.init_node('topic_subscriber')
sub = rospy.Subscriber('/odom', Odometry, callback)
rospy.spin()

```

roscd <package\_name>  
mkdir msg

The "Age.msg" file must contain this:

---

float32 years  
float32 months  
float32 days

---

# how to install ros serial to communicate with arduino

[rosserial\_arduino/Tutorials/Arduino IDE Setup - ROS Wiki](http://wiki.ros.org/rosserial%5Farduino/Tutorials/Arduino%20IDE%20Setup?ref=oransblog.com#Installing%5Fthe%5FSoftware)

```bash
sudo apt-get install ros-noetic-rosserial-arduino
sudo apt-get install ros-noetic-rosserial

```

![](https://www.oransblog.com/content/images/2021/02/image-49.png)

![](https://www.oransblog.com/content/images/2021/02/image-50.png)

```bash
cd ~/catkin_ws/src
git clone https://github.com/ros-drivers/rosserial.git
cd ~/catkin_ws
catkin_make
catkin_make install

```

### Errors with install

![](https://www.oransblog.com/content/images/2021/02/image-51.png)

# Trying `catkin_make_isolated`

that didnt work...

this issue was someone's elses package was installed that was broaken

# Fix: move the problem package out and run 'catkin\_make\`

### Sucess!

![](https://www.oransblog.com/content/images/2021/02/image-52.png)

# install arduino ide

[Program an Arduino UNO with your Raspberry Pi — The MagPi magazine](https://magpi.raspberrypi.org/articles/program-arduino-uno-raspberry-pi?ref=oransblog.com)

```bash
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install arduino

```

![](https://www.oransblog.com/content/images/2021/02/image-53.png)

Skechbook folder location

```bash
cd ~/sketchbook/libraries
rm -rf ros_lib
rosrun rosserial_arduino make_libraries.py .

```

# Windows note:

If you are building the Arduino on Windows, you need to create the ros\_lib folder in some convenient directory.

```bash
cd <some_empty_directory>
rosrun rosserial_arduino make_libraries.py .

```

# Issue i ran into

![](https://www.oransblog.com/content/images/2021/02/image-54.png)

links

[usb\_cam - ROS Wiki](http://wiki.ros.org/usb%5Fcam?ref=oransblog.com)

[fatal error: serial/serial.h: no such file or directory in ros - ROS Answers: Open Source Q&A Forum](https://answers.ros.org/question/328107/fatal-error-serialserialh-no-such-file-or-directory-in-ros/?ref=oransblog.com)

[robotarmhackathon/launch at main · agillies8/robotarmhackathon](https://github.com/agillies8/robotarmhackathon/tree/main/launch?ref=oransblog.com)

[agillies8/robotarmhackathon: Code for the robot arm hackathon](https://github.com/agillies8/robotarmhackathon?ref=oransblog.com)

[ros-drivers/rosserial: A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial](https://github.com/ros-drivers/rosserial?ref=oransblog.com)

[rosserial\_arduino - ROS Wiki](http://wiki.ros.org/rosserial%5Farduino?ref=oransblog.com)

[3AxisArm/Single\_BUTTON\_TEST.ino at master · agillies8/3AxisArm](https://github.com/agillies8/3AxisArm/blob/master/Arduino/Single%5FBUTTON%5FTEST/Single%5FBUTTON%5FTEST.ino?ref=oransblog.com)

exaplse simple

[3AxisArm/buttonPlex.py at master · agillies8/3AxisArm](https://github.com/agillies8/3AxisArm/blob/master/buttonPlex.py?ref=oransblog.com)

[3AxisArm/TWO\_BUTTON\_TEST.ino at master · agillies8/3AxisArm](https://github.com/agillies8/3AxisArm/blob/master/Arduino/TWO%5FBUTTON%5FTEST/TWO%5FBUTTON%5FTEST.ino?ref=oransblog.com)

simple keyboard input

[teleop\_twist\_keyboard - ROS Wiki](http://wiki.ros.org/teleop%5Ftwist%5Fkeyboard?ref=oransblog.com)

Al considerar [camisetas de fútbol con ajuste holgado](https://www.camisetatienda.com/?ref=oransblog.com), la decisión resulta más sencilla cuando se confirma la diferencia entre ajuste entallado, regular y holgado. El pedido puede cerrarse después de confirmar la tolerancia indicada para cada talla.