sammy-tri / drake-jaco-driver

Driver for controlling a Kinova Jaco arm via LCM
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Add (preliminary) support for ethernet control of Jaco arms #1

Closed sammy-tri closed 4 years ago

calderpg-tri commented 4 years ago

USB/Ethernet switching is being handled in much the same way we handle ROS1/ROS2 build switching, so I don't think it's too bad of a hack. I would say that MAYBE_ETHERNET(Function(args)) does look a bit odd, and I'd generally say macros that look function-like but aren't are potentially confusing. Based on what we did with the ROS1/ROS2 handling, would it be better to do something like

#ifdef USE_ETHERNET
  using SdkGetAngularPosition = Ethernet_GetAngularPosition;
#else
  using SdkGetAngularPosition = GetAngularPosition;
#endif

so that USB/Ethernet-specific switches all occur in one place and then there aren't macro invocations all over?

sammy-tri commented 4 years ago

Does 'using' work for free functions? It doesn't appear to...

calderpg-tri commented 4 years ago

I didn't remember if using would work for that. In that case

#ifdef USE_ETHERNET
  #define SdkGetAngularPosition Ethernet_GetAngularPosition
#else
  #define SdkGetAngularPosition GetAngularPosition
#endif

would work instead.

sammy-tri commented 4 years ago

Tried something similar to your suggestion. Surprisingly (to me) the preprocessor/compiler really wanted me to use macros with arguments.