GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Matrixchung/ifoc_control

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
config
config
 
 
include/ifoc_control
include/ifoc_control
 
 
python
python
 
 
resource
resource
 
 
src
src
 
 
third_party
third_party
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.xml
package.xml
 
 

Repository files navigation

ifoc_control

支持 hcan 和 socketcan 双后端的双模式工程:

  • 作为 ROS 2 ament_cmake 功能包编译
  • 作为普通 CMake 项目独立编译
  • 通过 config/config.yaml 统一定义 CAN 配置
  • Linux 和 Windows 通过条件编译调用各自平台的 HCAN 动态库

目录结构

  • include/ifoc_control/can/: CAN 公共类型和 ICANDevice 接口
  • include/ifoc_control/hal/: HAL 设备声明
  • src/core/: 公共类型实现
  • src/HAL/: HCAN / SocketCAN HAL 实现
  • src/apps/: 独立程序和 ROS 2 节点入口
  • third_party/hcan/: 从 docs/hcan 整理进来的原厂头文件和平台库
  • config/config.yaml: 运行时配置文件

Vendor 库布局

  • third_party/hcan/include/windows/HCanbus.h
  • third_party/hcan/include/linux/Hcanbus.h
  • third_party/hcan/windows/x64/
  • third_party/hcan/windows/x86/
  • third_party/hcan/linux/ubuntu22-x86_64/
  • third_party/hcan/linux/ubuntu20-x86_64/
  • third_party/hcan/linux/arm64/
  • third_party/hcan/linux/armhf/

Linux 默认会按当前架构选择 bundled HCAN 库。x86_64 默认使用 ubuntu22-x86_64,也可以在配置时手动覆盖:

cmake -S . -B build -DHCAN_LINUX_VARIANT=ubuntu20-x86_64

独立编译

cmake -S . -B build
cmake --build build
./build/ifoc_control_cli

安装 Python 包

项目根目录已经提供 setup.py,可以直接安装 ifoc Python 包:

python3 -m pip install .

开发模式安装:

python3 -m pip install -e .

安装后即可直接使用:

import ifoc
import ifoc.vofa_server as vofa

如果要运行 python/examples/demo.py,建议安装演示依赖:

python3 -m pip install ".[demo]"

程序会优先读取:

  1. 环境变量 IFOC_CONTROL_CONFIG
  2. 兼容旧环境变量 IFOC_ROS2_CONTROL_CONFIG
  3. 当前工作目录下的 config/config.yaml
  4. 源码目录下的默认 config/config.yaml

作为 ROS 2 功能包编译

把当前目录放进 ROS 2 workspace 的 src/ 下,然后执行:

colcon build --packages-select ifoc_control
source install/setup.bash
ros2 run ifoc_control ifoc_control_node

config.yaml

所有 CAN 设备配置都定义在 can: 节点下,仅保留这些字段:

  • backend: "hcan" 或 "socketcan"
  • can_fd: 是否启用 CAN FD
  • bitrate: 常规 CAN 仲裁域波特率
  • data_bitrate: CAN FD 数据域波特率。can_fd: false 时无效
  • device_index: HCAN 设备编号
  • channel_index: HCAN 通道编号。Linux 下通常是 0/1
  • channel_name: SocketCAN 接口名,例如 can0

当前示例文件见 config/config.yaml。

说明

  • 若 backend: hcan,程序初始化时会先调用 CAN_ScanDevice() 并打印所有扫描到的 HCAN 基本信息。
  • hcan 其余参数使用代码内固定默认值:终端电阻开启、离线唤醒开启、自动重传开启、过滤器默认全收、canfd_mode=IsoCANFD。Pres/Tseg1/Tseg2/SJW 等时序参数默认填 0,交给 HCAN 动态库按波特率自动计算,采样点约为 75%。
  • socketcan 其余参数也使用固定默认值:loopback=false、listen_only=false、receive_own_messages=false、berr_reporting=true、restart_ms=100。
  • Linux 下,HCAN 官方库运行时通常还依赖 libudev,当前 Ubuntu 环境链接验证已通过。
  • Windows 构建会根据位数自动选用 third_party/hcan/windows/x64 或 x86 下的 .lib/.dll。
  • Linux 与 Windows 的 HCAN API 存在差异:Linux 是 device + channel,Windows 是“每通道一个设备索引”。当前 HAL 已在内部做了统一封装。
  • socketcan 后端当前仅在 Linux 下可用。

About

No description, website, or topics provided.

Resources

Readme
Apache-2.0 license
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.