Closed romaster93 closed 2 years ago
Follow these commands as shown in README. It is not connected as you've not started the simulator. Before running the steps below you can try to run px4 with gazebo using _make px4_sitl gazebo_
Terminal-1 : cd PX4-Autopilot && sudo no_sim=1 make px4_sitl_gazebo
Terminal-2 : cd PX4-Autpilot && source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default && roslaunch gazebo_ros empty_world.launch (set your world file as required). On the gazebo window, select iris_depth_camera from the left panel.
Terminal-3 : cd catkin_ws && roslaunch FastPlannerOctomap MappingSim.launch (give goal location using 2D Nav Goal option)
Terminal-4 : rosrun FastPlannerOctomap Planner (or noYawPlanner if you want to plan the trajectory keeping the heading or yaw of the drone fixed). For the startOver option select either 1 or 0. Refer to the source code (FastPlannerOctomap/src/kinodynamic_astar.cpp and Planner.cpp for details). Also give the height (in metres) of the goal location when prompted.
Terminal-5 : rosrun FastPlannerOctomap Controller
hello !!
I ran it according to the readme file. But the drone keeps descending.
and If I don't run qgroundcontrol the drone will not takeoff.
Please refer to the link.
Yes I see this issue. I also had this. Forgot to mention this in the Readme. What you can do is to not run the takeoff command. In the controller code, do arming before passing the waypoints. That way it'll start in offboard mode
@deepak-1530 Does this mean that if I directly input and execute a waypoint without entering the takeoff command in advance, arming and takeoff are automatically performed?
You'll have to write the command for arming in the offboard control script itself. When the drone starts, it would start moving towards the current target point it receives.
You can arm it like this
mavros_msgs::SetMode offb_set_mode;
offb_set_mode.request.custom_mode = "OFFBOARD";
mavros_msgs::CommandBool arm_cmd;
arm_cmd.request.value = true;
geometry_msgs::PoseStamped pose;
pose.pose.position.x = 0;
pose.pose.position.y = 0;
pose.pose.position.z = 0;
//send a few setpoints before starting
for(int i = 100; ros::ok() && i > 0; --i)
{
chatter_pub.publish(pose);
ros::spinOnce();
rate.sleep();
}
if( set_mode_client.call(offb_set_mode) &&
offb_set_mode.response.mode_sent)
{
ROS_INFO("Offboard enabled");
}
if( arming_client.call(arm_cmd) &&
arm_cmd.response.success)
{
ROS_INFO("Vehicle armed");
}
@deepak-1530
thanks to reply
it already have that code in controller.cpp
if(trajectoryUpdated)
{
geometry_msgs::PoseStamped initPose;
if(count==0)
{
std::cout<<"Controller started ... "<<std::endl;
initPose.pose.position.x = 0;
initPose.pose.position.y = 0;
initPose.pose.position.z = 0;
for(int i = 0; i<100 && ros::ok(); i++)
{
wp_pub.publish(initPose);
ros::spinOnce();
rate.sleep();
}
mavros_msgs::SetMode offb_set_mode;
offb_set_mode.request.custom_mode = "OFFBOARD";
mavros_msgs::CommandBool arm_cmd;
arm_cmd.request.value = true;
/** set mode to offboard **/
if(set_mode_client.call(offb_set_mode) &&
offb_set_mode.response.mode_sent)
{
ROS_INFO("Offboard enabled");
}
if( arming_client.call(arm_cmd) &&
arm_cmd.response.success)
{
ROS_INFO("Vehicle armed");
}
}
so i run a code but px4 said failsafe mode deactivated....
Can you tell me which version of px4 you used?
SITL COMMAND: "/home/cho/PX4-Autopilot/build/px4_sitl_default/bin/px4" "/home/cho/PX4-Autopilot/build/px4_sitl_default"/etc -s etc/init.d-posix/rcS -t "/home/cho/PX4-Autopilot"/test_data Creating symlink /home/cho/PX4-Autopilot/build/px4_sitl_default/etc -> /home/cho/PX4-Autopilot/build/px4_sitl_default/t
[0__ | \ \ \ / / / | | |_/ / \ V / / /| | | / / \ / /| | | | / /^\ \ \ | _| \/ \/ |_/
px4 starting.
INFO [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0 INFO [init] found model autostart file as SYS_AUTOSTART=10016 INFO [param] selected parameter default file eeprom/parameters_10016 INFO [parameters] BSON document size 291 bytes, decoded 291 bytes (INT32:12, FLOAT:3) [param] Loaded: eeprom/parameters_10016 INFO [dataman] data manager file './dataman' size is 7866640 bytes PX4 SIM HOST: localhost INFO [simulator] Waiting for simulator to accept connection on TCP port 4560
My px4 is not connected.
thanks