Skip to content

Commit

Permalink
Merge branch 'master' into mag-consistency-check
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored Aug 2, 2019
2 parents 3c0cae8 + d301c22 commit 75992d3
Show file tree
Hide file tree
Showing 50 changed files with 4,146 additions and 982 deletions.
11 changes: 9 additions & 2 deletions .ci/Jenkinsfile-SITL_tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pipeline {
stage('Build') {
agent {
docker {
image 'px4io/px4-dev-ros-kinetic:2019-03-08'
image 'px4io/px4-dev-ros-kinetic:2019-07-29'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw -e HOME=$WORKSPACE'
}
}
Expand Down Expand Up @@ -93,6 +93,13 @@ pipeline {
vehicle: "iris_obs_avoid",
run_script: "rostest_avoidance_run.sh"
],
[
name: "MC_safe_landing",
test: "mavros_posix_test_safe_landing.test",
mission: "MC_safe_landing",
vehicle: "iris_obs_avoid",
run_script: "rostest_avoidance_run.sh"
],

]

Expand Down Expand Up @@ -123,7 +130,7 @@ def createTestNode(Map test_def) {
return {
node {
cleanWs()
docker.image("px4io/px4-dev-ros-kinetic:2019-03-08").inside('-e HOME=${WORKSPACE}') {
docker.image("px4io/px4-dev-ros-kinetic:2019-07-29").inside('-e HOME=${WORKSPACE}') {
stage(test_def.name) {
def run_script = test_def.get('run_script', 'rostest_px4_run.sh')
def test_ok = true
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ tests_offboard: rostest

tests_avoidance: rostest
@"$(SRC_DIR)"/test/rostest_avoidance_run.sh mavros_posix_test_avoidance.test
@"$(SRC_DIR)"/test/rostest_avoidance_run.sh mavros_posix_test_safe_landing.test

python_coverage:
@mkdir -p "$(SRC_DIR)"/build/python_coverage
Expand Down
2 changes: 1 addition & 1 deletion boards/px4/fmu-v5x/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ px4_add_board(
imu/adis16448
imu/adis16497
#imu # all available imu drivers
# TBD imu/bmi088 - needs bus selection
imu/bmi088
# TBD imu/ism330dlc - needs bus selection
imu/mpu6000
irlock
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"fileType": "Plan",
"geoFence": {
"circles": [
],
"polygons": [
],
"version": 2
},
"groundStation": "QGroundControl",
"mission": {
"cruiseSpeed": 15,
"firmwareType": 12,
"hoverSpeed": 5,
"items": [
{
"AMSLAltAboveTerrain": null,
"Altitude": 18,
"AltitudeMode": 1,
"autoContinue": true,
"command": 22,
"doJumpId": 1,
"frame": 3,
"params": [
15,
0,
0,
null,
47.3977394,
8.5455942,
18
],
"type": "SimpleItem"
},
{
"AMSLAltAboveTerrain": null,
"Altitude": 18,
"AltitudeMode": 1,
"autoContinue": true,
"command": 16,
"doJumpId": 2,
"frame": 3,
"params": [
0,
0,
0,
null,
47.3977394,
8.5456982,
18
],
"type": "SimpleItem"
},
{
"AMSLAltAboveTerrain": null,
"Altitude": 18,
"AltitudeMode": 1,
"autoContinue": true,
"command": 16,
"doJumpId": 3,
"frame": 3,
"params": [
0,
0,
0,
null,
47.3977432,
8.545805,
18
],
"type": "SimpleItem"
},
{
"AMSLAltAboveTerrain": null,
"Altitude": 0,
"AltitudeMode": 1,
"autoContinue": true,
"command": 21,
"doJumpId": 4,
"frame": 3,
"params": [
0,
0,
0,
null,
47.3977432,
8.545804,
0
],
"type": "SimpleItem"
}
],
"plannedHomePosition": [
47.3977419,
8.5455941,
489
],
"vehicleType": 2,
"version": 2
},
"rallyPoints": {
"points": [
],
"version": 2
},
"version": 1
}
2 changes: 1 addition & 1 deletion launch/single_vehicle_spawn.launch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<!-- PX4 SITL -->
<arg unless="$(arg interactive)" name="px4_command_arg1" value=""/>
<arg if="$(arg interactive)" name="px4_command_arg1" value="-d"/>
<node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen" args="$(find px4)/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -i $(arg ID) $(arg px4_command_arg1)">
<node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen" args="$(find px4)/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -i $(arg ID) -w sitl_$(arg vehicle)_$(arg ID) $(arg px4_command_arg1)">
</node>
<!-- spawn vehicle -->
<node name="$(arg vehicle)_$(arg ID)_spawn" output="screen" pkg="gazebo_ros" type="spawn_model" args="-urdf -param rotors_description -model $(arg vehicle)_$(arg ID) -package_to_model -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg R) -P $(arg P) -Y $(arg Y)"/>
Expand Down
2 changes: 1 addition & 1 deletion launch/single_vehicle_spawn_sdf.launch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<!-- PX4 SITL -->
<arg unless="$(arg interactive)" name="px4_command_arg1" value=""/>
<arg if="$(arg interactive)" name="px4_command_arg1" value="-d"/>
<node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen" args="$(find px4)/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -i $(arg ID) $(arg px4_command_arg1)">
<node name="sitl_$(arg ID)" pkg="px4" type="px4" output="screen" args="$(find px4)/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -i $(arg ID) -w sitl_$(arg vehicle)_$(arg ID) $(arg px4_command_arg1)">
</node>
<!-- spawn vehicle -->
<node name="$(arg vehicle)_$(arg ID)_spawn" output="screen" pkg="gazebo_ros" type="spawn_model" args="-sdf -param model_description -model $(arg vehicle)_$(arg ID) -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg R) -P $(arg P) -Y $(arg Y)"/>
Expand Down
2 changes: 1 addition & 1 deletion msg/battery_status.msg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ float32 average_current_a # Battery current average in amperes, -1 if unknown
float32 discharged_mah # Discharged amount in mAh, -1 if unknown
float32 remaining # From 1 to 0, -1 if unknown
float32 scale # Power scaling factor, >= 1, or -1 if unknown
float32 temperature # temperature of the battery
float32 temperature # temperature of the battery. NaN if unknown
int32 cell_count # Number of cells
bool connected # Whether or not a battery is connected, based on a voltage threshold
bool system_source # Whether or not a this battery is the active power source for VDD_5V_IN
Expand Down
18 changes: 9 additions & 9 deletions msg/manual_control_setpoint.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ uint8 SWITCH_POS_NONE = 0 # switch is not mapped
uint8 SWITCH_POS_ON = 1 # switch activated (value = 1)
uint8 SWITCH_POS_MIDDLE = 2 # middle position (value = 0)
uint8 SWITCH_POS_OFF = 3 # switch not activated (value = -1)
int8 MODE_SLOT_NONE = -1 # no mode slot assigned
int8 MODE_SLOT_1 = 0 # mode slot 1 selected
int8 MODE_SLOT_2 = 1 # mode slot 2 selected
int8 MODE_SLOT_3 = 2 # mode slot 3 selected
int8 MODE_SLOT_4 = 3 # mode slot 4 selected
int8 MODE_SLOT_5 = 4 # mode slot 5 selected
int8 MODE_SLOT_6 = 5 # mode slot 6 selected
int8 MODE_SLOT_MAX = 6 # number of slots plus one
uint8 MODE_SLOT_NONE = 0 # no mode slot assigned
uint8 MODE_SLOT_1 = 1 # mode slot 1 selected
uint8 MODE_SLOT_2 = 2 # mode slot 2 selected
uint8 MODE_SLOT_3 = 3 # mode slot 3 selected
uint8 MODE_SLOT_4 = 4 # mode slot 4 selected
uint8 MODE_SLOT_5 = 5 # mode slot 5 selected
uint8 MODE_SLOT_6 = 6 # mode slot 6 selected
uint8 MODE_SLOT_NUM = 6 # number of slots
uint8 SOURCE_RC = 1 # radio control
uint8 SOURCE_MAVLINK_0 = 2 # mavlink instance 0
uint8 SOURCE_MAVLINK_1 = 3 # mavlink instance 1
Expand Down Expand Up @@ -61,7 +61,7 @@ uint8 kill_switch # throttle kill: _NORMAL_, KILL
uint8 arm_switch # arm/disarm switch: _DISARMED_, ARMED
uint8 transition_switch # VTOL transition switch: _HOVER, FORWARD_FLIGHT
uint8 gear_switch # landing gear switch: _DOWN_, UP
int8 mode_slot # the slot a specific model selector is in
uint8 mode_slot # the slot a specific model selector is in
uint8 data_source # where this input is coming from
uint8 stab_switch # stabilize switch (only relevant for fixed wings, optional): _MANUAL, STABILIZED
uint8 man_switch # manual switch (only relevant for fixed wings, optional): _STABILIZED_, MANUAL
57 changes: 47 additions & 10 deletions platforms/posix/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static bool dir_exists(const std::string &path);
static bool file_exists(const std::string &name);
static std::string file_basename(std::string const &pathname);
static std::string pwd();
static int change_directory(const std::string &directory);


#ifdef __PX4_SITL_MAIN_OVERRIDE
Expand Down Expand Up @@ -181,13 +182,14 @@ int main(int argc, char **argv)
std::string data_path;
std::string commands_file = "etc/init.d/rcS";
std::string test_data_path;
std::string working_directory;
int instance = 0;

int myoptind = 1;
int ch;
const char *myoptarg = nullptr;

while ((ch = px4_getopt(argc, argv, "hdt:s:i:", &myoptind, &myoptarg)) != EOF) {
while ((ch = px4_getopt(argc, argv, "hdt:s:i:w:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'h':
print_usage();
Expand All @@ -209,6 +211,10 @@ int main(int argc, char **argv)
instance = strtoul(myoptarg, nullptr, 10);
break;

case 'w':
working_directory = myoptarg;
break;

default:
PX4_ERR("unrecognized flag");
print_usage();
Expand All @@ -218,6 +224,15 @@ int main(int argc, char **argv)

PX4_DEBUG("instance: %i", instance);

// change the CWD befre setting up links and other directories
if (!working_directory.empty()) {
int ret = change_directory(working_directory);

if (ret != PX4_OK) {
return ret;
}
}

if (myoptind < argc) {
std::string optional_arg = argv[myoptind];

Expand All @@ -232,7 +247,6 @@ int main(int argc, char **argv)
return -1;
}


int ret = create_symlinks_if_needed(data_path);

if (ret != PX4_OK) {
Expand Down Expand Up @@ -383,7 +397,6 @@ int create_dirs()
return PX4_OK;
}


void register_sig_handler()
{
// SIGINT
Expand Down Expand Up @@ -544,14 +557,15 @@ void print_usage()
{
printf("Usage for Server/daemon process: \n");
printf("\n");
printf(" px4 [-h|-d] [-s <startup_file>] [-t <test_data_directory>] [<rootfs_directory>] [-i <instance>]\n");
printf(" px4 [-h|-d] [-s <startup_file>] [-t <test_data_directory>] [<rootfs_directory>] [-i <instance>] [-w <working_directory>]\n");
printf("\n");
printf(" -s <startup_file> shell script to be used as startup (default=etc/init.d/rcS)\n");
printf(" <rootfs_directory> directory where startup files and mixers are located,\n");
printf(" (if not given, CWD is used)\n");
printf(" -i <instance> px4 instance id to run multiple instances [0...N], default=0\n");
printf(" -h help/usage information\n");
printf(" -d daemon mode, don't start pxh shell\n");
printf(" -s <startup_file> shell script to be used as startup (default=etc/init.d/rcS)\n");
printf(" <rootfs_directory> directory where startup files and mixers are located,\n");
printf(" (if not given, CWD is used)\n");
printf(" -i <instance> px4 instance id to run multiple instances [0...N], default=0\n");
printf(" -w <working_directory> directory to change to\n");
printf(" -h help/usage information\n");
printf(" -d daemon mode, don't start pxh shell\n");
printf("\n");
printf("Usage for client: \n");
printf("\n");
Expand Down Expand Up @@ -626,3 +640,26 @@ std::string pwd()
char temp[PATH_MAX];
return (getcwd(temp, PATH_MAX) ? std::string(temp) : std::string(""));
}

int change_directory(const std::string &directory)
{
// create directory
if (!dir_exists(directory)) {
int ret = mkdir(directory.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);

if (ret == -1) {
PX4_ERR("Error creating directory: %s (%s)", directory.c_str(), strerror(errno));
return -1;
}
}

// change directory
int ret = chdir(directory.c_str());

if (ret == -1) {
PX4_ERR("Error changing current path to: %s (%s)", directory.c_str(), strerror(errno));
return -1;
}

return PX4_OK;
}
Loading

0 comments on commit 75992d3

Please sign in to comment.