Hi,
I am doing vision-based control and the camera is on the drone facing down.
So the position estimation is in body frame.
I found the topic /mavros/setpoint_velocity/cmd_vel can be used to change the drone's speed but it seems it is in NED frame.
Is there a topic like /mavros/setpoint_velocity/cmd_vel but use body frame?
Or I need to convert my speed setpoint from body frame to NED frame to implement it?
I tried to find something that I can use and I found this code. https://github.com/weiweikong/px4_velocity_control_keyboard/blob/master/src/px4_velocity_control_node.cpp
vs_body_axis.twist.linear.x = vs.twist.linear.x * cos(uavYawENU) + vs.twist.linear.y * sin(uavYawENU);
vs_body_axis.twist.linear.y = vs.twist.linear.x * sin(uavYawENU) - vs.twist.linear.y * cos(uavYawENU);
It seems this is the best solution I could find.
I am not sure if the Yaw is from IMU only or from fusion of IMU and magnetic.
Do you have some comments or ideas about this?
Mavros: 0.17.3
ROS: Indigo
Ubuntu: 14.04
APM:Copter V3.4-dev (fe724032)
bshang2@mechatronics-990:~/simulation/ardupilot/ArduCopter$ roslaunch ardupilot_sitl_gazebo_plugin erlecopter_mark.launch
... logging to /home/bshang2/.ros/log/ca9213bc-89bf-11e7-b657-1803733b65bb/roslaunch-mechatronics-990-28079.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://mechatronics-990:45006/
CLEAR PARAMETERS
PARAMETERS
NODES
/
gazebo (gazebo_ros/gzserver)
gazebo_gui (gazebo_ros/gzclient)
mavros (mavros/mavros_node)
spawn_erlecopter (gazebo_ros/spawn_model)
auto-starting new master
process[master]: started with pid [28094]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to ca9213bc-89bf-11e7-b657-1803733b65bb
process[rosout-1]: started with pid [28107]
started core service [/rosout]
process[mavros-2]: started with pid [28126]
process[spawn_erlecopter-3]: started with pid [28133]
process[gazebo-4]: started with pid [28134]
process[gazebo_gui-5]: started with pid [28151]
spawn_model script started
[gazebo-4] process has died [pid 28134, exit code 255, cmd /home/bshang2/simulation/ros_catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/gzserver -u -e ode /home/bshang2/simulation/ros_catkin_ws/src/ardupilot_sitl_gazebo_plugin/ardupilot_sitl_gazebo_plugin/worlds/mark_world/mark.world __name:=gazebo __log:=/home/bshang2/.ros/log/ca9213bc-89bf-11e7-b657-1803733b65bb/gazebo-4.log].
log file: /home/bshang2/.ros/log/ca9213bc-89bf-11e7-b657-1803733b65bb/gazebo-4.log
[INFO] [WallTime: 1503684250.172508] [0.000000] Loading model xml from ros parameter
[INFO] [WallTime: 1503684250.176886] [0.000000] Waiting for service /gazebo/spawn_urdf_model
[gazebo_gui-5] process has died [pid 28151, exit code 255, cmd /home/bshang2/simulation/ros_catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/gzclient __name:=gazebo_gui __log:=/home/bshang2/.ros/log/ca9213bc-89bf-11e7-b657-1803733b65bb/gazebo_gui-5.log].
log file: /home/bshang2/.ros/log/ca9213bc-89bf-11e7-b657-1803733b65bb/gazebo_gui-5.log
^C[spawn_erlecopter-3] killing on exit
[mavros-2] killing on exit
Traceback (most recent call last):
File "/home/bshang2/simulation/ros_catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model", line 301, in
sm.callSpawnService()
File "/home/bshang2/simulation/ros_catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model", line 267, in callSpawnService
initial_pose, self.reference_frame, self.gazebo_namespace)
File "/home/bshang2/simulation/ros_catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/src/gazebo_ros/gazebo_interface.py", line 28, in spawn_urdf_model_client
rospy.wait_for_service(gazebo_namespace+'/spawn_urdf_model')
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 159, in wait_for_service
raise ROSInterruptException("rospy shutdown")
rospy.exceptions.ROSInterruptException: rospy shutdown
^C[rosout-1] killing on exit
^C[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done
bshang2@mechatronics-990:~/simulation/ardupilot/ArduCopter$ roslaunch ardupilot_sitl_gazebo_plugin erlecopter_mark.launch
... logging to /home/bshang2/.ros/log/e483c856-89bf-11e7-bb61-1803733b65bb/roslaunch-mechatronics-990-28603.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://mechatronics-990:41224/
CLEAR PARAMETERS
PARAMETERS
NODES
/
gazebo (gazebo_ros/gzserver)
gazebo_gui (gazebo_ros/gzclient)
mavros (mavros/mavros_node)
spawn_erlecopter (gazebo_ros/spawn_model)
auto-starting new master
process[master]: started with pid [28618]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to e483c856-89bf-11e7-bb61-1803733b65bb
process[rosout-1]: started with pid [28631]
started core service [/rosout]
process[mavros-2]: started with pid [28656]
process[spawn_erlecopter-3]: started with pid [28657]
process[gazebo-4]: started with pid [28674]
process[gazebo_gui-5]: started with pid [28678]
spawn_model script started
[INFO] [WallTime: 1503684293.653120] [0.000000] Loading model xml from ros parameter
[INFO] [WallTime: 1503684293.657344] [0.000000] Waiting for service /gazebo/spawn_urdf_model
[INFO] [WallTime: 1503684294.260952] [0.047500] Calling service /gazebo/spawn_urdf_model
[INFO] [WallTime: 1503684294.855628] [0.445000] Spawn status: SpawnModel: Successfully spawned model
[spawn_erlecopter-3] process has finished cleanly
log file: /home/bshang2/.ros/log/e483c856-89bf-11e7-bb61-1803733b65bb/spawn_erlecopter-3*.log
bshang2@mechatronics-990:~/simulation/ardupilot/ArduCopter$ rostopic echo -n1 /diagnostics
header:
seq: 6456
stamp:
secs: 6817
nsecs: 500000000
frame_id: ''
status:
bshang2@mechatronics-990:~/simulation/ardupilot/ArduCopter$ rosrun mavros checkid
OK. I got messages from 1:1.
Received 1231 messages, from 1 addresses
sys:comp list of messages
1:1 0, 1, 2, 136, 152, 150, 24, 27, 29, 30, 32, 33, 162, 163, 164, 165, 42, 173, 178, 62, 193, 74, 35, 36, 241, 116
Hey there,
You can use the setpoint_raw.
http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.setpoint_raw
On the target setpoint, you can change the coordinate frame.
http://docs.ros.org/api/mavros_msgs/html/msg/PositionTarget.html
For setpoint_velocity
, I will add a fix which will allows choosing between the LOCAL_NED
and the BODY_NED
, since it currently is defaulted to LOCAL_NED
(https://github.com/mavlink/mavros/blob/master/mavros/src/plugins/setpoint_velocity.cpp#L81). In the mean time, you can use setpoint_raw
and set the coordinate_frame
to FRAME_BODY_NED
or MAV_FRAME::BODY_NED
(both should work).
Thanks @AlexisTM and @TSC21 Your reply is helpful. I will try that later.
@TSC21 @AlexisTM Thanks for your help! I can control the velocity in body frame now. Video is recorded: https://www.youtube.com/watch?v=dyUQfFYX3pk&feature=youtu.be
rostopic pub /mavros/setpoint_raw/local mavros_msgs/PositionTarget '{header: {stamp: now, frame_id: "world"}, coordinate_frame: 8, type_mask: 3527, velocity: {x: 0.1, y: 0, z: 0}}' -r 10
@cnpcshangbo good to know
hi @cnpcshangbo, thank you for the video.
I post this to help others clearing a confusion that I had.
Even though the frame mask is FRAME_BODY_NED = 8
, the ROS command should still be in ENU . The ENU -> NED conversion is taken care by mavros.
In fact, from the video, the behavior is:
Hi Hoang,
Thank you for your clarification.
Sorry to hear that it took you so long time.
Your efforts help other.
Thanks
Bo
Hoang Minh Chung notifications@github.com于2018年8月17日 周五上午11:09写道:
hi @cnpcshangbo https://github.com/cnpcshangbo, thank you for the video.
I post this to help others clearing a confusion that I had.
Even though the frame mask is "FRAME_BODY_NED = 8", the ROS command
should still be in ENU . The ENU -> NED conversion will be done by
mavros.
In fact, from the video, the behavior is:
- x = 0.1 ---> To the right
- y = 0.1 ---> Forward
Obviously it is still in ENU. However, this confusion cost me a week
of pulling hair...—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mavlink/mavros/issues/792#issuecomment-413745084, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEm3NdefOViosyJKxQlf2h0ZweC8lO6uks5uRjP9gaJpZM4PDCb2
.
Isn't it supposed to be x forward and y to the left for BODY and x to East, y to North in the map frame @Nuno?
So am I correct that we actually have 3 conventions here:
1) NED: PX4 onboard estimation and control
2) ENU: standard input format for mavros command messages
3) NWU: Typical coordinate system in ROS
No. There's no NWU in ROS.
http://www.ros.org/reps/rep-0103.html
@AlexisTM north or east should no be used to specify body conventions, but rather orientations like front, left.
Okay. But if I am not wrong, I think we still have 3 conventions?
1) NED: Onboard control
2) Right-Forward-Up: How mavros understands raw (velocity) setpoints
3) Forward-Left-Up: ROS convention
@hmchung We are using velocity setpoints within the map frame and it is ENU (ROS convention)
Note that there should be only 2 conventions! NED on the Pixhawk and ENU: anything you do on ROS.
Forward-Left-Up (FLU) is the ROS convention for the body frame. East-North-Up (ENU) is the ROS convention for the local/word frame.
Most helpful comment
For
setpoint_velocity
, I will add a fix which will allows choosing between theLOCAL_NED
and theBODY_NED
, since it currently is defaulted toLOCAL_NED
(https://github.com/mavlink/mavros/blob/master/mavros/src/plugins/setpoint_velocity.cpp#L81). In the mean time, you can usesetpoint_raw
and set thecoordinate_frame
toFRAME_BODY_NED
orMAV_FRAME::BODY_NED
(both should work).