@Zachary-Lowell-0 Would I need to wipe the drone and install the new build on to it? I also tried building your branch but I'm unsure about the location as where to put it, such as in /home/root, /opt/, etc., or if I need to use a specific build command other than "colcon build." Would you be able to clarify this? Thanks again for your help!
Posts made by GlennTee
-
RE: ( VOXL2 PX4 ROS2) MPA to ROS2 for Battery Voltage & Problems
-
RE: ( VOXL2 PX4 ROS2) MPA to ROS2 for Battery Voltage & Problems
@Zachary-Lowell-0 Hello. I just tried what you mentioned and I've had no luck so far. Below is my terminal window where I tried running both commands after sourcing.
-
( VOXL2 PX4 ROS2) MPA to ROS2 for Battery Voltage & Problems
Hello. I'm attempting to try and obtain the battery voltage through code for a project I am working on where I want the drone to perform different operations based on whether the battery is low. One idea was to take the MPA battery voltage data found from doing "voxl-inspect-battery" and to send it to ROS2 to be read and obtained through there. However, I keep experiencing what appears to be syntax errors whenever I try to run "ros2 launch voxl_mpa_to_ros2 voxl_mpa_to_ros2.launch" and it shows that there is no executable found whenever I run "ros2 run voxl_mpa_to_ros2 voxl_mpa_to_ros2," and with multiple files of the same name I'm not exactly sure which one to chmod. Would anyone know anything about resolving this? I am urgently seeking a fix to this. Below is the aforementioned launch file:
<?xml version="1.0"?>
<!--
/****************************************************************************- Copyright 2023 Modal AI
- Complete MPA launch file exposes all node params as arguments
****************************************************************************/
-->
<launch>
<!-- start mpa node -->
<node name="voxl_mpa_to_ros_node2" type="voxl_mpa_to_ros_node2" pkg="voxl_mpa_to_ros2" output="screen" /></launch>
-
PX4 VOXL2 ROS2 Starling Reading Battery Voltage Through Code
Hello. I'm trying to obtain the voltage of the battery on the Starling drone I've been working with it as I want to use it in my Python program to tell the drone where to go based on whether the battery is high or low in charge. I've been having trouble doing this and I was wondering if there is any easy way to go about doing this. I don't seem to have a "battery_status" topic when I do "ros2 topic list," but I do see a BatteryStatus.msg file within px4_msgs, a package I am using. Any help or insight would be greatly appreciated.
-
RE: VOXL2 ROS2 Starling Code Inconsistencies
@Zachary-Lowell-0 Thank you so much, I will try that out!
-
RE: VOXL2 ROS2 Starling Code Inconsistencies
I also was wondering if there also a way to read the battery voltage? In my case, I want to be able to read the battery voltage in my code in able to tell the drone to do specific things based on if the voltage is high or low.
-
RE: VOXL2 ROS2 Starling Code Inconsistencies
@Zachary-Lowell-0 I do have another question: would you happen to know of any resources or examples involving April Tag detection and alignment using the VOXL2 ROS2 PX4 Starling? My goal is to try to use my drone to detect an April Tag, align with it, and land on it. Preferably, I would like to do this in Python if possible.
-
RE: VOXL2 ROS2 Starling Code Inconsistencies
@Zachary-Lowell-0 Thank you so much, this appears to have fixed it! I'm now able to consistently run and exit the program cleanly.
-
VOXL2 ROS2 Starling Code Inconsistencies
Hello, I'm running the PX4 ROS2 offboard control example from https://docs.px4.io/main/en/ros2/offboard_control.html#foxy and am having some inconsistent behavior. When I run the program, the drone arms, takes off, and lands as expected. However, during subsequent runs, the drone never arms (The props never spin at all), but the program still continues running as indicated by the print statements that show up. Sometimes, if I close the terminal and run the program again in a new terminal, this problem is fixed as the drone will arm and fly most times, but not always. Am I missing something that cleanly shuts down after running? I'm running the code shown below:
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from rclpy.qos import QoSProfile, ReliabilityPolicy, HistoryPolicy, DurabilityPolicy
from px4_msgs.msg import OffboardControlMode, TrajectorySetpoint, VehicleCommand, VehicleLocalPosition, VehicleStatus
import time
import mathclass OffboardControl(Node):
"""Node for controlling a vehicle in offboard mode."""def __init__(self) -> None: super().__init__('offboard_control_takeoff_and_land') # Configure QoS profile for publishing and subscribing qos_profile = QoSProfile( reliability=ReliabilityPolicy.BEST_EFFORT, durability=DurabilityPolicy.TRANSIENT_LOCAL, history=HistoryPolicy.KEEP_LAST, depth=1 ) # Create publishers self.offboard_control_mode_publisher = self.create_publisher( OffboardControlMode, '/fmu/in/offboard_control_mode', qos_profile) self.trajectory_setpoint_publisher = self.create_publisher( TrajectorySetpoint, '/fmu/in/trajectory_setpoint', qos_profile) self.vehicle_command_publisher = self.create_publisher( VehicleCommand, '/fmu/in/vehicle_command', qos_profile) # Create subscribers self.vehicle_local_position_subscriber = self.create_subscription( VehicleLocalPosition, '/fmu/out/vehicle_local_position', self.vehicle_local_position_callback, qos_profile) self.vehicle_status_subscriber = self.create_subscription( VehicleStatus, '/fmu/out/vehicle_status', self.vehicle_status_callback, qos_profile) # Initialize variables self.offboard_setpoint_counter = 0 self.vehicle_local_position = VehicleLocalPosition() self.vehicle_status = VehicleStatus() self.takeoff_height = -1.0 # Create a timer to publish control commands self.timer = self.create_timer(0.1, self.timer_callback) def vehicle_local_position_callback(self, vehicle_local_position): """Callback function for vehicle_local_position topic subscriber.""" self.vehicle_local_position = vehicle_local_position def vehicle_status_callback(self, vehicle_status): """Callback function for vehicle_status topic subscriber.""" self.vehicle_status = vehicle_status def arm(self): """Send an arm command to the vehicle.""" self.publish_vehicle_command( VehicleCommand.VEHICLE_CMD_COMPONENT_ARM_DISARM, param1=1.0) self.get_logger().info('Arm command sent') def disarm(self): """Send a disarm command to the vehicle.""" self.publish_vehicle_command( VehicleCommand.VEHICLE_CMD_COMPONENT_ARM_DISARM, param1=0.0) self.get_logger().info('Disarm command sent') def engage_offboard_mode(self): """Switch to offboard mode.""" self.publish_vehicle_command( VehicleCommand.VEHICLE_CMD_DO_SET_MODE, param1=1.0, param2=6.0) self.get_logger().info("Switching to offboard mode") def land(self): """Switch to land mode.""" self.publish_vehicle_command(VehicleCommand.VEHICLE_CMD_NAV_LAND) self.get_logger().info("Switching to land mode") def publish_offboard_control_heartbeat_signal(self): """Publish the offboard control mode.""" msg = OffboardControlMode() msg.position = True msg.velocity = False msg.acceleration = False msg.attitude = False msg.body_rate = False msg.timestamp = int(self.get_clock().now().nanoseconds / 1000) self.offboard_control_mode_publisher.publish(msg) def publish_position_setpoint(self, x: float, y: float, z: float): """Publish the trajectory setpoint.""" msg = TrajectorySetpoint() msg.position = [x, y, z] msg.yaw = 1.57079 # (90 degree) msg.timestamp = int(self.get_clock().now().nanoseconds / 1000) self.trajectory_setpoint_publisher.publish(msg) self.get_logger().info(f"Publishing position setpoints {[x, y, z]}") def publish_vehicle_command(self, command, **params) -> None: """Publish a vehicle command.""" msg = VehicleCommand() msg.command = command msg.param1 = params.get("param1", 0.0) msg.param2 = params.get("param2", 0.0) msg.param3 = params.get("param3", 0.0) msg.param4 = params.get("param4", 0.0) msg.param5 = params.get("param5", 0.0) msg.param6 = params.get("param6", 0.0) msg.param7 = params.get("param7", 0.0) msg.target_system = 1 msg.target_component = 1 msg.source_system = 1 msg.source_component = 1 msg.from_external = True msg.timestamp = int(self.get_clock().now().nanoseconds / 1000) self.vehicle_command_publisher.publish(msg) def timer_callback(self) -> None: """Callback function for the timer.""" self.publish_offboard_control_heartbeat_signal() if self.offboard_setpoint_counter == 10: self.engage_offboard_mode() self.arm() if self.vehicle_local_position.z > self.takeoff_height and self.vehicle_status.nav_state == VehicleStatus.NAVIGATION_STATE_OFFBOARD: self.publish_position_setpoint(0.0, 0.0, self.takeoff_height) elif self.vehicle_local_position.z <= self.takeoff_height: self.land() exit(0) if self.offboard_setpoint_counter < 11: self.offboard_setpoint_counter += 1
def main(args=None) -> None:
print('Starting offboard control node...')
rclpy.init(args=args)
offboard_control = OffboardControl()
rclpy.spin(offboard_control)
offboard_control.destroy_node()
rclpy.shutdown()if name == 'main':
try:
main()
except Exception as e:
print(e) -
RE: ROS2 VOXL2 Deserialization Errors
@teddy-zaremba Thank you so much, using that specific version worked like a charm!
-
RE: ROS2 VOXL2 Deserialization Errors
@Zachary-Lowell-0 Thank you. I just tried using a different SDK version (1.1.2) instead of the one I was originally using (1.1.4) just to see if that would help, but I am still experiencing the same errors. My guess right now is that it is a problem with message definitions within the repository itself.
-
ROS2 VOXL2 Deserialization Errors
Hello,
I'm in the process of trying to run a sample Python program from the PX4 website that allows my Starling drone to enter offboard mode, arm, fly to a specific height, and wait. However, when going to run my program, I experience deserialization errors. I suspect this is due to different definitions involving messages between the subscribers and publishers, but I'm not 100% sure. Would anyone know anything about resolving these specific errors?
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@GlennTee Good news! The program now runs, turns out I needed to add the .py extension to the file name when calling the run command, so it should be "ros2 run px4_ros_com offboard_control.py"
However, we experienced a lot of errors while running. The drone did arm (But only would do every even numbered attempt for some reason), however it did not fly. I'm working now to debug these errors.
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@Zachary-Lowell-0 Hi, the code we are referring to is from an example on the PX4 website, where the drone should engage in offboard mode, arm, ascend a desired height, and wait. The link to that is here: https://docs.px4.io/main/en/ros2/offboard_control.html
We are trying to run this program on our Starling drone, and the line we are running to execute the program is "ros2 run px4_ros_com offboard_control"
With the changes made, we now see that the arm command is being sent to the correct topic, but the drone continues to not arm.
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@teddy-zaremba said in VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program:
voxl-microdds-agent"
This is what I get:
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@teddy-zaremba Hi, I just checked using that command and it appears the agent is enabled, but it is not running.
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
I just ran into another problem where I believe after running "voxl-configure-microdds" again, it seems some of my changes were reset as I noticed "offboard_mode" defaulted back to "figure_eight" while looking in the vision-hub config file. However, I did notice that my changes with the node publishers were not changed.
I thought I have reverted everything to how it was before, but the drone is now back to not flying at all. I also noticed that my list of ros2 topics has also shrunk down as well.
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@Kessie Hi again, we just changed COM_RC_OVERRIDE to allow for overriding offboard mode and we were able to cut the motors while the drone was operating in offboard mode. We modified the PX4 ROS 2 Offboard Control Example code to only enable offboard mode and arm the drone, but we noticed that once the drone armed, it had a lot of throttle. I'm guessing there is a setting maybe in QGroundControl to modify the throttle somehow, or is there another way to fix this?
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@Kessie Thank you. I'm not sure where I changed the prefix, but I can try to find it.
-
RE: VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program
@teddy-zaremba Sorry for the late reply, I've already run both of those commands in that order. This is what comes up when I run "ros2 topic list"