Skip to content

Commit

Permalink
Merge pull request #93 from clearpathrobotics/feature/vcan_defaults
Browse files Browse the repository at this point in the history
Add default vcan ROS interfaces based on platform
  • Loading branch information
roni-kreinin authored Nov 22, 2024
2 parents 8e1848a + 61e9a88 commit 7c66d0b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions clearpath_config/platform/can.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from clearpath_config.common.types.config import BaseConfig
from clearpath_config.common.types.list import ListConfig
from clearpath_config.common.types.platform import Platform
from typing import List


Expand Down Expand Up @@ -130,6 +132,30 @@ def __init__(self) -> None:


class CANBridgeConfig:
SINGLE_VCAN_DEFAULT = [
{
CANBridge.INTERFACE: "vcan0",
CANBridge.ENABLE_CAN_FD: False,
CANBridge.INTERVAL: 0.01,
CANBridge.USE_BUS_TIME: False,
CANBridge.FILTERS: "0:0",
CANBridge.AUTO_CONFIGURE: True,
CANBridge.AUTO_ACTIVATE: True,
}
]

DEFAULTS = {
Platform.A200: [],
Platform.DD100: SINGLE_VCAN_DEFAULT,
Platform.DD150: SINGLE_VCAN_DEFAULT,
Platform.DO100: SINGLE_VCAN_DEFAULT,
Platform.DO150: SINGLE_VCAN_DEFAULT,
Platform.GENERIC: [],
Platform.J100: [],
Platform.R100: SINGLE_VCAN_DEFAULT,
Platform.W200: [],
}

def __init__(
self,
config: dict = {}
Expand All @@ -155,3 +181,7 @@ def config(self, can_bridges: list):
bridge = CANBridge()
bridge.from_dict(b)
self._can_bridges.add(bridge)

def update(self, serial_number: bool = False) -> None:
if serial_number:
self.config = self.DEFAULTS[BaseConfig.get_platform_model()]
1 change: 1 addition & 0 deletions clearpath_config/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def update(self, serial_number=False) -> None:
self.template = template
# Reload battery
self.battery.update(serial_number=serial_number)
self.can_bridges.update(serial_number=serial_number)

@property
def controller(self) -> str:
Expand Down

0 comments on commit 7c66d0b

Please sign in to comment.