Skip to content

Instantly share code, notes, and snippets.

def on_new_messages(self, messages):
''' [Optional] Called according to the execution mode of the block.
Parameters
----------
messages : dict
A dictionary of the port keys and the values of the incoming messages.
'''
bboxes = messages['bboxes'].bboxes #Bounding boxes
#!/usr/bin/env python
from std_msgs.msg import Bool, Float64
from yonoarc_msgs.msg import ObjectBBoxArray
import rospy
import time
class EB():
def __init__(self, node_name="eb_node"):
rospy.init_node(node_name)
import os
import subprocess
import time
import airsim
from std_msgs.msg import Header
import numpy as np
from sensor_msgs.msg import PointCloud2
from geometry_msgs.msg import Point32
import sensor_msgs.point_cloud2 as pcl2
from yonoarc_utils.image import to_ndarray, from_ndarray
class AirSim:
def download_run_airsim(self):
# Environment variables to run AirSim headless
os.environ["SDL_VIDEODRIVER_VALUE"] = "offscreen"
os.environ['SDL_HINT_CUDA_DEVICE'] = "0"
# AirSim Binaries List
list_env = ["Blocks", "Africa", "Building_99",
"Zhangjiajie", "Neighborhood", "SoccerField", "LandscapeMountains", "TrapCam"]
# Let's get the selected environment from our block properities
self.enviroment = list_env[self.get_property("env")]
class AirSim:
def on_start(self):
self.alert("creating airsim user and running ssh.....", "INFO")
# username and password for ssh
os.environ["USERNAME"] = "airsim"
os.environ["PASSWORD"] = "airsim1234"
# Run the ssh-server
os.system("(mkdir /home/$USERNAME && useradd $USERNAME && echo $USERNAME:$PASSWORD | chpasswd && usermod -aG sudo $USERNAME && chown airsim:airsim /home/airsim && usermod -d /home/airsim airsim && mkdir /var/run/sshd && /usr/sbin/sshd) &")
# Download and Run AirSim Binary
self.download_run_airsim()
class AirSim:
def on_button_clicked(self, button_key):
# Handle button Clicked Events.
if button_key == 'move_to':
# Parse the Move Command
pos_string = self.get_property("pos").split(",")
self.command_list = []
for st in pos_string:
self.command_list.append(float(st))
self.move_command = True
class AirSim:
def parse_lidarData(self, data):
# function to create PointCloud2 from Lidar Data
# reshape array of floats to array of [X,Y,Z]
points = np.array(data.point_cloud, dtype=np.dtype('f4'))
points = np.reshape(points, (int(points.shape[0]/3), 3))
header = Header()
header.frame_id = "lidar"
pcl = pcl2.create_cloud_xyz32(header, points)
return pcl

FreePalestine.Dev

Installing ROS Noetic on Raspberry Pi 4

Hello Everyone. I've been trying to install ROS Noetic on Raspbian GNU/Linux 10 (buster) from source but it was like a nightmare. Finally, I was able to install it and I want to share it with you.

Steps:

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

import subprocess
import os
import time
class Gazebo:
def on_start(self):
# Get the world file path form block's properties
self.world_file = self.get_property("world_file")
# Get the models files path form block's properties
self.models_path = self.get_property("models_path")
import subprocess
import os
import time
class Gazebo:
def on_start(self):
"""This block is used to launch gazebo in noVNC
it builds the ros workspace, source it , then run a launch file
which run gazebo ros and load the appropriate world file.
"""
self.ws_path = self.get_property("ws_path") # Workspace Path