ros-industrial / ros_canopen

CANopen driver framework for ROS (http://wiki.ros.org/ros_canopen)
GNU Lesser General Public License v3.0
332 stars 270 forks source link

Support Boolean variables #403

Open lkm1321 opened 3 years ago

lkm1321 commented 3 years ago

Hi,

This PR adds support for Boolean (DataType=0x0001) variables. The new features are:

  1. DataType=0x0001 in EDS is parsed as C++ bool, regarding positive integer values of DefaultValue as "true"
  2. It's published as ROS std_msgs/Bool object.

Addresses https://github.com/ros-industrial/ros_canopen/issues/268

Roboprotos commented 3 years ago

Hi, Thanks for proposing this PR, this feature would be really helpful. Since it has passed all the checks, would it be possible to have it merged with the melodic-devel branch ?

mathias-luedtke commented 3 years ago

This fix look okay, but I am unsure about PDO support. canopen_master does not support bit-wise access (granularity 1). Unfortunately, I was never able to test this, because none of our devices support boolean objects.

Roboprotos commented 3 years ago

I see, I was mainly interested in the DCF parser, to be able to parse boolean datatype from some manufacturer specific objects that can't be mapped to PDO.

I agree PDO support should be checked before merging, or if canopen_master doesn't support granularity 1, do you think the parser could just reject files which have a mappable boolean object ?

mathias-luedtke commented 3 years ago

do you think the parser could just reject files which have a mappable boolean object ?

I think it should be possible to fail the init service, if a boolean gets mapped.

lkm1321 commented 3 years ago

Hi guys, thanks for the interest. I do have a device with Boolean variables. I checked that parsing and SDOs are okay, but not PDOs. I'm happy to test whether PDO works. Would that help with having this merged?

Roboprotos commented 2 years ago

Hi @lkm1321, were you able to test your PR with PDOs ?

lkm1321 commented 2 years ago

Hi @Roboprotos, I did a quick test of this feature with our device (Roboteq RGBL1896) but doesn't seem to work correctly. SDO just seems to read 0 even though the underlying value should be 1. I'm not sure if the fault is in ros_canopen or in the device's firmware, and I'd need to look at cansniffer output to debug, but I'll be away from lab until February so it'll be some time before I do any debugging. I'll update if any developments before that.