forked from LORD-MicroStrain/microstrain_inertial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move driver package content to ros_mscl folder
* 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
Showing
92 changed files
with
205 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.