forked from shehzi001/ros_foundation_course
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added examples of using std ros message in python
- Loading branch information
Showing
9 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
fc_ros_tutorials/demo_ros_messages/ros_python_std_messages_examples/CMakeLists.txt
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,16 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(ros_python_std_messages_examples) | ||
|
||
find_package(catkin REQUIRED COMPONENTS | ||
rospy | ||
std_msgs | ||
) | ||
|
||
catkin_python_setup() | ||
|
||
catkin_package( | ||
CATKIN_DEPENDS | ||
rospy | ||
std_msgs | ||
|
||
) |
16 changes: 16 additions & 0 deletions
16
fc_ros_tutorials/demo_ros_messages/ros_python_std_messages_examples/package.xml
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,16 @@ | ||
<?xml version="1.0"?> | ||
<package> | ||
<name>ros_python_std_messages_examples</name> | ||
<version>0.1.0</version> | ||
<description>The ros_python_std_messages_examples package</description> | ||
|
||
<maintainer email="[email protected]">shehzad Ahmed</maintainer> | ||
|
||
<license>GPLv3</license> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
<build_depend>rospy</build_depend> | ||
<build_depend>std_msgs</build_depend> | ||
<run_depend>rospy</run_depend> | ||
<run_depend>std_msgs</run_depend> | ||
</package> |
12 changes: 12 additions & 0 deletions
12
...demo_ros_messages/ros_python_std_messages_examples/ros/scripts/std_messages_examples_node
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,12 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This script is a simple python node which imports | ||
source code of std_messages_examples. | ||
""" | ||
#-*- encoding: utf-8 -*- | ||
__author__ = 'shehzad ahmed' | ||
|
||
import ros_python_std_messages_examples_ros.std_messages_examples | ||
|
||
if __name__ == '__main__': | ||
ros_python_std_messages_examples_ros.std_messages_examples.main() |
Empty file.
42 changes: 42 additions & 0 deletions
42
...s_python_std_messages_examples/ros/src/ros_python_std_messages_examples_ros/demo_class.py
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,42 @@ | ||
#!/usr/bin/env python | ||
''' | ||
This script demostrates the way of filling | ||
ros std_msgs by giving few examples. | ||
''' | ||
import rospy | ||
from std_msgs.msg import Bool | ||
from std_msgs.msg import Float32 | ||
from std_msgs.msg import Int32 | ||
from std_msgs.msg import String | ||
|
||
|
||
class DemoClass(): | ||
def __init__(self): | ||
self.prepare_std_msg() | ||
|
||
def prepare_std_msg(self): | ||
rospy.loginfo("Preparing std_msgs......") | ||
''' | ||
Fill Bool message | ||
''' | ||
bool_msg = Bool() | ||
|
||
bool_msg.data = False | ||
|
||
''' | ||
Fill Float32 message | ||
''' | ||
float32_msg = Float32() | ||
|
||
float32_msg.data = 1.0 | ||
|
||
''' | ||
Fill Int32 message | ||
Please, do it your self for practice | ||
''' | ||
|
||
''' | ||
Fill String message | ||
Please, do it your self for practice | ||
''' | ||
rospy.loginfo("std_msgs preparation done......") |
Binary file added
BIN
+1.8 KB
..._python_std_messages_examples/ros/src/ros_python_std_messages_examples_ros/demo_class.pyc
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
...d_messages_examples/ros/src/ros_python_std_messages_examples_ros/std_messages_examples.py
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,22 @@ | ||
#!/usr/bin/env python | ||
""" | ||
This script demostrates the way of filling | ||
ros std_msgs by giving few examples. | ||
""" | ||
#-*- encoding: utf-8 -*- | ||
__author__ = 'shehzad ahmed' | ||
import rospy | ||
from demo_class import * | ||
|
||
def initlize_node(): | ||
''' | ||
Initilize node and spin which simply keeps python | ||
from exiting until this node is stopped | ||
''' | ||
rospy.init_node('std_messages_examples_node', anonymous=False) | ||
rospy.loginfo("std_messages_examples_node is now running") | ||
demo_class1 = DemoClass() | ||
rospy.spin() | ||
|
||
def main(): | ||
initlize_node() |
Binary file added
BIN
+1.48 KB
..._messages_examples/ros/src/ros_python_std_messages_examples_ros/std_messages_examples.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions
11
fc_ros_tutorials/demo_ros_messages/ros_python_std_messages_examples/setup.py
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,11 @@ | ||
#!/usr/bin/env python | ||
|
||
from distutils.core import setup | ||
from catkin_pkg.python_setup import generate_distutils_setup | ||
|
||
d = generate_distutils_setup( | ||
packages=['ros_python_std_messages_examples_ros'], | ||
package_dir={'ros_python_std_messages_examples_ros': 'ros/src'} | ||
) | ||
|
||
setup(**d) |