CHH3213 / MyNote

这是随手记录在学习过程中碰到的问题解决方案
0 stars 0 forks source link

ubuntu_CHH3213 #2

Open CHH3213 opened 3 years ago

CHH3213 commented 3 years ago

APM问题总结

1.mavros话题:

setpoint_raw/attitude 使用 NED 作为坐标系,而 setpoint_attitude/attitude 主题使用 ENU

2.setpoint_raw/attitude可以设置姿态和推力(0,1), setpoint_attitude/attitude可以设置姿态和位置;推力设置为setpoint_attitude/thrust

3.solidworks导出的模型为黑色的

只需要将导出后的sdf文件中的material标签中的以下代码注释掉(即文中已经注释掉的部分):

          <material>
<!--            <shader type='pixel'>-->
<!--              <normal_map>__default__</normal_map>-->
<!--            </shader>-->
            <script>
              <name>Gazebo/Red</name>
              <uri>file://media/materials/scripts/gazebo.material</uri>
<!--              <name>ModelPreview_1::base_link::base_link_visual_MATERIAL_</name>-->
<!--              <uri>__default__</uri>-->
            </script>
<!--            <ambient>0 0 0 1</ambient>-->
<!--            <diffuse>0 0 0 1</diffuse>-->
<!--            <specular>0 0 0 1</specular>-->
<!--            <emissive>0 0 0 1</emissive>-->
          </material>
<!--          <transparency>0</transparency>-->
<!--          <cast_shadows>1</cast_shadows>-->

4.模型的转动惯量设置挺重要的

这是一个转动惯量等物理量的在线计算网站

5.gazebo中模型的摩擦:

The sdf documentation says it should be in range [0..1]. we can see that anything over 1.0 is treated as 1.0 (infinite friction).

6.gazebo仿真频率问题:设置real_time_update_rate

    <physics type='ode'>
     <max_step_size>0.01</max_step_size>
     <real_time_factor>1</real_time_factor>
    <real_time_update_rate>100</real_time_update_rate>
     <gravity>0 0 -9.81</gravity>
     <!-- <gravity>0 0 0</gravity> -->
    </physics>
这个参数指定了每个物理更新步骤的持续时间(秒)。 该参数以赫兹为单位指定每秒尝试的物理更新次数。如果这个数字设为0,它就会尽可能快地运行。注意,的乘积表示 the target ,即模拟时间与实时的比率。

7.gazebo关闭仿真界面等问题

8.Ardupilot飞控姿态角与姿态角速度控制过程分析(超长篇)

9.如何修改遥控器输入:
横滚命令: rc 1  1200
俯仰命令: rc 2  1200
油门命令: rc 3   1200
偏航命令: rc 4    1600

10.模式切换不成功,是因为没有给定油门值,所以一切换就会掉下来。

arm throttle
rc 3 1800

1800 为油门值,1500油门值中立。

11.术语

FCS(Flight Control System)飞行控制系统:与FCU相区别,FCS是包含FCU以及其它硬件、软件、算法的系统集合。

FCU(Flight Control Unit)飞行控制单元:接收并处理从接收机发来的遥控器信号;接收并处理传感器发来的反馈信号;通过相应算法得出机体信息;通过相应算法结合机体信息得出控制输出量;将控制输出量给出到执行器部分的软件与硬件的结合。

12.HIL Control

硬件在环仿真(Hardware-in-the-loop simulation, HiLHIL)

13.Ardupilot添加一个新模式全攻略,以Copter为例

14./mavros/actuator_control 没有订阅话题

将apm.launch中的blacklist注释掉

15. 将模型固定在地面

在相应的模型里,比如logger0里面,加入:

<joint name='fixing_to_ground' type='fixed'>
    <parent>world</parent>
    <child>logger0_chassis</child>
    <pose frame=''>0 0 -0.49 0 -0 0</pose>
</joint>

或者,将对应模型的<static>设置为true(1),就不会移动了,如果希望模型可移动,请将标签设置为 false(0)。

<static>1</static>

16.使用pwm波控制每个电机

详情请看脚本文件夹:bash

17.插件订阅的问题

注意subscriber的缓存队列的大小,会影响回调结果,这与ROS的回调机制相关,ROS在发生回调是会将所有队列中的消息分别送往回调函数中,因此如果队列未被及时更新,可能出现多次重复响应,因此建议设置为1,或者慎重考虑下运行频率相关。

18.ros掉包问题

当节点初始化放在话题注册前面时,会出现掉包(前面一两个包)的情况.因此将节点初始化放在话题注册后面。

19.gazebo sdf模型下载

模型下载

20.实时画图工具

PlotJuggler

  rosrun plotjuggler plotjuggler

21.RuntimeError: Variable -= value not supported问题

如果报-=不支持的话,那就不要写成-=,改成x=x-这种形式,如:

x -= 0.01 * grads
---
===>
x = x- 0.01*grads

+=同理。

当然也可以考虑assign_sub(减去一个数)or assign_add(加上一个数)方法。

如变成:

x.assign_sub(0.01*grads)
CHH3213 commented 3 years ago

APM模式选择

// Auto Pilot Modes enumeration
enum class Number : uint8_t {
    STABILIZE =     0,  // manual airframe angle with manual throttle
    ACRO =          1,  // manual body-frame angular rate with manual throttle
    ALT_HOLD =      2,  // manual airframe angle with automatic throttle
    AUTO =          3,  // fully automatic waypoint control using mission commands
    GUIDED =        4,  // fully automatic fly to coordinate or fly at velocity/direction using GCS immediate commands
    LOITER =        5,  // automatic horizontal acceleration with automatic throttle
    RTL =           6,  // automatic return to launching point
    CIRCLE =        7,  // automatic circular flight with automatic throttle
    LAND =          9,  // automatic landing with horizontal position control
    DRIFT =        11,  // semi-automous position, yaw and throttle control
    SPORT =        13,  // manual earth-frame angular rate control with manual throttle
    FLIP =         14,  // automatically flip the vehicle on the roll axis
    AUTOTUNE =     15,  // automatically tune the vehicle's roll and pitch gains
    POSHOLD =      16,  // automatic position hold with manual override, with automatic throttle
    BRAKE =        17,  // full-brake using inertial/GPS system, no pilot input
    THROW =        18,  // throw to launch mode using inertial/GPS system, no pilot input
    AVOID_ADSB =   19,  // automatic avoidance of obstacles in the macro scale - e.g. full-sized aircraft
    GUIDED_NOGPS = 20,  // guided mode but only accepts attitude and altitude
    SMART_RTL =    21,  // SMART_RTL returns to home by retracing its steps
    FLOWHOLD  =    22,  // FLOWHOLD holds position with optical flow without rangefinder
    FOLLOW    =    23,  // follow attempts to follow another vehicle or ground station
    ZIGZAG    =    24,  // ZIGZAG mode is able to fly in a zigzag manner with predefined point A and point B
    SYSTEMID  =    25,  // System ID mode produces automated system identification signals in the controllers
    AUTOROTATE =   26,  // Autonomous autorotation
};

位于:/home/chh3213/ardupilot/ArduCopter/mode.h 14行

CHH3213 commented 3 years ago

ubuntu各种文件夹用途

CHH3213 commented 3 years ago

python数组展平成一列

原来为7行3列:

[[ 0.00000000e+00  0.00000000e+00 -2.69499700e-12]
 [-2.10534030e-01 -3.15565144e+00  6.83704029e+00]
 [-2.13012756e-01  2.83851793e+00  6.81062238e+00]
 [ 4.99991534e+00  4.99929875e+00  5.99999612e-02]
 [-5.00008466e+00  4.99929954e+00  5.99956080e-02]
 [-5.00008463e+00 -5.00070098e+00  5.99999612e-02]
 [ 4.99991537e+00 -5.00070019e+00  5.99956080e-02]]

使用展平命令:

np.array(train_data['pos'][0]).flatten()

变成1行21列:

[ 0.00000000e+00  0.00000000e+00 -2.69499700e-12 -2.10534030e-01
 -3.15565144e+00  6.83704029e+00 -2.13012756e-01  2.83851793e+00
  6.81062238e+00  4.99991534e+00  4.99929875e+00  5.99999612e-02
 -5.00008466e+00  4.99929954e+00  5.99956080e-02 -5.00008463e+00
 -5.00070098e+00  5.99999612e-02  4.99991537e+00 -5.00070019e+00
  5.99956080e-02]
CHH3213 commented 3 years ago

ubuntu20.04网络图标不见方法解决