Skip to content

Latest commit

 

History

History
executable file
·
272 lines (244 loc) · 8.87 KB

.NOTES.md

File metadata and controls

executable file
·
272 lines (244 loc) · 8.87 KB

Limitations

  • Multidimensional arrays are not supported

  • Must use ROS_PRG configuration with all the variables inside

  • Must not change the node name as the update script searches for a '.../robin' node

  • Must have bash (devel/setup.bash)

  • Must restart codesyscontrol service

  • Each robin object can only be used in one POU

  • Strings and arrays with fixed size only (STRING defaults to 80 in CODESYS)

Usage

  • Example CODESYS program
    PROGRAM ROS_PRG
    VAR_INPUT
      double_to_ros : LREAL;
    END_VAR
    VAR
      robin: Robin;
    END_VAR
    robin();
    robin.write('double_var', double_to_ros);
    

Data types map

CODESYS C++ ROS ROS msg
ROS_BYTE uint8_t byte std_msgs::Byte
INT int16_t int16 std_msgs::Int16
ARRAY[min..max] OF * *[max - min + 1] *[max - min + 1] std_msgs::*MultiArray

TODO

  • WIP

    • finish installation/usage
      • fix catkin_make errors
  • fix plink auto accept server fingerprint

  • write dev warnings

    • possibility of cpp/codesys struct alignment differences?
  • detalhar TODOs

  • grammarly README

  • static code analysis

  • review ros byte type; rostopic error when passing values > 125

  • start_update.py: start softplc if stopped?

  • support '{attribute 'suffixed'}' for structs and struct members

  • fix CMakeLists.txt update: comment 'add_message_files' if no messages to be generated

  • merge with master

Later

  • README.md softPLC version must match version in example project
  • fix catkin_make problem: move custom messages to separate robin_msgs package (robin_bridge, robin_updater)
  • add remaining ros msg packages to codesys project and types.yml
  • review README installation and usage steps
  • european commission funding pics
  • upload to ROSIN remote
  • add remaining msg packages
  • get Robin.DEF_ARRAY_LEN from xml
  • support variables from different POUs or from GVLs
    • check xml for external variable
    • handle name collisions
    • consider namespaces
  • document classes, methods, etc. (eg. @param, @return, etc.)
    • cpp
    • codesys
  • unit tests
    • shm_test read/write list of values
  • integration tests
  • compare performance with old version
  • optimize performance
    • reduce isOpen checks if performance worse than old version
    • reduce ifs, loops
    • time tests
    • ? replace std::string with char*
    • pass by ref or val?
    • is read thread faster than old way? (specially in beagle; can it handle it?)
  • TEST TEST TEST
    • test all types
    • check all combinations (no msgs, ros msgs, custom msgs, X both ros and custom msgs)
    • test in robots
  • jinja2
  • print warning when string/array is larger than shm
  • updater: support multidimensional arrays
  • vlarrays: pass array length and read only length elements
    • quick performance estimation?
    • implement
    • compare performance
  • create install script / cmakelists
  • variable.py: store arrays' base_var in self.base_var instead of self.members[0]
  • robin_inst.cpp: compare performance between individual struct member assignment and memcpy, for pod structs
  • make updater.py executable from any directory
  • robin_inst.cpp: whole struct assignment instead of member by member for pod variables
  • review isOpen logic
  • review shm_ptr_ need: can declare shm_ptr_ at start of specialization; performance issues?
  • different error codes
  • support include Robin from other package
  • restart codesys if ros node dies
  • update.py: update source files only if changed (eg create tmp file; if different: rename; else: delete tmp)
  • prettify robin_insts.cpp: create intermediate constant variables to avoid long namespaces
  • check robin name is valid (no invalid characters)
  • prepend shm names with 'robin_' to avoid name collisions with other programs
    • even better, use a single shm space
  • types.yml: codesys->iec/base, ros->ros_msg_pkgs/msgs_pkgs/msgs
  • gen_demo_project.py codesys demo project generator
  • support multiple nodes named robin in different namespaces
  • include robin.h only (contains robin_publisher, robin_subscriber, etc.)
  • scan network before updating
    • get project children (device), get gateway, get targets, sel target, set comm path
    • OR get gateways, sel gateway, get targets, sel targets, set comm path
  • start_update.py: export specified project instead of primary
    • if no arg and no primary, error
  • option to publish on change only (eg '{attrib...')
  • option to zero values if not updated after some time
  • option to zero or keep unsent values in variable length arrays
  • option to choose publishing/reading rates
  • support robin objects defined in other POUs or from GVLs
  • update.py: check if source updates were successful
  • update README.md variable mapping table from types.yml
  • reduce .git size
  • delete read_thread when closing or use std/boost::unique_ptr/shared_ptr
  • support ros services
  • support ros actions

