You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Drew Bednar 3e43bfc16b Adding a neopixel light control node 3 years ago
launch services, messages, neopixel driver 3 years ago
msg services, messages, neopixel driver 3 years ago
scripts Adding a neopixel light control node 3 years ago
srv services, messages, neopixel driver 3 years ago
CMakeLists.txt services, messages, neopixel driver 3 years ago
README.md Adding new notes for messages and services 3 years ago
package.xml services, messages, neopixel driver 3 years ago

README.md

ROS Hello world

Start up

From the ~/workspace/ros directory

roscore

In a new terminal run the keyboard capture node

rosrun simple_example command_node.py

In a third window

rosrun simple_example drive_node.py

Nodes and Topics

rostopic bw     display bandwidth used by topic
rostopic echo   print messages to screen
rostopic hz     display publishing rate of topic    
rostopic list   print information about active topics
rostopic pub    publish data to topic
rostopic type   print topic type

In a fourth window you can see the active nodes:

ubuntu@rospi:~/catkin_ws$ rosnode list
/keyb_commander_1845_1645809765799
/motor_driver_1870_1645809783593
/rosout

You can look at the topics used in the deployment:

ubuntu@rospi:~/catkin_ws$ rostopic list -v

Published topics:
 * /rosout_agg [rosgraph_msgs/Log] 1 publisher
 * /command [std_msgs/String] 1 publisher
 * /rosout [rosgraph_msgs/Log] 2 publishers

Subscribed topics:
 * /rosout [rosgraph_msgs/Log] 1 subscriber
 * /command [std_msgs/String] 1 subscriber

We can see the publisher and subscriber of a topic and it's message type:

ubuntu@rospi:~/catkin_ws$ rostopic info /command
Type: std_msgs/String

Publishers:
 * /keyb_commander_1845_1645809765799 (http://rospi:35435/)

Subscribers:
 * /motor_driver_1870_1645809783593 (http://rospi:34943/)

We can see the topic type, which is this case is one that uses std_msgs/String

ubuntu@rospi:~/catkin_ws$ rostopic type /command
std_msgs/String

If we want to look at the definition of a message we can use rosmsg:

rosmsg show geometry_msgs/Twist

Slam together the rostopic type command with rosmsg show command to immediately get the message type info

rostopic type /command | rosmsg show

We can also publish a message to the /command topic like so rostopic pub [topic] [msg_type] [args]

rostopic pub /command std_msgs/String "left"

We can also echo out the messages received by the topic:

ubuntu@rospi:~/catkin_ws$ rostopic echo /command
data: "forward"
---
data: "back"
---
data: "left"
---
data: "right"
---
data: "back"
---
data: "forward"
---

If we want to look at descriptive stats of the rate of messages published to a topic we can use the hertz subcommand:

rostopic hz /command

Built messages will be located in

./devel/lib/python3/dist-packages/<package-name>/msg/_<message-name>.py at the root of your Catkin workspace

Parameters and Services

Services

From [Understanding ROS Parameters and Services] Services are synchronous (blocking) RPC servers essentially

rosservice list         print information about active services
rosservice call         call the service with the provided args
rosservice type         print service type
rosservice find         find services by service type
rosservice uri          print service ROSRPC uri
ubuntu@rospi:~/catkin_ws$ rosservice list
/keyb_commander_1845_1645809765799/get_loggers
/keyb_commander_1845_1645809765799/set_logger_level
/motor_driver_1870_1645809783593/get_loggers
/motor_driver_1870_1645809783593/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level

In this package we have no services available beyond the basic logging facilities.

We cab get the type of service messages that they expect much like the rostopics.

rosservice type /keyb_commander_1845_1645809765799/get_loggers
roscpp/GetLoggers

If we have std_srvs/Empty as a message type like in /turtlesim we would call that service with no arguments using the rosservice call /clear command. Other services might look like this:

toor@ubuntu:~/workspace/ros/src$ rosservice type /spawn | rossrv show
float32 x
float32 y
float32 theta
string name
---
string name
toor@ubuntu:~/workspace/ros/src$ rosservice call /spawn 2 2 0.2 ""
name: "turtle2"

Spawns a second turtle

Built service definitions will be located in

./devel/lib/python3/dist-packages/<package-name>/srv/_<service-name>.py at the root of your Catkin workspace

Parameters

ROS provides a parameter server that you read and write values to.

rosparam set            set parameter
rosparam get            get parameter
rosparam load           load parameters from file
rosparam dump           dump parameters to file
rosparam delete         delete parameter
rosparam list           list parameter names

Let's just look at all the parameters.

toor@ubuntu:~/workspace/ros/src$ rosparam get /
rosdistro: 'noetic

  '
roslaunch:
  uris:
    host_ubuntu__38527: http://ubuntu:38527/
rosversion: '1.15.14

  '
run_id: a50b0b18-9666-11ec-b706-21c9002ce246
turtlesim:
  background_b: 255
  background_g: 86
  background_r: 150

Ros Utility Programs

rqt_plot displays a scrolling time plot of the data published on topics. It's a GUI that only works on ros-desktop.

rosrun rqt_plot rqt_plot

[Understanding ROS Parameters and Services](https://wiki.ros.org/ROS/Tutorials/UnderstandingServicesParams