Skip to content

Commit

Permalink
* move driver package content to ros_mscl folder
Browse files Browse the repository at this point in the history
* add name argument to microstrain.launch file to specify the namespace (default: gx5)
* update README.md
* add basic subscriber example (C++)
  • Loading branch information
mgill committed Feb 19, 2020
1 parent 056d701 commit 201fd5d
Show file tree
Hide file tree
Showing 92 changed files with 205 additions and 52 deletions.
56 changes: 56 additions & 0 deletions Examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ROS-MSCL Examples Readme

A example listener node is provided in to demonstrate a very basic C++ node that subscribes to and displays some of the data published by the ros_mscl driver.

Over time we will provide more robust and varied examples in both C++ and Python, but in the meantime we hope this helps in quickly testing to ensure everything is installed and working properly!

Prerequisite: completed setup and build steps found [here](https://github.com/LORD-MicroStrain/ROS-MSCL).

#### Create the example package
1. Move the `ros_mscl_cpp_example` package to the `your_workspace/src` folder.

2. Locate and register the package to the workspace: `rospack find ros_mscl_cpp_example`

3. Build your workspace:

cd ~/your_workspace
catkin_make
source ~/your_workspace/devel/setup.bash
The source command may need to be run in each terminal prior to launching a ROS node.


#### Launch the listener node
Launch the inertial device node:

roslaunch ros_mscl microstrain.launch

In a separate terminal, launch the example listener node:

roslaunch ros_mscl_cpp_example listener.launch

Optional launch parameters:
- name: the namespace of the listener node, default: listener_cpp
- device: the namespace of the inertial device node to subscribe to, default: gx5


**Example**: Launch two listener subscribed to different namespaces

In two different terminals:

roslaunch ros_mscl_cpp_example listener.launch name:=listener1234 device:=sensor1234

ros_mscl_cpp_example listener.launch name:=bestListener device:=bestSensor
This will launch two nodes that listen to IMU data in different namespaces:
- listener1234, subscribed to: /sensor1234/imu/data
- bestListener, subscribed to: /bestSensor/imu/data

Test this by changing the namespace of the inertial device node:
1. Launch sensor1234:

roslaunch ros_mscl microstrain.launch name:=sensor1234
Data will begin to stream in only the listener1234 terminal.
2. Stop sensor1234
3. Launch bestSensor:

roslaunch ros_mscl microstrain.launch name:=bestSensor
Data will begin to stream in only the bestListener terminal.
19 changes: 19 additions & 0 deletions Examples/ros_mscl_cpp_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.8.3)
project(ros_mscl_cpp_example)

find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)

catkin_package()

include_directories(
# include
${catkin_INCLUDE_DIRS}
)


add_executable(listener_cpp src/listener.cpp)
target_link_libraries(listener_cpp ${catkin_LIBRARIES})
14 changes: 14 additions & 0 deletions Examples/ros_mscl_cpp_example/launch/listener.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<launch>

<!-- Declare arguments with default values -->
<arg name="name" default="listener_cpp" />
<arg name="device" default="gx5" />

<node name="listener_cpp"
pkg="ros_mscl_cpp_example"
type="listener" output="screen" ns="$(arg name)">
<param name="device" value="$(arg device)" type="str" />
</node>

</launch>
28 changes: 28 additions & 0 deletions Examples/ros_mscl_cpp_example/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<package format="2">
<name>ros_mscl_cpp_example</name>
<version>0.0.0</version>
<description>Example listener for Parker LORD Sensing inertial device driver ros_mscl (C++).</description>
<maintainer email="[email protected]">mgill</maintainer>
<license>MIT</license>

<url type="website">https://github.com/LORD-MicroStrain/ROS-MSCL</url>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>


<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

</export>
</package>
42 changes: 42 additions & 0 deletions Examples/ros_mscl_cpp_example/src/listener.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "ros/ros.h"
#include "sensor_msgs/Imu.h"

void imuDataCallback(const sensor_msgs::Imu::ConstPtr& imu)
{
ROS_INFO("Quaternion Orientation: [%f, %f, %f, %f]", imu->orientation.x, imu->orientation.y, imu->orientation.z, imu->orientation.w);
ROS_INFO("Angular Velocity: [%f, %f, %f]", imu->angular_velocity.x, imu->angular_velocity.y, imu->angular_velocity.z);
ROS_INFO("Linear Acceleration: [%f, %f, %f]", imu->linear_acceleration.x, imu->linear_acceleration.y, imu->linear_acceleration.z);

// add code here to handle incoming IMU data
}

int main(int argc, char** argv)
{
// register listener to ROS master
ros::init(argc, argv, "listener");

// get the device name parameter
std::string deviceName;
ros::NodeHandle params("~");
params.param<std::string>("device", deviceName, "gx5");
ROS_INFO("Got device param: %s", deviceName.c_str());

// clear param for future use
params.deleteParam("device");

// create the listener node object
ros::NodeHandle n;

// subscribe to the imu/data topic
//Parameters:
// topic - namespace (defined in launch file) and topic name
// queue size - maximum number of messages to buffer
// callback - callback function to handle this data
ros::Subscriber sub = n.subscribe(("/" + deviceName + "/imu/data"), 3, imuDataCallback);

// start listening for data
ros::spin();

return 0;
}

