ros-industrial / ros_canopen

CANopen driver framework for ROS (http://wiki.ros.org/ros_canopen)
GNU Lesser General Public License v3.0
336 stars 271 forks source link

Using CAN bus ID's #382

Closed BenJamin-ad closed 4 years ago

BenJamin-ad commented 4 years ago

I would like to filter the CAN bus messages to only read a few CAN ID's from my vehicle before passing them onto other parts of my system or into a bag as I don't require the entire vehicle CAN bus.

I see that this functionality has been mentioned in #230 #250 but I am struggling to see where I can include my CAN ID's.

I am currently using socketcan_bridge to bring CAN bus data into ROS.

Is it possible for someone to explain how I can only receive messages from a few CAN ID's?

Many thanks.

mathias-luedtke commented 4 years ago

I see that this functionality has been mentioned in #230 #250 but I am struggling to see where I can include my CAN ID's.

As described in #250, you need to set the can_ids parameter (list of numbers and/or strings).

BenJamin-ad commented 4 years ago

Thank you for the reply.

I appreciate that #250 shows me the parameter to set and the accepted format however I am still confused how I can do this? Do I set this in the ROS workspace or elsewhere?

mathias-luedtke commented 4 years ago

however I am still confused how I can do this? Do I set this in the ROS workspace or elsewhere?

A common approach is to create a launch file that loads the config from a YAML file or sets the parameters directly.

Please note that can_ids is a private parameter.

If you need help in setting a parameter, please check ROS answers as well.

PS: I will close this issue now, because it this is not a ros_canopen-specific issue.

BenJamin-ad commented 4 years ago

Thank you @ipa-mdl.

I know this is probably trivial for most but in case anyone is interested here is my launch file that successfully logged only can id 176:

`

[176]

`

omerkonan commented 2 years ago

Hello, I am trying to initialize XmlRpc::XmlRpcValue by hard-coded. I don't want to get value from ros params. How can I create XmlRpc::XmlRpcValue from std::string list. @BenJamin-ad @mathias-luedtke For example, I have list like [1556, 176, 1557]. It is not importtant for me is it integer or string list. I want to typecast this list to XmlRpc::XmlRpcValue. Then I want to run this method with created XmlRpc::XmlRpcValue void SocketCANToTopic::setup(XmlRpc::XmlRpcValue filters) { setup(can::tofilters(filters)); } https://github.com/ros-industrial/ros_canopen/blob/e10f4905c6b773f8f31f99b900665a69a6a7678a/socketcan_bridge/src/socketcan_to_topic.cpp#L78