Skip to content

Instantly share code, notes, and snippets.

View ibraEssam's full-sized avatar
🇵🇸
Free Palestine

Ibrahim Essam ibraEssam

🇵🇸
Free Palestine
View GitHub Profile
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 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 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")]
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
#!/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)
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
def on_new_messages(self, messages):
if 'brake' in messages:
print("Braking signal received...")
print(messages['brake'].data)
brake_action = messages['brake'].data
if brake_action:
self.cm.DVA_write(self.brake_quant, 1)
else:
self.cm.DVA_write(self.brake_quant, 0)
if 'steer_sign' in messages:
#!/bin/bash
(while sleep 2; do /opt/TurboVNC/bin/vncserver -geometry 1366x768 -securitytypes TLSNone,X509None,None :1; done & DISPLAY=":1" sh ~/.vnc/xstartup.turbovnc & cd /noVNC && ./utils/launch.sh --vnc localhost:5901) & (export DISPLAY=:1 ; ./opt/ipg/carmaker/linux64-8.1.1/bin/CM -cmdport 16660
) & sleep infinity
import cv2
from pycarmaker import VDS
# initalize VDS
vds = VDS()
# Connect
vds.connect()
# Read Images
while(True):
# Capture frame-by-frame
nViews 1
# First camera
0 {
Width 640
Height 480
Export {rgb}
VPtOffset_x 3.1
VPtOffset_y 0
VPtOffset_z 1.1
FrameRate 25