ROS和CAN的一些资料

举报
zhangrelay 发表于 2021/07/15 04:52:58 2021/07/15
【摘要】 最近需要在ROS中使用CAN,这里简单汇总一下看过的资料,参考文献如下: 1. ROS Control and CAN interface on a custom robot 2. ros_canopen wiki ros_canopen: can_msgs | canopen_402 | canopen_chai...

最近需要在ROS中使用CAN,这里简单汇总一下看过的资料,参考文献如下:

1. ROS Control and CAN interface on a custom robot

2. ros_canopen wiki


ros_canopencan_msgs | canopen_402 | canopen_chain_node | canopen_master | canopen_motor_node | socketcan_bridge | socketcan_interface

3. ros_canopen github


这些资料主要讲述在ROS中使用Canopen。这些软件包为ROS内的CANopen设备提供支持。

它可以分为不同的部分:

  • CAN层抽象
  • 带有设备/对象管理的CANopen主站
  • 特定于配置文件的支持,目前仅适用于402配置文件(驱动器和运动控制)
  • ROS界面,通过ros_control进行运动控制



canopen_motor_node为例:

----

controller manager

The node includes a controller_manager instance that can be used to spawn controller_interface compliant controllers. Depending on the motor device different interfaces are support.

For each joint a hardware_interface::JointStateHandle is registered with the position, velocity and effort of the specific drive. The actual value is determined by the conversion functions.

In addition handles for the following command interfaces are available if the given modes are supported by the device:

  • hardware_interface::PositionJointInterface:

    • Profiled Position
    • Interpolated Position
    • Cyclic Synchronous Position
  • hardware_interface::VelocityJointInterface:

    • Velocity
    • Profiled Velocity
    • Cyclic Synchronous Velocity
  • hardware_interface::EffortJointInterface:

    • Profiled Torque
    • Cyclic Synchronous Torque

----

Drive operation modes

All standardized drive modes are implemented, these modes can be substituted in sub classes and others can be added.

The following table lists all supported drive modes and their data objects. The objects used should be mapped to PDOs.

Name

ID

target object

RPDO mapping parameter

comments

Profiled Position

1

607A

0x607a0020

Velocity

2

6042

0x60420010

Profiled Velocity

3

60FF

0x60ff0020

Profiled Torque

4

6071

0x60710010

not yet tested

Interpolated Position

7

60C1sub1

0x60c10120

Cyclic Synchronous Position

8

607A

0x607a0020

not yet tested

Cyclic Synchronous Velocity

9

60FF

0x60ff0020

not yet tested

Cyclic Synchronous Torque

10

7071

0x60710010

not yet tested

The modes can be switched at run-time, the 402 state might be switched in order to switch the mode, if necessary.

Not all devices support all operation modes. The driver limits the set of available modes based on object 6502.


