ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to let Ros communicate to new hardware?

asked 2019-06-25 19:02:31 -0600

Leoshock gravatar image

l am planning to use Sensoray826 board to control some motors, and using Ros-rqt to plot some curves..but there is not any useful driver/package to connect them(arduino is so common to be used, l dont want to use this). Could someone give me some methods to let Ros(kinetic) receive messages from Sensoray826(using rosserial or? how to use it?)?

edit retag flag offensive close merge delete

Comments

It's not much, but there appears to be at least some code in jmpechem/sm_n_vis/sensoray826.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-26 02:19:16 -0600 )edit

l knew this code, but dont know how to use it.

Leoshock gravatar image Leoshock  ( 2019-06-27 15:39:29 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-25 23:30:14 -0600

Geoff gravatar image

The best resource on the general process for talking to a new piece of hardware in ROS is Chapter 15 of Programming Robots with ROS. It describes the general process for creating new ROS nodes to talk to a sensor or actuator. However it doesn't cover the specific part of talking to the hardware, because this varies far too much between different pieces of hardware to write a general description.

In the case of your board, there is a software development kit available for Linux and a technical wiki that has a lot of information on how the board is programmed. You also apparently need to install a Linux kernel driver to handle the actual communication with the board, but after that you should be able to use the provided API to handle communication with it. Once you have the driver installed, I recommend you try out the examples to learn how the board works (skip this step if you already know). Then you can do the same sort of thing as the examples to talk to the board from your ROS node(s).

As the book linked above says, you will need to decide what ROS interface your nodes will provide for interacting with the boards. This depends on the specific hardware you are using with it.

edit flag offensive delete link more

Comments

l already knew how to program codes in linux for this board and finished whole code for controlling the motor, l am now familiar with this board, but l dont know ros much, and the development kit of the board does not have GUI to show velocity curve... that is why l want to let board talk to "Ros node" to generate some GUI in ROS.

Leoshock gravatar image Leoshock  ( 2019-06-27 15:43:01 -0600 )edit

In that case refer to the Programming Robots with ROS book for the best tutorial on how to integrate it into ROS.

Geoff gravatar image Geoff  ( 2019-06-27 19:07:00 -0600 )edit

l am still confused that, from the book you mentioned, the author used" from fake_sensor import Fakesensor". But for sensoray 826 board, it has its own driver and file making method. for example, l used its development kit writting a c language file called motor.c and then generating an executable file from it, called motordemo. My question is in my code, how can l import the function like the book did? "from motor.c import xxx" or "from motordemo import xxx", if the second is correct, why will the topic receive the sensing data from it? it's just a executable file?!

Leoshock gravatar image Leoshock  ( 2019-08-02 17:00:01 -0600 )edit

The book is using Python. If you are using C++, you can't copy the code directly. You can't import an executable file into a C++ program.

The easiest approach is to create a ROS node and use the SDK provided by the board's manufacturer directly from your node to talk to the board. This is like creating your motor.c file, but you do it through the ROS toolchain. You may also be able to paste the content of motor.c into your node's source file and use its functions, although I do not recommend it as this approach will be harder to maintain.

Alternatively, you could use the manufacturer's SDK to create a shared library, and then link your node's executable file to that.

Geoff gravatar image Geoff  ( 2019-08-04 17:36:20 -0600 )edit

thanks, l have last questions, now l have a c file in board's SDK which can control the motor, my plan is using python to write Ros nodes. can l directly import c.file into my python node file in ROS(like the book did for sensor) or l have to change c into c++ then import c++ into python? and l think besides these c file (or c++ file) and python nodes file and some SDK source files(like sensoray826api.h which is supplied by manufacturer), l still need to write sth to connect ros to board?l think this file is not supplied by anyone because judging from the book you mentioned, it has python nodes file and python fakesensor file, although the book does not mention other files l guess there will still be a file to connect nodes to fakesensor, is it right? do you ...(more)

Leoshock gravatar image Leoshock  ( 2019-08-08 16:59:52 -0600 )edit

If you want to use your C file from a node written in Python, you will need to create a C extension for Python. This is _not easy_ and so I am guessing that it is not want you want to do.

Here's what you need to do in steps:

  1. Create a ROS node using C++.
  2. Make a header file for your C file that declares the functions necessary to control the motor.
  3. Include the header file in your ROS node's source file.
  4. Include the C file in your CMakeLists.txt so that it gets compiled as part of the node.
  5. Use the functions from your C file in your ROS node to talk to the motor.

However to be honest I think you do not have enough general knowledge of using C++, because you do not appear to understand that you cannot directly import a source file ...(more)

Geoff gravatar image Geoff  ( 2019-08-18 17:25:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-25 19:02:31 -0600

Seen: 620 times

Last updated: Jun 25 '19