Hi i am currently trying to make ROS node for sending CAN bus messages.
I need to import a python 2.7 library named "can" in the script. I tried to add the path to this library to my CMAKE list, but with no luck.
Here is the script and errors i am getting.
-- ==> add_subdirectory(motor_controller)
CMake Error at motor_controller/CMakeLists.txt:153 (target_link_libraries):
Cannot specify link libraries for target "motor_controller_node" which is
not built by this project.
My node python script
## # In ROS, nodes are uniquely named. If two nodes with the same
# name are launched, the previous one is kicked off. The
# anonymous=True flag means that rospy will choose a unique
# name for our 'listener' node so that multiple listeners can
# run simultaneously.
import rospy, can
from sensor_msgs.msg import RegionOfInterest
bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=500000)
msg = can.Message(arbitration_id=0x5F0,data=[0],extended_id=False)
msg.data[0] = 1
def callback(data):
rospy.loginfo(data.y_offset)
bus.send(msg)
def listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber('MotorSetpoint', RegionOfInterest, callback)
# spin() simply keeps python from exiting until this node is stopped
rospy.spin()
if __name__ == '__main__':
listener()
my attempt to link the library:
FIND_LIBRARY(EXT_LIBRARY can /usr/local/lib/python2.7/dist-packages/python_can-2.1.1.dev0-py2.7.egg/can/__init__.pyc
)
target_link_libraries(${PROJECT_NAME}_node
${catkin_LIBRARIES}
${EXT_LIBRARY}
Originally posted by olacv15 on ROS Answers with karma: 3 on 2018-03-14
Post score: 0