Skip to content

Event camera #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 6, 2021
Merged

Event camera #83

merged 7 commits into from
Apr 6, 2021

Conversation

gerni17
Copy link

@gerni17 gerni17 commented Feb 28, 2021

This is the event camera implementation.

gerni17 and others added 2 commits February 28, 2021 13:46
* workin pipeline, wrong velocity format and of doesn't seem to work

* nice pipeline with histo, but rather slow

* check the framerate

* not working pipeline

* working pipeline of firt event sensor

* commit before implementing trajectory

* able to send the events to client

* able to transfrm it ina image but not properly working

* wrong deserialization

* working pipeline

* added timestep

* not working trajectory

* not working

* working but not moving

* some working

* racing is workin properly, the oter one not really

* working in racing

* first working pipeline, but not ood yet

* not working pieline

* working but wrong error

* not workin testing

* having big errors again

* events and other thing do not have same coordinates

* working with second last images

* nothing important

* check coroutines

* added client evet settings

* i don't undertand why but this works

* added histogram and removed second image

* rosbag publisher

* not working

* working pipeline

* tested and storing rosbags

* cleaned code and added recording script

* new env, writing to rosbag, no pos wirting

* saving image and events

* save image

* writing images and erasing zeros

* proper time function

* saving properly

* huge error accumulation

* little faster and testing is more independent, overall working

* recieving all images

* snaga

* changed testin bag destination

* changed to previous port numbers

* added depth and int64, still ring trajectory

* added snaga config

* this looks nice for now

* working but has to be cleaned and made smarter, still having the helper function

* wrkin ad clean

* for snaga to produce video

* trajectory

* higher res

* slightl change of trajectory

* recording definitive

* major changes to make it adaptive

* formatted

* added linear depth

* added adaptive time of elia

* add rotation

* added corect pos output

* added speed variing

* added trajectory

* doubled vel

* added new trajectory

* added angle to pure translation

* add fourth traj

* trajectory five

* sixth trajectory

* seventh trajectory

* cleaned code
@antonilo antonilo requested a review from yun-long March 6, 2021 10:38
@@ -3,6 +3,9 @@ dist
*.egg-info
*.so
__pycache__
build

flightros/params/local.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this line necessary?

@@ -96,7 +103,7 @@ class UnityBridge {
int64_t u_packet_latency_;

// axuiliary variables
const Scalar unity_connection_time_out_{10.0};
const Scalar unity_connection_time_out_{1000.0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using such a large time out

int output_index{0};
// eventcamera settings
float Cm{0.1};
float Cp{0.1};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are Cm and Cp?
and why not using "Scalar" instead "float"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp and cm are the thresholds of the event sensor.

// #include <cstdio>
// #include <stdint.h>
// #include <cinttypes>
// #include <ze/common/transformation.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can delete these comments if they are no longer needed

// using uint16_t = ze::uint16_t;
// using uint16_t =std::unit16_t;
// using Time = std::int64_t;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also delete these comments if no longer needed

// uint16_t y;
// Time t;
// bool pol;
// };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

bool setsigmaCm(const float sigma_cm);
bool setRefractory(const uint64_t refractory_period);
bool setLogEps(const float log_eps);
bool setImgStore(const bool img_store);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use "Scalar" instead of "float"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

bool setImgStore(const bool img_store);

bool changeTime(TimeMessage_t time_msg);
double getSecSimTime();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why using 'double" here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we need a higher resolution for this variable

cv::Mat createEventimages();

private:
Logger logger_{"RBGCamera"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an event camera, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, my bad

@@ -81,6 +82,7 @@ bool UnityBridge::sendInitialSettings(void) {
msg << "Pose";
// create JSON object for initial settings
json json_mesg = settings_;
std::cout << settings_.vehicles[0].eventcameras.size();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like a debug code. you can remove it

// << " seconds." << std::endl;
// usleep((time_out / 10.0) * 1e6);
// run_time += time_out / 10.0;
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the code is commented out by accident.

float sigma_cp_;
float sigma_cm_;
int64_t refractory_period_ns_;
float log_eps_;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float or Scalar

handleOutput(always);
}

bool UnityBridge::handleOutput(bool always) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always is not used

// create new message object
zmqpp::message msg;
logger_.info(sub_port_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like only for debug. remove it if not needed

std::end(events));
queue_mutex_.unlock();
std::string amount = std::to_string(event_queue_for_img.size());
logger_.warn(amount);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need a warning here?


EventCamera::EventCamera()
: channels_(3), width_(720), height_(480), fov_{70.0} {
auto time = std::chrono::high_resolution_clock::now();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace auto with std::chrono::high_resolution_clock::now

}
logger_.error("empty events buffer");
return events;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get which events? all events from the start or a single event at the current time step?

bool EventCamera::setCp(const float cp) {
if (cp <= 0.0) {
logger_.warn(
"The setting value for Eventcamera Cp is not valid, discard the "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is Cp, maybe be specific here

float getCm(void) const;
float getCp(void) const;
float getsigmaCm(void) const;
float getsigmaCp(void) const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are floats needed, or Scalar

@@ -24,6 +24,7 @@ bool UnityBridge::initializeConnections() {
pub_.bind(client_address_ + ":" + pub_port_);

// create and bind a download_socket
logger_.info(sub_port_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this logger for debug only

@@ -269,37 +322,100 @@ bool UnityBridge::handleOutput() {
}
}
}
// feed events to the eventcamera
for (const auto& cam : settings_.vehicles[idx].eventcameras) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not use auto

@@ -0,0 +1,90 @@
#pragma once
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the record.hpp can be more specific, e.g., "record_events.hpp"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is actually to record all kind of data, e.g. positions, images, ...

@@ -0,0 +1,94 @@
#pragma once
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this testing.hpp file needed?

Copy link
Collaborator

@yun-long yun-long left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some high-level comments:

  • use clang-format for automatically formating the c++ code
  • be consistent when using "float" or "double", I prefer using "Scalar"
  • delete codes that are not longer needed, such as std::cout , longer, or commented code
  • in flightros, put the ROS example into a single folder, e.g., a folder named "eventcamera"

@gerni17 gerni17 changed the base branch from master to dev/eventcamera April 5, 2021 12:13
@yun-long yun-long merged commit 40cd22e into uzh-rpg:dev/eventcamera Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants