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.