Skip to content

Commit

Permalink
Incorporate sensor type DRVEGRD 152
Browse files Browse the repository at this point in the history
Linkt to issue #11
  • Loading branch information
smartSRA authored Oct 19, 2022
1 parent 1a0b8e8 commit a08720b
Show file tree
Hide file tree
Showing 16 changed files with 320 additions and 56 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ This release also offers the possibilty of configuring the ip addresses of the s
## v3.0.0 - 2022-09-23

Major release includes the new smartmicro sensor DRVEGRD 169. The driver offers mode changes and configuration of the DRVEGRD 169 along with publishing the radar targets as pointcloud data. The callbacks for datastream now require a clientID.

## v3.1.0 - 2022-10-19

This release includes the new smartmicro sensor DRVEGRD 152. The driver offers mode changes and configuration of the DRVEGRD 152 along with publishing the radar targets as pointcloud data. The callbacks for datastream now require a clientID.
File renamed without changes.
9 changes: 6 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ ros2 launch umrr_ros2_driver radar.launch.py
- ROS2 foxy

### UMRR radars and Smart Access API version
A [smartmicro](https://www.smartmicro.com/automotive-radar) UMRR96 radar, UMRR11 radar or UMRR9F radar are
A [smartmicro](https://www.smartmicro.com/automotive-radar) UMRR96, UMRR11, DRVEGRD 152 or DRVEGRD 169 radar are
required to run this node. This code is bundled with a version of Smart Access API. Please make
sure the version used to publish the data is compatible with this version:

- Date of release: `September 22, 2022`
- Smart Access Automotive version: `v2.0.0`
- Date of release: `October 19, 2022`
- Smart Access Automotive version: `v2.1.0`
- User interface version: `UMRR96 Type 153 AUTOMOTIVE v1.2.1`
- User interface version: `UMRR11 Type 132 AUTOMOTIVE v1.1.1`
- User interface version: `UMRR9F Type 169 AUTOMOTIVE v1.1.1`
- User interface version: `UMRR9D Type 152 AUTOMOTIVE v1.0.1`

### Sensor Firmwares
This ROS2 driver release is compatible with the following sensor firmwares:
- UMRR11 Type 132: V5.1.4
- UMRR96 Type 153: V5.2.4
- UMRR9D Type 152: V1.0.0
- UMRR9F Type 169: V1.3.0

### Point cloud message wrapper library
To add targets to the point cloud in a safe and quick fashion a
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,28 @@ services:
networks:
device_network:
ipv4_address: 172.22.10.103
sensor_3:
depends_on:
build_simulator:
condition: service_completed_successfully
image: umrr-ros:latest
volumes:
- .:/code
environment:
- SMART_ACCESS_CFG_FILE_PATH=/code/simulator/config_umrr9d/com_lib_config.json
- LD_LIBRARY_PATH=/code/umrr_ros2_driver/smartmicro/lib-linux-x86_64-gcc_9
entrypoint: ["/code/simulator/simulation/out/bin/simulator"]
command: ["11", "1", "0", "C"]
networks:
device_network:
ipv4_address: 172.22.10.104
ros_node:
image: umrr-ros:latest
depends_on:
- "sensor_0"
- "sensor_1"
- "sensor_2"
- "sensor_3"
volumes:
- .:/code
command: ["colcon", "test", "--packages-above", "umrr_ros2_driver"]
Expand Down
16 changes: 16 additions & 0 deletions simulator/config_umrr9d/com_lib_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Com Lib Config",
"version": "1.0.0",
"client_id": 400,
"role": "slave",
"shared_lib_path": "/code/umrr_ros2_driver/smartmicro/lib-linux-x86_64-gcc_9",
"config_path": "/code/simulator/config_umrr9d",
"user_interface_name": "umrr9d_t152_automotive",
"user_interface_major_v": 1,
"user_interface_minor_v": 0,
"user_interface_patch_v": 1,
"download_path": "",
"instruction_serialization_type": "port_based",
"data_serialization_type": "port_based",
"alive": false
}
12 changes: 12 additions & 0 deletions simulator/config_umrr9d/hw_inventory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"hwItems": [
{
"type": "eth",
"dev_id": 1,
"iface_name": "eth0",
"port": 55555
}
],
"name": "HW inventory List",
"version": "1.1.0"
}
14 changes: 14 additions & 0 deletions simulator/config_umrr9d/routing_table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"clients": [
{
"client_id": 1,
"data_serialization_type": "port_based",
"instruction_serialization_type": "port_based",
"ip": "172.22.10.100",
"link_type": "eth",
"port": 55555
}
],
"name": "Client Routing Table",
"version": "1.0.0"
}
103 changes: 57 additions & 46 deletions simulator/simulation/src/simulator.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
// Copyright (c) 2021, s.m.s, smart microwave sensors GmbH, Brunswick, Germany.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <CommunicationServicesIface.h>
#include <DataServicesIface.h>
#include <DeviceMonitorServiceIface.h>
#include <Instruction.h>
#include <InstructionBatch.h>
#include <InstructionBuffer.h>
#include <InstructionServiceIface.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#include <chrono>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include <string>
#include <thread>

