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

MattMalt's profile - activity

2019-02-13 11:37:27 -0500 received badge  Famous Question (source)
2018-07-09 14:07:49 -0500 marked best answer BNO05 IMU + ROS

I've recently purchased the BNO05 IMU and wish to start publishing sensor_msgs/Imu data on my ROS network. The sensor is connected to an Arduino Uno board which is then connected to my computer. I've found sample code for the IMU which obtains quaternion data from the sensor and displays it on the serial monitor.

I've tried to modify the code so that a node is created which publishes the data in the sensor_msgs/IMU format. The problem is that once this extra code is added, the serial monitor starts outputting rubbish. I believe that this might be due to delays.

Does anyone have experience with this particular IMU?

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <ros.h>
#include <sensor_msgs/Imu.h>

/* 

   Connections

   ===========
   Connect SCL to analog 5
   Connect SDA to analog 4
   Connect VDD to 3-5V DC
   Connect GROUND to common ground

   History
   =======
   2015/MAR/03  - First release (KTOWN)
   2015/AUG/27  - Added calibration and system status helpers
*/

/* Set the delay between fresh samples */
#define BNO055_SAMPLERATE_DELAY_MS (1000)

sensor_msgs::Imu odom_msg;
ros::Publisher pub_odom("imuOdom", &odom_msg);
ros::NodeHandle nh;

Adafruit_BNO055 bno = Adafruit_BNO055(55);

/**************************************************************************/
/*
    Displays some basic information on this sensor from the unified
    sensor API sensor_t type (see Adafruit_Sensor for more information)
*
/
/**************************************************************************/
void displaySensorDetails(void)
{
  sensor_t sensor;
  bno.getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" xxx");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" xxx");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" xxx");



Serial.println("------------------------------------");

  Serial.println("");
  delay(500);
}

/**************************************************************************/
/*
    Display some basic info about the sensor status
*/
/**************************************************************************/
void displaySensorStatus(void)
{
  /* Get the system status values (mostly for debugging purposes) */

  uint8_t system_status, self_test_results, system_error;
  system_status = self_test_results = system_error = 0;
  bno.getSystemStatus(&system_status, &self_test_results, &system_error);

  /* Display the results in the Serial Monitor */
  Serial.println("");
  Serial.print("System Status: 0x");
  Serial.println(system_status, HEX);
  Serial.print("Self Test:     0x");
  Serial.println(self_test_results, HEX);
  Serial.print("System Error:  0x");

  Serial.println(system_error, HEX);
  Serial.println("");
  delay(500);
}

/**************************************************************************/
/*
    Display sensor calibration status
*/
/**************************************************************************/

    void displayCalStatus(void)
{
  /* Get the four calibration values (0..3) */
  /* Any sensor data reporting 0 should be ignored, */
  /* 3 means 'fully calibrated" */
  uint8_t system, gyro, accel, mag;
  system = gyro = accel = mag = 0;
  bno.getCalibration(&system, &gyro, &accel, &mag);

  /* The data should be ignored until the system calibration is > 0 */
  Serial.print("\t");
  if (!system)
  {

    Serial.print("! ");
  }

  /* Display the individual values */
  Serial.print("Sys:");
  Serial.print(system, DEC);
  Serial.print(" G:");
  Serial.print(gyro, DEC);
  Serial.print(" A:");
  Serial.print(accel, DEC);
  Serial.print(" M:");

  Serial.print(mag, DEC);
}

/**************************************************************************/
/*
    Arduino setup function (automatically called at startup)
*/
/**************************************************************************/
void setup(void)
{ 
  nh.initNode(); 

  nh.advertise(pub_odom);

  Serial.begin(9600);
  Serial.println("Orientation Sensor Test"); Serial.println("");

  /* Initialise the sensor */
  if(!bno.begin())
  {
    /* There was a problem detecting the BNO055 ... check your connections */
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ...
(more)
2017-10-26 01:04:47 -0500 received badge  Notable Question (source)
2017-10-15 06:33:34 -0500 received badge  Popular Question (source)
2017-09-06 01:31:21 -0500 received badge  Famous Question (source)
2017-06-06 12:18:48 -0500 received badge  Famous Question (source)
2017-06-06 12:18:48 -0500 received badge  Notable Question (source)
2017-05-11 08:31:23 -0500 asked a question robot_pose_ekf problem

robot_pose_ekf problem I'm trying to use robot_pose_ekf with an IMU and odometry, but I'm getting the error "filter time

2017-05-08 02:08:44 -0500 received badge  Notable Question (source)
2017-05-02 04:27:15 -0500 commented answer BNO05 IMU + ROS

I found that the reason that the board wasn't connecting with ROS was because of the different baud rates. Entering the

2017-05-02 04:21:49 -0500 received badge  Popular Question (source)
2017-05-02 04:12:49 -0500 commented answer BNO05 IMU + ROS

I've removed the serial outputs to the monitor, but I'm now getting this error message : [ERROR] [WallTime: 1493716237

2017-05-02 04:11:11 -0500 received badge  Enthusiast
2017-05-01 14:07:01 -0500 asked a question BNO05 IMU + ROS

BNO05 IMU + ROS I've recently purchased the BNO05 IMU and wish to start publishing sensor_msgs/Imu data on my ROS networ

2016-11-30 04:52:52 -0500 received badge  Supporter (source)
2016-11-29 04:44:17 -0500 received badge  Popular Question (source)
2016-11-29 01:21:50 -0500 received badge  Student (source)
2016-11-28 12:16:16 -0500 commented question Transform Listener Problem

Ah I see, I saw an example online using c_str() and assumed that I had to use it. Thanks for pointing that out for future reference though!

2016-11-27 22:26:54 -0500 asked a question Transform Listener Problem

Hi I'm new to ROS and am trying to transform a point from the /odom frame to the /map frame. Every time I run the package I get the following error:

Invalid argument passed to lookupTransform argument source_frame in tf2 frame_ids cannot be empty

My code is detailed below:

geometry_msgs::PointStamped point1;
   geometry_msgs::PointStamped point2;
   std::string frame1 = "/odom"; 
   std::string frame2 = "/map";

void getPoseCallback(const geometry_msgs::Pose msg)

{
   point1.point.x = msg.position.x;
   point1.point.y = msg.position.y;
   point1.point.z = 0;
   point1.header.frame_id = frame1.c_str();
}

int main(int argc, char** argv)
{  
  ros::init(argc, argv, "tf_listener");

  ros::NodeHandle node;

  ros::Publisher pose = node.advertise<geometry_msgs::PointStamped>("odom_abs", 10);
  ros::Subscriber getPose = node.subscribe("/odom", 1000, getPoseCallback);
  tf::TransformListener listener;

      ros::Rate rate(10.0);

  point2.header.frame_id = frame2.c_str();

  while (node.ok())
  {
    try
    {
        listener.waitForTransform("/map","/odom",ros::Time::now(), ros::Duration(3.0));
        listener.transformPoint("/map", point1,point2);


       }
        catch (tf::TransformException &ex)
        {
      ROS_ERROR("%s",ex.what());
      ros::Duration(1.0).sleep();
      continue;
    }

    pose.publish(point2);



        ros::spin();
        rate.sleep();
      }

  return 0;
};

Checking with the class reference for the transform_listener, I can't find any error in the arguments.