Maybe

  • extend msg objects to point to shm directly
  • simplify robin_inst.cpp: eg function to simplify array/vector copy
  • rename "types_map['codesys']" to "types_map['iec']"
  • gen some src in Robin class?
  • CODESYS attributes equal to boolean value
  • 'types_map' and 'types.yaml' to 'typesmap(.yml)'
  • use std_msgs MultiArray instead of custom VarLen?
    • compare performance
    • what else?
  • add cpp/ros_decl (type+name+arrlen)
  • change Variable.parent to .parent_var
  • change Variable __eq__ to compare 'self.name' as well
  • encapsulate everything in class(es): RobinUpdateStarter, RobinUpdater
  • detect shell used to compile
  • start_update.py: config.yml for ssh settings
  • ros side as service as well
  • single shm space
  • change header files to .hpp extension
  • change inst.cpp to impl.cpp
  • use c++ macros to automate struct member assignments based on structs.h
  • group RobinPublishers with same rate into single threads
  • pass DEF_ARRAY_SIZE to robin fb
  • update.py: print 'Updating...' and pause inside

Code

robin_node.cpp

  // enable rosconsole logging
  if (ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug))
  {
   ros::console::notifyLoggerLevelsChanged();
  }

structs.h

// define structure padding; can reduce performance
struct alignas(8) S {};

python

    # sphinx style function docstrings
        """One-line description

        :param param1: Param1 description
        :type param1: param1_type
        :param param2: Param2 description
        :type param2: param2_type
        :raises Error1: Error1 description
        :raises Error2: Error2 description
        :return: Return description
        :rtype: return_type

        """

start_update.py

# scan network
gw = online.gateways['Gateway-1']
gw.perform_network_scan()
try:
    online.gateways['Gateway-1'].perform_network_scan()
except:
    system.ui.error('Update failed.')
    raise SystemExit
devices = projects.primary.find('Device', recursive=False)
if devices is None or len(devices) != 1:
    system.ui.error('Failed to find device.')
    raise SystemExit
guid = devices[0].get_gateway()
online.gateways[guid].perform_network_scan()

update.py

# add codesyscontrol restart command to sudoers.d
cmd = '''sudo -n systemctl restart codesyscontrol 2> /dev/null ||
         ls /etc/sudoers.d/allow_restart_codesyscontrol > /dev/null 2>&1 ||
         echo "$USER ALL=(ALL:ALL) NOPASSWD: $(which systemctl) restart codesyscontrol" |
         sudo EDITOR="tee" visudo -f /etc/sudoers.d/allow_restart_codesyscontrol > /dev/null &&
         sudo -n systemctl restart codesyscontrol'''

robin.xml

<!-- codesys multidimensional arrays -->
<variable name="double_flarray_to_codesys_1">
  <type>
    <array>
      <dimension lower="1" upper="5" />
      <baseType>
        <derived name="TestStruct_foo" />
      </baseType>
    </array>
  </type>
  <documentation>
    <xhtml xmlns="http://www.w3.org/1999/xhtml">  struct_to_codesys_arr: TestStruct_arr;</xhtml>
  </documentation>
</variable>
<variable name="double_flarray_to_codesys_2">
  <type>
    <array>
      <dimension lower="1" upper="5" />
      <dimension lower="1" upper="10" />
      <baseType>
        <LREAL />
      </baseType>
    </array>
  </type>
</variable>
<variable name="double_flarray_to_codesys_3">
  <type>
    <array>
      <dimension lower="1" upper="5" />
      <baseType>
        <array>
          <dimension lower="1" upper="5" />
          <baseType>
            <LREAL />
          </baseType>
        </array>
      </baseType>
    </array>
  </type>
</variable>