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

Aerugo2272's profile - activity

2020-03-02 20:59:37 -0500 received badge  Famous Question (source)
2019-09-17 03:56:56 -0500 received badge  Enthusiast
2019-09-13 05:01:04 -0500 received badge  Notable Question (source)
2019-09-02 04:56:48 -0500 received badge  Popular Question (source)
2019-07-29 03:38:43 -0500 commented answer can't locate node [my_imu] in package [imu_localisation]

Thanks that worked! Small note, had to change the name in "add_dependencies" and "target_link_libraries" as well to my n

2019-07-29 03:37:52 -0500 marked best answer can't locate node [my_imu] in package [imu_localisation]

I've been trying to make a simple cpp code that does the double integration for an IMU to return the estimated position. The package imu_localisation is listed in rospack list, and roslaunch finds the package and the launch file as well. However when I try to launch it I am hit with:

ERROR: cannot launch node of type [imu_localisation/my_imu]: can't locate node [my_imu] in package [imu_localisation]

I've tried catkin_make and source devel/setup.bash in that order multiple times to no avail. The error occurs when I run

roslaunch imu_localisation localise.launch

The following is the my_imu.cpp code.

#include "ros/ros.h"
#include "std_msgs/String.h"
#include "sensor_msgs/Imu.h"
#include "geometry_msgs/Vector3.h"
#include "nav_msgs/Odometry.h"

sensor_msgs::Imu prev_imu;

void imuCallback(const sensor_msgs::Imu::ConstPtr& imu){
  prev_imu.linear_acceleration.x = imu->linear_acceleration.x;
  prev_imu.linear_acceleration.y = imu->linear_acceleration.y;
  prev_imu.linear_acceleration.z = imu->linear_acceleration.z;

}

int main(int argc, char **argv){
  ros::init(argc, argv, "my_imu");
  double samplePeriod = 0.02;
  ros::NodeHandle nh;
  geometry_msgs::Vector3 vel,prev_vel,pos,prev_pos;
  ros::Publisher pos_pub=nh.advertise<nav_msgs::Odometry>("/odom",1);
  ros::Subscriber imu_sub=nh.subscribe("/imu/data" , 50, imuCallback);
  ros::Rate loop_rate(50);

  while(ros::ok()){
    std_msgs::String msgs;
    if(prev_vel.x == 0){
      prev_vel.x = prev_imu.linear_acceleration.x * samplePeriod;
      prev_vel.y = prev_imu.linear_acceleration.y * samplePeriod;
      prev_vel.z = prev_imu.linear_acceleration.z * samplePeriod;
    }
    //
    vel.x = prev_vel.x + prev_imu.linear_acceleration.x * samplePeriod;
    vel.y = prev_vel.y + prev_imu.linear_acceleration.y * samplePeriod;
    vel.z = prev_vel.z + prev_imu.linear_acceleration.z * samplePeriod;
    ROS_INFO("vel x : %f", vel.x);
    pos.x = prev_pos.x + vel.x * samplePeriod;
    pos.y = prev_pos.y + vel.y * samplePeriod;
    pos.z = prev_pos.z + vel.z * samplePeriod;
    ROS_INFO("pos x : %f", pos.x);

    prev_vel = vel;
    prev_pos = pos;
    loop_rate.sleep();
  }

}

And here is my launch file localise.launch

<launch>

  <node pkg="imu_localisation" name="my_imu" type="my_imu" output="screen">
  </node>
</launch>

And the CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(imu_localisation)

find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  roscpp
  rospy
  sensor_msgs
  std_msgs
)

catkin_package()

include_directories(
  ${catkin_INCLUDE_DIRS}
)

add_executable(imu_localisation src/my_imu.cpp)
add_dependencies(imu_localisation ${imu_localisation_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(imu_localisation
  ${catkin_LIBRARIES}
)

Any pointers? I'm sure I'm missing something dead simple here.

2019-07-29 03:37:52 -0500 received badge  Scholar (source)
2019-07-29 03:34:55 -0500 received badge  Supporter (source)
2019-07-26 10:47:14 -0500 asked a question can't locate node [my_imu] in package [imu_localisation]

can't locate node [my_imu] in package [imu_localisation] I've been trying to make a simple cpp code that does the double