Comments (9)
Besides, I have another question.
If I use python script in ROS1. I don't need to compile by catkin_make. The script will work correctly as ROS node.
But in ROS2. The script not compile by colcon build(contrast catkin_make). It will execute but cannot communication with another ros2 node. Unless you build it then using ros2 run xxx
the python script would work correctly. I suspect because ROS2 used DDS.
And I think RAFCON project is not compiled with ROS2.
Oh sorry, it may be the same problem. How to use RAFCON for ROS2?
from rafcon.
Hi @lx852357,
I don't have any experience with ROS2, nevertheless I might be able to answer some of your questions.
The code you copied here uses Python 3 syntax (super().__init__('minimal_subscriber')
, super
with no arguments), this is why you need to run RAFCON with a Python 3 interpreter.
And I think RAFCON project is not compiled with ROS2.
RAFCON is written in Python (supports both 2 and 3) and is thus interpreted (not compiled).
How to use RAFCON for ROS2?
As I said, I don't know much about ROS2. One requirement (according to a quick Google search) is that ROS2 only supports Python 3, thus you need to run RAFCON with a Python 3 interpreter and write Python 3 compatible code. Running RAFCON with Python 3 requires you to install it with pip3!
I hope that helps!
from rafcon.
Thank you @franzlst ,
Yes, It is interpreter nor compiler.
I think ROS2 node may only using ros2 run XX
this way will work correctly, otherwise the communication will not work.
So, I wanna know that can RACFON state machine project be part of my ROS2 project? And It's up to me to decide when to trigger the state machine process in my Python code.
from rafcon.
I think ROS2 node may only using ros2 run XX this way will work correctly, otherwise the communication will not work.
In ROS2 environment, executing the Python script directly it could work. It's my problem of environment.
Would you mind closing this issue later? There may be other problems in the future. It won't be long. I will close this question in this week.
Thank you @franzlst .
from rafcon.
Exciting! The RAFCON has successfully run ROS2 listener.
But I still don't understand some details.
-
If I defined a global variable which is not saved in GVM. While the process has enter next state, can I still call the global varible?
-
Are local variable of previous state immediately destroyed after entering the next state.(Not concurrency state)
-
I have some custom message struct. How do I pass it to the next state? If not used GVM.
I used state machine to manage my process. But the data is global.
I want to see the data flow clearly.
from rafcon.
Exciting! The RAFCON has successfully run ROS2 listener.
Cool! Can you give some information, how you managed to do so now? Are there any special things others should be aware of? It would be great if you could share your experience!
Regarding the GVM questions: Please open a new issue and post them there!
from rafcon.
@franzlst I think he is doing simple global var. And you are right to request a new issue. But maybe a short hint to our tutorials will help.
@lx852357 Using global statements is a very implicit way of holding permanent objects. Therefore RAFCON offers the GVM to do this transparent and secure (e.g. with locks). An example for a clean ros node creation (with permanent tf-listener) you can find here. Please look also into our ROS turtle tutorials and there implementation to avoid redoing your work too often. Consider also our FAQ or other guides on readthedocs in case you have not read them already.
from rafcon.
Thank you!
I try @Rbelder opinion firstly. If I still have new questions I will open a new issue.
Some information about use RAFCON for ROS2:
-
pip3 install rafcon --user
-
Because ROS2 natively supports distributed. So you can subscribe or publish directly. For example,
Code in the test state:
import rclpy
import sys
from rclpy.node import Node
from std_msgs.msg import String
class MinimalSubscriber(Node):
def __init__(self):
super().__init__('minimal_subscriber')
self.subscription = self.create_subscription(
String,
'topic',
self.listener_callback,
10)
self.subscription # prevent unused variable warning
def listener_callback(self, msg):
self.get_logger().info('I heard: "%s"' % msg.data)
def execute(self, inputs, outputs, gvm):
rclpy.init(args=None) # Here may report an error.
minimal_subscriber = MinimalSubscriber()
minimal_subscriber.get_logger().info('execute')
rclpy.spin(minimal_subscriber)
minimal_subscriber.destroy_node()
rclpy.shutdown()
- An error may reported when running the state machine.
RuntimeError: Failed to init: rcl_init called on an already initialized context
This problem occurs because of this subscriber may not end. Using ros2 node list
to check if the subscribe still alive. When this problem occurred I have to shutdown RAFCON.
- When running a publisher the ros logger will display on your terminal instead of RAFCON.
By the way, I don't know if the subscriber will end after stop a state machine.
from rafcon.
Thank you for the information!
This problem occurs because of this subscriber may not end
I could imagine that this occurs when the state raises an exception for some reason and the execute
function does not run to the end. Try this:
try:
rcpl.init()
# more code
finally:
rclpy.shutdown()
By the way, I don't know if the subscriber will end after stop a state machine.
I don't know about ROS2, but I would imagine that minimal_subscriber.destroy_node()
causes the subscriber to stop. This the subscribr would already end when the state finishes.
from rafcon.
Related Issues (20)
- readTheDocs "PyCharm Coding Style/Conventions"
- symlinking a folder into a library doesn't seem to work HOT 1
- Question: How do I load a state machine non-interactively? HOT 2
- History states in RAFCON HOT 8
- No warning or error log message when passing "None" to an input port
- set libsass version properly HOT 1
- RAFCON Crashes abruptly..... HOT 11
- Missing 'Default value' columns in editor HOT 4
- RAFCON crashes if the NOTIFICATIONS_MINIMUM_LOG_LEVEL is set to 10
- installation error HOT 7
- Error when trying BasicTurtleDemo HOT 2
- Online translations using a web browser HOT 4
- error message when locking gvm variable in ROS subcriber callback function HOT 3
- Minor changes in the default values for keyboard shortcuts HOT 1
- Error when launching rafcon HOT 2
- Relative path to other python file in rafcon project HOT 4
- Failed to install on Ubuntu 20.04/python3/venv HOT 2
- Error import external library (ROS2) HOT 2
- Import error upon startup ('Iterable' from 'collections' - deprecated class) HOT 1
- How do I cite you? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rafcon.