Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default vcan ROS interfaces based on platform #93

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading