2015-07-20 89 views
-3

我目前已经开始使用PX4自动驾驶仪,并且正在通过其中一个示例应用程序,并试图编译固件并将其上载到Pixhawk。PX4自动驾驶仪:“初始化从指针开始整型而不投射”

的问题是,它加载失败给我的这些错误:

化妆[2]:* [px4_simple_app.co]错误1请[1]:* [/ C/PX4 /Firmware/Build/px4fmu-v2_default.build//c/px4/Firmware/src/examples/px4_simple_app/module.pre.o] 错误2 make [1]:离开目录 `/ c/px4/Firmware/Build /px4fmu-v2_default.build'make:*** [/c/px4/Firmware/Build/px4fmu-v2_default.build/firmware.px4]错误2

我不知道这些意味着什么,但检查程式码,它给了我这个错误在一定行:

初始化将指针整数,未作铸

从这一行:

int att_pub_fd = orb_advertise(ORB_ID(vehicle_attitude), &att); 

我不知道如何解决这个问题。有人能给我一些帮助吗?

这是代码的其余部分:

/** 
* @file px4_simple_app.c 
* Minimal application example for PX4 autopilot 
*/ 

#include <string.h> 
#include <nuttx/config.h> 
#include <unistd.h> 
#include <stdio.h> 
#include <poll.h> 

#include <uORB/uORB.h> 
#include <uORB/topics/sensor_combined.h> 
#include <uORB/topics/vehicle_attitude.h> 

__EXPORT int px4_simple_app_main(int argc, char *argv[]); 

int px4_simple_app_main(int argc, char *argv[]) 
{ 
printf("Hello Sky!\n"); 

/* subscribe to sensor_combined topic */ 
int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined)); 
orb_set_interval(sensor_sub_fd, 1000); 

/* advertise attitude topic */ 
struct vehicle_attitude_s att; 
memset(&att, 0, sizeof(att)); 
int att_pub_fd = orb_advertise(ORB_ID(vehicle_attitude), &att); 

/* one could wait for multiple topics with this technique, just using one here */ 
struct pollfd fds[] = { 
    { .fd = sensor_sub_fd, .events = POLLIN }, 
    /* there could be more file descriptors here, in the form like: 
    * { .fd = other_sub_fd, .events = POLLIN }, 
    */ 
}; 

int error_counter = 0; 

while (true) { 
    /* wait for sensor update of 1 file descriptor for 1000 ms (1 second) */ 
    int poll_ret = poll(fds, 1, 1000); 

    /* handle the poll result */ 
    if (poll_ret == 0) { 
     /* this means none of our providers is giving us data */ 
     printf("[px4_simple_app] Got no data within a second\n"); 
    } else if (poll_ret < 0) { 
     /* this is seriously bad - should be an emergency */ 
     if (error_counter < 10 || error_counter % 50 == 0) { 
      /* use a counter to prevent flooding (and slowing us down) */ 
      printf("[px4_simple_app] ERROR return value from poll(): %d\n" 
       , poll_ret); 
     } 
     error_counter++; 
    } else { 

     if (fds[0].revents & POLLIN) { 
      /* obtained data for the first file descriptor */ 
      struct sensor_combined_s raw; 
      /* copy sensors raw data into local buffer */ 
      orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw); 
      printf("[px4_simple_app] Accelerometer:\t%8.4f\t%8.4f\t%8.4f\n", 
       (double)raw.accelerometer_m_s2[0], 
       (double)raw.accelerometer_m_s2[1], 
       (double)raw.accelerometer_m_s2[2]); 

      /* set att and publish this information for other apps */ 
      att.roll = raw.accelerometer_m_s2[0]; 
      att.pitch = raw.accelerometer_m_s2[1]; 
      att.yaw = raw.accelerometer_m_s2[2]; 
      orb_publish(ORB_ID(vehicle_attitude), att_pub_fd, &att); 
     } 
     /* there could be more file descriptors here, in the form like: 
     * if (fds[1..n].revents & POLLIN) {} 
     */ 
    } 
} 

return 0; 
} 
+1

Google又下降了吗?它没有给你一个单一的有用的暗示该错误消息? – John3136

+1

是否有任何理由不添加C#和Objective-C标签?如果我错误地删除了C++标记,请重新添加,但删除C标记。所有这些都是**不同的**语言。 – Olaf

回答

0

功能

orb_advertise(ORB_ID(vehicle_attitude), &att) 

返回一个指针,且将其分配给一个int。我不知道你要做什么,但如果它指向一个整数比你需要取消引用指针。