using namespace com::common;
using namespace com::master;
using namespace com::types;

namespace
{
uint64_t identifier;
uint64_t majorVersion;
uint64_t minorVersion;
std::string port;
std::string portFile;

} // namespace

std::shared_ptr<com::common::DataServicesIface> dataServices =
com::common::DataServicesIface::Get();
com::common::DataServicesIface::Get();

void slave_callback(ClientId clientId, PortId, BufferDescriptor buffer) {
InstructionBuffer *receive =
reinterpret_cast<InstructionBuffer *>(buffer.GetBufferPtr());
void slave_callback(ClientId clientId, PortId, BufferDescriptor buffer)
{
InstructionBuffer * receive = reinterpret_cast<InstructionBuffer *>(buffer.GetBufferPtr());
int sizeIncomingBuf = buffer.GetSize();
uint32_t instnumber = receive->GetNumOfInstructions();
auto instructions = receive->GetInstructions();
Expand All @@ -41,40 +59,33 @@ void slave_callback(ClientId clientId, PortId, BufferDescriptor buffer) {
std::cout << "Base user interface major version set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
instruction->SetValue(1);
} else if (instruction->GetSectionId() == 3042 &&
instruction->GetId() == 21) {
} else if (instruction->GetSectionId() == 3042 && instruction->GetId() == 21) {
std::cout << "Base user interface minor version set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
instruction->SetValue(0);
} else if (instruction->GetSectionId() == 3042 &&
instruction->GetId() == 22) {
} else if (instruction->GetSectionId() == 3042 && instruction->GetId() == 22) {
std::cout << "User interface identifier set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
instruction->SetValue(identifier);
} else if (instruction->GetSectionId() == 3042 &&
instruction->GetId() == 23) {
} else if (instruction->GetSectionId() == 3042 && instruction->GetId() == 23) {
std::cout << "User interface major version set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
instruction->SetValue(majorVersion);
} else if (instruction->GetSectionId() == 3042 &&
instruction->GetId() == 24) {
} else if (instruction->GetSectionId() == 3042 && instruction->GetId() == 24) {
std::cout << "User interface minor version set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
instruction->SetValue(minorVersion);
} else if (instruction->GetSectionId() == 2010 &&
instruction->GetId() == 2) {
std::cout << "UMRR96 mode frequency_sweep set!"
<< std::endl;
} else if (instruction->GetSectionId() == 2010 && instruction->GetId() == 2) {
std::cout << "UMRR96 mode frequency_sweep set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
} else if (instruction->GetSectionId() == 2010 && instruction->GetId() == 4) {
std::cout << "UMRR11 mode angular_separation set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
} else if (instruction->GetSectionId() == 2010 &&
instruction->GetId() == 4) {
std::cout << "UMRR11 mode angular_separation set!"
<< std::endl;
} else if (instruction->GetSectionId() == 2010 && instruction->GetId() == 5) {
std::cout << "UMRR9F mode range_toggle_mode set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
} else if (instruction->GetSectionId() == 2010 &&
instruction->GetId() == 5) {
std::cout << "UMRR9F mode range_toggle_mode set!"
<< std::endl;
} else if (instruction->GetSectionId() == 2010 && instruction->GetId() == 1) {
std::cout << "UMRR9D mode center_frequency_idx set!" << std::endl;
instruction->SetResponse(COM_INSTR_PORT_SUCCESS);
} else {
std::cout << "Unknown instruction received from ROS driver!" << std::endl;
Expand All @@ -84,17 +95,17 @@ void slave_callback(ClientId clientId, PortId, BufferDescriptor buffer) {
dataServices->SetInstructionBuffer(clientId, *receive, nullptr);
}

void stream_port(std::string portFile) {

void stream_port(std::string portFile)
{
dataServices->RegisterInstRecvCallback(slave_callback);

ClientId masterId = 1;
PortId portTargetListId = 66;
std::ifstream ifs(portFile, std::ifstream::binary | std::ios::binary);
std::filebuf *pbuf = ifs.rdbuf();
std::filebuf * pbuf = ifs.rdbuf();
int size = pbuf->pubseekoff(0, ifs.end, ifs.in);
pbuf->pubseekpos(0, ifs.in);
char *filebuffer = new (std::nothrow) char[size];
char * filebuffer = new (std::nothrow) char[size];

if (filebuffer == nullptr) {
std::cout << "error assigning memory!" << std::endl;
Expand All @@ -104,18 +115,17 @@ void stream_port(std::string portFile) {
BufferDescriptor bufferdesc((uint8_t *)filebuffer, size);
std::this_thread::sleep_for(std::chrono::seconds(1));

if (ERROR_CODE_OK !=
dataServices->StreamDataPort(masterId, portTargetListId, bufferdesc)) {
if (ERROR_CODE_OK != dataServices->StreamDataPort(masterId, portTargetListId, bufferdesc)) {
return;
}

std::cout << "sensor is transmitting data! " << std::endl;
ifs.close();
delete[] filebuffer;

}

int main(int argc, char *argv[]) {

int main(int argc, char * argv[])
{
if (argc != 5) {
std::cout << "Specifiy User Interface for the sensor" << std::endl;
return 1;
Expand All @@ -125,28 +135,29 @@ int main(int argc, char *argv[]) {
majorVersion = strtoll(argv[2], nullptr, 10);
minorVersion = strtoll(argv[3], nullptr, 10);
port = argv[4];

if (!dataServices->Init()) {
throw std::runtime_error("Data services have not been initialized!");
}

auto Start = std::chrono::steady_clock::now();

while (1) {

if(port == "A") {
if (port == "A") {
std::string portFile = "/code/simulator/targetlist_port_v2_1_0.bin";
stream_port(portFile);
}
else if(port == "B") {
} else if (port == "B") {
std::string portFile = "/code/simulator/targetlist_port_v3_0_0.bin";
stream_port(portFile);
}
else {
} else if (port == "C") {
std::string portFile = "/code/simulator/targetlist_port_v4_0_0.bin";
stream_port(portFile);
} else {
std::cout << "Invalid input!" << std::endl;
}
if (std::chrono::steady_clock::now() - Start > std::chrono::seconds(30))
if (std::chrono::steady_clock::now() - Start > std::chrono::seconds(30)) {
break;
}
}
return 0;
}
Binary file added simulator/targetlist_port_v4_0_0.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion smart_extract.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

smart_pack=SmartAccessAutomotive_2_0_0.tar.gz
smart_pack=SmartAccessAutomotive_2_1_0.tar.gz
URL_smartbinaries=https://www.smartmicro.com/fileadmin/media/Downloads/Automotive_Radar/Software/${smart_pack}

cat << EOF
Expand Down
7 changes: 5 additions & 2 deletions umrr_ros2_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ install(FILES
"${PROJECT_SOURCE_DIR}/smartmicro/lib-linux-x86_64-gcc_9/libumrr11_t132_automotivev1.1.1_user_interface.so"
"${PROJECT_SOURCE_DIR}/smartmicro/lib-linux-x86_64-gcc_9/libumrr96_t153_automotivev1.2.1_user_interface.so"
"${PROJECT_SOURCE_DIR}/smartmicro/lib-linux-x86_64-gcc_9/libumrr9f_t169_automotivev1.1.1_user_interface.so"
"${PROJECT_SOURCE_DIR}/smartmicro/lib-linux-x86_64-gcc_9/libumrr9d_t152_automotivev1.0.1_user_interface.so"
DESTINATION lib)

set(LIB_PATH "${CMAKE_INSTALL_PREFIX}/lib")
Expand All @@ -79,7 +80,8 @@ target_include_directories(smartmicro_radar_node PUBLIC ${CMAKE_INSTALL_PREFIX}/
smartmicro/include/
smartmicro/include/umrr11_t132_automotive_v1_1_1
smartmicro/include/umrr96_t153_automotive_v1_2_1
smartmicro/include/umrr9f_t169_automotive_v1_1_1)
smartmicro/include/umrr9f_t169_automotive_v1_1_1
smartmicro/include/umrr9d_t152_automotive_v1_0_1)

# link smart_access_lib-linux-x86_64-gcc_9 to the node
target_link_libraries(smartmicro_radar_node
Expand All @@ -89,7 +91,8 @@ target_link_libraries(smartmicro_radar_node
osal
umrr11_t132_automotivev1.1.1_user_interface
umrr96_t153_automotivev1.2.1_user_interface
umrr9f_t169_automotivev1.1.1_user_interface)
umrr9f_t169_automotivev1.1.1_user_interface
umrr9d_t152_automotivev1.0.1_user_interface)

rclcpp_components_register_node(smartmicro_radar_node
PLUGIN "smartmicro::drivers::radar::SmartmicroRadarNode"
Expand Down
Loading

0 comments on commit a08720b

Please sign in to comment.