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

micro ros with rviz

asked 2022-01-06 20:47:58 -0500

Nur92 gravatar image

updated 2022-01-07 02:09:36 -0500

gvdhoorn gravatar image

Hello. I'm new with ROS. Currently I'm using the sparkfun zed f9p rtk-gnss board module. then I'm using micro ros to publish the gps points which the sparkfun zed f9p rtk-gnss board module is connected with teensy 4.0

my question is how can I use rviz with the gps points.

Is there anyone can help me with this. Thank you


#define myWire Wire // This will work on the Redboard Artemis and the Artemis Thing Plus using Qwiic
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
//   microROS
#include <micro_ros_arduino.h>
#include <stdio.h>
#include <rcl/rcl.h>
#include <rcl/error_handling.h>
#include <rclc/rclc.h>
#include <rclc/executor.h>

#include <sensor_msgs/msg/nav_sat_fix.h>
#include <sensor_msgs/msg/nav_sat_status.h>

rcl_publisher_t publisher;
rclc_executor_t executor;
rclc_support_t support;
rcl_allocator_t allocator;
rcl_node_t node;
rcl_timer_t timer;

sensor_msgs__msg__NavSatFix * navsatfix_message;

#define LED_PIN 13

#define RCCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){error_loop();}}
#define RCSOFTCHECK(fn) { rcl_ret_t temp_rc = fn; if((temp_rc != RCL_RET_OK)){}}
//   microROS
//   microROS

void error_loop(){
    digitalWrite(LED_PIN, !digitalRead(LED_PIN));
//   microROS

void setup()
  while (!Serial); //Wait for user to open terminal


  //myGNSS.enableDebugging(Serial); // Uncomment this line to enable debug messages

  if (myGNSS.begin(myWire) == false) //Connect to the u-blox module using Wire port
    Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
    while (1)

  // Check that this platform supports 64-bit (8 byte) double
  if (sizeof(double) < 8)
    Serial.println(F("Warning! Your platform does not support 64-bit double."));
    Serial.println(F("The latitude and longitude will be inaccurate."));

  myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)

  //myGNSS.setNavigationFrequency(20); //Set output to 20 times a second

  byte rate = myGNSS.getNavigationFrequency(); //Get the update rate of this module
  Serial.print("Current update rate: ");

  //myGNSS.saveConfiguration(); //Save the current settings to flash and BBR

//   microROS

  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);  


  allocator = rcl_get_default_allocator();

  //create init_options
  RCCHECK(rclc_support_init(&support, 0, NULL, &allocator));

  // create node
  RCCHECK(rclc_node_init_default(&node, "micro_ros_arduino_node", "", &support));

  // create publisher
    ROSIDL_GET_MSG_TYPE_SUPPORT(sensor_msgs, msg, NavSatFix),

  navsatfix_message = sensor_msgs__msg__NavSatFix__create();

//   microROS


void loop()
  //Query module only every second.
  //The module only responds when a new position is available.
  if (millis() - lastTime > 1000)
    lastTime = millis(); //Update the timer

    // getHighResLatitude: returns the latitude from HPPOSLLH as an int32_t in degrees * 10^-7
    // getHighResLatitudeHp: returns the high resolution component of latitude from HPPOSLLH as an int8_t in degrees * 10^-9
    // getHighResLongitude: returns the longitude from HPPOSLLH as an int32_t in degrees * 10^-7
    // getHighResLongitudeHp: returns the high resolution component of longitude from HPPOSLLH as an int8_t in degrees * 10^-9
    // getElipsoid: returns the height above ellipsoid as an int32_t in mm
    // getElipsoidHp: returns the high resolution component of the height above ellipsoid as an int8_t in mm * 10^-1
    // getMeanSeaLevel: returns the height above mean sea level as an int32_t in ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-01-07 01:44:52 -0500

Pablogs gravatar image
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-01-06 20:47:58 -0500

Seen: 228 times

Last updated: Jan 07 '22