ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
This may be a hardware issue. Try publishing the topic yourself without the IMU and see if you can get the callback to execute. You can do this with the command line as seen in the wiki:
rostopic pub /mavros/imu/data sensor_msgs/Imu "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
orientation_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
angular_velocity: {x: 0.0, y: 0.0, z: 0.0}
angular_velocity_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
linear_acceleration: {x: 0.0, y: 0.0, z: 0.0}
linear_acceleration_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]"
Now, the easy way to do this is to type rostopic pub /mavros/imu/data sensor_msgs/Imu
then hit the tab
key twice and it'll fill in the rest for you. Just hit Enter
and it'll publish this message for you.
Now, if your callback executes you'll that it may be a hardware issue versus something being wrong with your code.
2 | No.2 Revision |
This may be a hardware issue. Try publishing the topic yourself without the IMU and see if you can get the callback to execute. You can do this with the command line as seen in the wiki:
rostopic pub /mavros/imu/data sensor_msgs/Imu "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
orientation_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
angular_velocity: {x: 0.0, y: 0.0, z: 0.0}
angular_velocity_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
linear_acceleration: {x: 0.0, y: 0.0, z: 0.0}
linear_acceleration_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]"
Now, the easy way to do this is to type rostopic pub /mavros/imu/data sensor_msgs/Imu
in the terminal then hit the tab
key twice and it'll fill in the rest for you. Just Next, hit Enter
and it'll publish this message for you.
Now, if If your callback executes you'll that it may be a hardware issue versus something being wrong with your code.
3 | No.3 Revision |
This may be a hardware issue. Try publishing the topic yourself without the IMU and see if you can get the callback to execute. You can do this with the command line as seen in the wiki:
rostopic pub /mavros/imu/data sensor_msgs/Imu "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
orientation_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
angular_velocity: {x: 0.0, y: 0.0, z: 0.0}
angular_velocity_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
linear_acceleration: {x: 0.0, y: 0.0, z: 0.0}
linear_acceleration_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]"
Now, the easy way to do this is to type rostopic pub /mavros/imu/data sensor_msgs/Imu
in the terminal then hit the tab
key twice and it'll fill in the rest for you. Next, hit Enter
and it'll publish this message for you.
If your callback executes you'll that it may be a hardware issue versus something being wrong with your code.
the commander will fall back to the last mode the vehicle was in before entering Offboard mode
4 | No.4 Revision |
This may be a hardware issue. Try publishing the topic yourself without the IMU and see if you can get the callback to execute. You can do this with the command line as seen in the wiki:
rostopic pub /mavros/imu/data sensor_msgs/Imu "header:
seq: 0
stamp: {secs: 0, nsecs: 0}
frame_id: ''
orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
orientation_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
angular_velocity: {x: 0.0, y: 0.0, z: 0.0}
angular_velocity_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
linear_acceleration: {x: 0.0, y: 0.0, z: 0.0}
linear_acceleration_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]"
Now, the easy way to do this is to type rostopic pub /mavros/imu/data sensor_msgs/Imu
in the terminal then hit the tab
key twice and it'll fill in the rest for you. Next, hit Enter
and it'll publish this message for you.
If your callback executes you'll that it may be a hardware issue versus something being wrong with your code, or at least the callback portion of it. Although, if you're following the MAVROS PX4 ROS offboard tutorial you may be missing certain portions of code such as keeping the keeping the vehicle armed. If it doesn't receive any commands for a certain amount of time (faster than 2Hz) then
the commander will fall back to the last mode the vehicle was in before entering Offboard mode
Update
You do not have to publish like this (from the terminal) to get your callbacks to execute. You do, however, need to have something publishing on that topic. What I mean is, a callback is only executed when it receives data. Therefore, if nothing is publishing then callbacks are not executed. That's why you weren't seeing your callback doing anything, there was nothing being published.
I highly recommend that you go through the tutorials to make sure that you understand how the publish and subscribe system works along with the other basics of ROS.