Skip to content
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

Add launch parameter to disable auto firmware update #61

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,23 @@ ROS_NAMESPACE=zivid_camera rosrun nodelet nodelet standalone zivid_camera/nodele
The following parameters can be specified when starting the driver. Note that all the parameters are
optional, and typically not required to set.

For example, to launch the driver with `frame_id` specified, append `_frame_id:=camera1` to the
rosrun command:
For example, to run the zivid_camera driver with `frame_id` specified, append `_frame_id:=camera1` to the
`rosrun` command:

```bash
ROS_NAMESPACE=zivid_camera rosrun zivid_camera zivid_camera_node _frame_id:=camera1
```

Or, if using `roslaunch` specify the parameter using `<param>`:

```xml
<launch>
<node name="zivid_camera" pkg="zivid_camera" type="zivid_camera_node" ns="zivid_camera" output="screen">
<param type="string" name="frame_id" value="camera_1" />
</node>
</launch>
Comment on lines +201 to +208

Choose a reason for hiding this comment

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

Nice to add the example of launching the zivid_camera node with parameters.

I think it would be nice to add the available launch parameters to the sample.launch file also, since it's most convenient to run the zivid_camera node (and the application code) from launch files. It would be nice to include the available options to the sample.launch file then.

<node name="zivid_camera" pkg="zivid_camera" type="zivid_camera_node" ns="zivid_camera" output="screen"/>

Choose a reason for hiding this comment

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

Maybe something like this:

<arg name="frame_id" default="zivid_optical_frame"/>
<node name="zivid_camera" pkg="zivid_camera" type="zivid_camera_node" ns="zivid_camera" output="screen">
    <param type="string" name="frame_id" value="$(arg frame_id)"/>
</node>

Choose a reason for hiding this comment

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

Then we can add most/all available options, like serial_number and update_firmware_automatically, to that sample launch file.

Choose a reason for hiding this comment

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

Alternatively add a new zivid_camera launch file under https://github.com/zivid/zivid-ros/tree/master/zivid_camera/launch, and that launch file in the sample launch file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, might be a good idea to add a launch file with all the parameters. Here I just wanted to add an example of how to set it for a .launch file yourself. The disadvantage of having all of them in the launch file is that we duplicate the default value, I suppose. We already have an existing request for this: #34, so I think we should not solve it now as part of this PR.

Choose a reason for hiding this comment

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

Ah, sorry didn't go through the current list of issues. #34 explains very well what I meant.
Sure, it's fine for me not to update it as part of this PR.

If it's fine by you, I could make a follow-up PR for #34. I missed this when I was using the driver for internal usage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feel free to make a PR for this @runenordmo

```

`file_camera_path` (string, default: "")
> Specify the path to a file camera to use instead of a real Zivid camera. This can be used to
> develop without access to hardware. The file camera returns the same point cloud for every capture.
Expand All @@ -219,6 +229,13 @@ ROS_NAMESPACE=zivid_camera rosrun zivid_camera zivid_camera_node _frame_id:=came
> the command line or rosparam the serial number must be prefixed with a colon (`:12345`).
> This parameter is optional. By default the driver will connect to the first available camera.

`update_firmware_automatically` (bool, default: true)
> Specify if the firmware of the connected camera should be automatically updated to the correct
> version when the Zivid ROS driver starts. If set to false, if the firmware version is out of date
> then camera must be manually updated, for example using Zivid Studio or `ZividFirmwareUpdater`.
> Read more about [firmware update in our knowledgebase][firmware-update-kb-url].
> This parameter is optional, and by default it is true.

## Services

### capture_assistant/suggest_settings
Expand Down Expand Up @@ -640,4 +657,5 @@ grant agreement No 732287. For more information, visit [rosin-project.eu](http:/
[zivid-knowledge-base-url]: https://support.zivid.com
[zivid-software-installation-url]: https://support.zivid.com/latest/getting-started/software-installation.html
[install-opencl-drivers-ubuntu-url]: https://support.zivid.com/latest/getting-started/software-installation/gpu/install-opencl-drivers-ubuntu.html
[hdr-getting-good-point-clouds-url]: https://support.zivid.com/latest/academy/camera/capturing-high-quality-point-clouds/getting-the-right-exposure-for-good-point-clouds.html
[hdr-getting-good-point-clouds-url]: https://support.zivid.com/latest/academy/camera/capturing-high-quality-point-clouds/getting-the-right-exposure-for-good-point-clouds.html
[firmware-update-kb-url]: https://support.zivid.com/latest/academy/camera/firmware-update.html
23 changes: 18 additions & 5 deletions zivid_camera/src/zivid_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ ZividCamera::ZividCamera(ros::NodeHandle& nh, ros::NodeHandle& priv)
priv_.param<bool>("use_latched_publisher_for_snr_image", use_latched_publisher_for_snr_image_, false);
priv_.param<bool>("use_latched_publisher_for_normals_xyz", use_latched_publisher_for_normals_xyz_, false);

bool update_firmware_automatically = true;
priv_.param<bool>("update_firmware_automatically", update_firmware_automatically, update_firmware_automatically);

if (file_camera_mode)
{
ROS_INFO("Creating file camera from file '%s'", file_camera_path.c_str());
Expand Down Expand Up @@ -181,11 +184,21 @@ ZividCamera::ZividCamera(ros::NodeHandle& nh, ros::NodeHandle& priv)

if (!Zivid::Firmware::isUpToDate(camera_))
{
ROS_INFO("The camera firmware is not up-to-date, starting update");
Zivid::Firmware::update(camera_, [](double progress, const std::string& state) {
ROS_INFO(" [%.0f%%] %s", progress, state.c_str());
});
ROS_INFO("Firmware update completed");
if (update_firmware_automatically)
{
ROS_INFO("The camera firmware is not up-to-date, and update_firmware_automatically is true, starting update");
Zivid::Firmware::update(camera_, [](double progress, const std::string& state) {
ROS_INFO(" [%.0f%%] %s", progress, state.c_str());
});
ROS_INFO("Firmware update completed");
}
else
{
ROS_ERROR("The camera firmware is not up-to-date, and update_firmware_automatically is false. Throwing error.");
throw std::runtime_error("The firmware on camera '" + camera_.info().serialNumber().value() +
"' is not up to date. The launch parameter update_firmware_automatically "
"is set to false. Please update the firmware on this camera manually.");
}
}
}

Expand Down