Coder Social home page Coder Social logo

jodle001 / ros2_pyads Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 2.0 38 KB

This is a ros2 package that will be a wrapper around the pyads library to have communication between ros2 and beckhoff PLCs.

Python 96.11% CMake 3.89%
beckhoff beckhoff-twincat-plc pyads python python3 ros2 ros2-humble

ros2_pyads's Issues

Add a license to the packages and project

I think it would be great to have an explicit license declaration in the packages. Not only the fields have a TODO, but that also provides a clear indication on your plans for the project.

For reference:

Thanks for considering it!

ReadByteArray.srv is not built

Complete set(srv_files "srv/ReadBool.srv" "srv/WriteBool.srv" "srv/ReadString.srv" **"srv/ReadByteArray.srv"** ) in https://github.com/jodle001/ros2_pyads/blob/main/ros2_pyads_interfaces/CMakeLists.txt for successful generation of custom srv message

This function in ads_com "write_by_name" should return a boolean value.

Here is the function in question. which doesn't return any boolean value.

def write_by_name(self, var_name, var_value, var_type):
"""
Write a variable to the PLC by name.
:param var_name: The name of the variable to write (e.g., 'MAIN.testVar')
:param var_value: The value of the variable to write (e.g., 5)
:param var_type: The type of the variable to write (e.g., pyads.PLCTYPE_DWORD)
"""
with pyads.Connection(self.remote_ads, pyads.PORT_TC3PLC1, self.plc_ip) as plc:
plc.write_by_name(var_name, var_value, var_type)

Here is where it is returning false in every case:

success = self.ads_com.write_by_name(
var_name='MAIN.bTest',
var_value=not self.ads_com.read_by_name('MAIN.bTest', pyads.PLCTYPE_BOOL), # Toggle the existing value
var_type=pyads.PLCTYPE_BOOL)
if not success:
self.get_logger().error('Failed to write variable to PLC')

ADSCom' object has no attribute 'plc

I've tried to download ros2_pyads and to install it. Everything went smoothly, however when I try to launch

ros2 launch ros2_pyads ads_com_bool_test.launch.py

I get the following error:

[INFO] [launch]: All log files can be found below C:\Users\dinterra.ros\log\2024-06-12-19-03-33-196428-DIN-IRMA-LT01-25096
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ads_com_bool_test_node.EXE-1]: process started with pid [10948]
[ads_com_bool_test_node.EXE-1] Traceback (most recent call last):
[ads_com_bool_test_node.EXE-1] File "C:\dev\ros2_ws\install\lib\ros2_pyads\ads_com_bool_test_node-script.py", line 33, in
[ads_com_bool_test_node.EXE-1] sys.exit(load_entry_point('ros2-pyads==0.0.0', 'console_scripts', 'ads_com_bool_test_node')())
[ads_com_bool_test_node.EXE-1] File "C:\dev\ros2_ws\install\Lib\site-packages\ros2_pyads\ads_com_bool_test_node.py", line 53, in main
[ads_com_bool_test_node.EXE-1] ADSComBoolTestNode()
[ads_com_bool_test_node.EXE-1] File "C:\dev\ros2_ws\install\Lib\site-packages\ros2_pyads\ads_com_bool_test_node.py", line 44, in init
[ads_com_bool_test_node.EXE-1] var_value=not self.ads_com.read_by_name('MAIN.bTest', pyads.PLCTYPE_BOOL), # Toggle the existing value
[ads_com_bool_test_node.EXE-1] File "C:\dev\ros2_ws\install\Lib\site-packages\ros2_pyads\ads_com.py", line 68, in read_by_name
[ads_com_bool_test_node.EXE-1] raise e
[ads_com_bool_test_node.EXE-1] File "C:\dev\ros2_ws\install\Lib\site-packages\ros2_pyads\ads_com.py", line 64, in read_by_name
[ads_com_bool_test_node.EXE-1] var = self.plc.read_by_name(var_name, var_type)
[ads_com_bool_test_node.EXE-1] AttributeError: 'ADSCom' object has no attribute 'plc'
[ERROR] [ads_com_bool_test_node.EXE-1]: process has died [pid 10948, exit code 1, cmd 'C:\dev\ros2_ws\install\lib\ros2_pyads\ads_com_bool_test_node.EXE --ros-args --params-file C:\Users\dinterra\AppData\Local\Temp\launch_params_zazljcay --params-file C:\Users\dinterra\AppData\Local\Temp\launch_params_5wyx8mi_'].

The comconfig file was changed with these values:

'sender_ams': '192.168.12.253.1.1',
'plc_ip': '192.168.12.253',
'route_name': 'ROS2PLC',
'host_name': '192.168.12.253',
'remote_ads': '192.168.12.253.1.1'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.