95 changes: 44 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,55 @@ MSCL is developed by [LORD Sensing - Microstrain](http://microstrain.com) in Wil

## Build Instructions

Download and install MSCL at /usr/share
#### MSCL
MSCL pre-built packages can be found here: [MSCL Packages](https://github.com/LORD-MicroStrain/MSCL#downloads)

#### Building from source
Install instructions can be found here: [How to Use MSCL](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md#linux)

If you choose to install MSCL at a location other than /usr/share, [CMakeLists.txt](https://github.com/LORD-MicroStrain/ROS-MSCL/blob/master/CMakeLists.txt) will need to be updated with the install path.

cd ~/catkin_ws
catkin_make
source devel/setup.bash

##### Pre-built MSCL Binaries/Packages (v52.2.1)
Windows:
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/mscl_52.2.1_Windows_C++.zip) |
[Python 2.7](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/mscl_52.2.1_Windows_Python2.7.zip) |
[Python 3.6](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/mscl_52.2.1_Windows_Python3.6.zip) |
[.NET](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/mscl_52.2.1_Windows_DotNet.zip)

Debian:
* x64:
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/c++-mscl_52.2.1_amd64.deb) |
[Python 2](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python2-mscl_52.2.1_amd64.deb) |
[Python 3](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python3-mscl_52.2.1_amd64.deb)
* arm64:
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/c++-mscl_52.2.1_arm64.deb) |
[Python 2](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python2-mscl_52.2.1_arm64.deb) |
[Python 3](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python3-mscl_52.2.1_arm64.deb)
* armhf (Raspbian):
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/c++-mscl_52.2.1_armhf.deb) |
[Python 2](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python2-mscl_52.2.1_armhf.deb) |
[Python 3](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python3-mscl_52.2.1_armhf.deb)

RPM:
* x64:
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/c++-mscl-52.2.1_x86_64.rpm) |
[Python 2](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python2-mscl-52.2.1_x86_64.rpm) |
[Python 3](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python3-mscl-52.2.1_x86_64.rpm)
* arm64:
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/c++-mscl-52.2.1_aarch64.rpm) |
[Python 2](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python2-mscl-52.2.1_aarch64.rpm) |
[Python 3](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python3-mscl-52.2.1_aarch64.rpm)
* CentOS:
[C++](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/c++-mscl-52.2.1_x86_64_centos7.6.1810.rpm) |
[Python 2](https://github.com/LORD-MicroStrain/MSCL/releases/download/v52.2.1/python2-mscl-52.2.1_x86_64_centos7.6.1810.rpm)

If the pre-built packages aren't available on your platform, you can build MSCL from source. This library will search for MSCL at /usr/share.

Instructions can be found here:
[Building MSCL on Windows](https://github.com/LORD-MicroStrain/MSCL/blob/master/BuildScripts/buildReadme_Windows.md) |
[Building MSCL on Linux](https://github.com/LORD-MicroStrain/MSCL/blob/master/BuildScripts/buildReadme_Linux.md)

### Documentation

[How to use MSCL](https://github.com/LORD-MicroStrain/MSCL/blob/master/HowToUseMSCL.md)

[FAQs](https://github.com/LORD-MicroStrain/MSCL/blob/master/FAQs.md)
#### Building from source
1. Install ROS and create a workspace: [Installing and Configuring Your ROS Environment](http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment)

2. Move ros_mscl package to the your_workspace/src folder.

3. Locate and register the ros_mscl package: `rospack find ros_mscl`

4. Build your workspace:

cd ~/your_workspace
catkin_make
source ~/your_workspace/devel/setup.bash
The source command may need to be run in each terminal prior to launching a ROS node.
#### Launch the node and publish data
The following command will launch the driver. Keep in mind each instance needs to be run in a separate terminal.

roslaunch ros_mscl microstrain.launch
Optional launch parameters:
- name: namespace the node will publish messages to, default: gx5
- port: serial port name to connect to the device over, default: /dev/ttyACM0
- baudrate: baud rate to open the connection with, default: 115200
- imu_rate: sample rate for IMU data (hz), default: 100
- debug: output debug info? default: false
- diagnostics: output diagnostic info? default: true

**Example**: Connect to and publish data from two devices simultaneously:
In two different terminals:

roslaunch ros_mscl microstrain.launch name:=sensor1234

roslaunch ros_mscl microstrain.launch name:=bestSensor port:=/dev/ttyACM1
This will launch two nodes that publish data to different namespaces:
- sensor1234, connected over port: /dev/ttyACM0
- bestSensor, connected over port: /dev/ttyACM1

To check published topics:

rostopic list


## License
ROS-MSCL is released under the MIT License - see the `LICENSE` file in the source distribution.

Copyright (c) 2020, Parker Hannifin Corp.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Standalone example launch file for 3DM-GX5-25 -->

<!-- Declare arguments with default values -->
<arg name="name" default="gx5" />
<arg name="port" default="/dev/ttyACM0" />
<arg name="baudrate" default="115200" />
<arg name="imu_rate" default="100" />
Expand All @@ -19,7 +20,7 @@
<!-- Microstrain sensor node -->
<node name="ros_mscl_node"
pkg="ros_mscl"
type="ros_mscl_node" output="screen" ns="gx5">
type="ros_mscl_node" output="screen" ns="$(arg name)">
<param name="port" value="$(arg port)" type="str" />
<param name="baudrate" value="$(arg baudrate)" type="int" />

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 201fd5d

Please sign in to comment.