----


  
  1. namespace canopen
  2. {
  3. class MotorBase : public canopen::Layer {
  4. protected:
  5. MotorBase(const std::string &name) : Layer(name) {}
  6. public:
  7. enum OperationMode
  8. {
  9. No_Mode = 0,
  10. Profiled_Position = 1,
  11. Velocity = 2,
  12. Profiled_Velocity = 3,
  13. Profiled_Torque = 4,
  14. Reserved = 5,
  15. Homing = 6,
  16. Interpolated_Position = 7,
  17. Cyclic_Synchronous_Position = 8,
  18. Cyclic_Synchronous_Velocity = 9,
  19. Cyclic_Synchronous_Torque = 10,
  20. };



  
  1. ProfiledPositionMode(boost::shared_ptr<ObjectStorage> storage) : ModeTargetHelper(MotorBase::Profiled_Position) {
  2. storage->entry(target_position_, 0x607A);


  
  1. virtual void registerDefaultModes(boost::shared_ptr<ObjectStorage> storage){
  2. registerMode<ProfiledPositionMode> (MotorBase::Profiled_Position, storage);
  3. registerMode<VelocityMode> (MotorBase::Velocity, storage);
  4. registerMode<ProfiledVelocityMode> (MotorBase::Profiled_Velocity, storage);
  5. registerMode<ProfiledTorqueMode> (MotorBase::Profiled_Torque, storage);
  6. registerMode<DefaultHomingMode> (MotorBase::Homing, storage);
  7. registerMode<InterpolatedPositionMode> (MotorBase::Interpolated_Position, storage);
  8. registerMode<CyclicSynchronousPositionMode> (MotorBase::Cyclic_Synchronous_Position, storage);
  9. registerMode<CyclicSynchronousVelocityMode> (MotorBase::Cyclic_Synchronous_Velocity, storage);
  10. registerMode<CyclicSynchronousTorqueMode> (MotorBase::Cyclic_Synchronous_Torque, storage);
  11. }



  
  1. class InterfaceMapping {
  2. typedef boost::bimap<boost::bimaps::multiset_of<std::string>, boost::bimaps::set_of<canopen::MotorBase::OperationMode> > bimap_type;
  3. bimap_type mapping_;
  4. public:
  5. InterfaceMapping(){
  6. mapping_.insert(bimap_type::value_type("hardware_interface::PositionJointInterface" ,canopen::MotorBase::Profiled_Position));
  7. mapping_.insert(bimap_type::value_type("hardware_interface::PositionJointInterface" ,canopen::MotorBase::Interpolated_Position));
  8. mapping_.insert(bimap_type::value_type("hardware_interface::PositionJointInterface" ,canopen::MotorBase::Cyclic_Synchronous_Position));
  9. mapping_.insert(bimap_type::value_type("hardware_interface::VelocityJointInterface" ,canopen::MotorBase::Velocity));
  10. mapping_.insert(bimap_type::value_type("hardware_interface::VelocityJointInterface" ,canopen::MotorBase::Profiled_Velocity));
  11. mapping_.insert(bimap_type::value_type("hardware_interface::VelocityJointInterface" ,canopen::MotorBase::Cyclic_Synchronous_Velocity));
  12. mapping_.insert(bimap_type::value_type("hardware_interface::EffortJointInterface" ,canopen::MotorBase::Profiled_Torque));
  13. mapping_.insert(bimap_type::value_type("hardware_interface::EffortJointInterface" ,canopen::MotorBase::Cyclic_Synchronous_Torque));
  14. }
  15. std::vector<canopen::MotorBase::OperationMode> getInterfaceModes(const std::string &interface){
  16. std::vector<canopen::MotorBase::OperationMode> modes;
  17. BOOST_FOREACH(bimap_type::left_reference i, mapping_.left.equal_range(interface)){
  18. modes.push_back(i.second);
  19. }
  20. return modes;
  21. }
  22. bool hasConflict(const std::string &interface, canopen::MotorBase::OperationMode mode){
  23. bimap_type::right_const_iterator it;
  24. if((it = mapping_.right.find(mode)) != mapping_.right.end()){
  25. return it->second != interface;
  26. }
  27. return false;
  28. }
  29. };


----

具体使用认真参考wiki和源码即可。

补充资料:

This is definitely still a WIP but I feel that it’s useful enough at this stage to make it publicly known. I’ve developed a wxWidgets-based tool for analysis of CAN messages and signals. I call it DeCANstructor and it’s available on Github20. Please feel free to provide any feedback/feature requests/etc. there. In addition to working with SocketCAN through ros_canopen6, it also works with multi-channel and PCIe Kvaser devices through Kvaser’s CANLIB and my company’s kvaser_interface9 (which outputs the same messages as ros_canopen).




文章来源: zhangrelay.blog.csdn.net,作者:zhangrelay,版权归原作者所有,如需转载,请联系作者。

原文链接:zhangrelay.blog.csdn.net/article/details/79296078

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。